Iris's worlds give the built-ins their IrisSeed; facade tests

This commit is contained in:
piexel committed 2026-10-10 13:15:34 +02:00
1 parent c270f79827
commit 405ab0fb2d
2 files changed
+115 -1

No files matched your search

@@ -0,0 +1,95 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.builtin.PendingSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import com.volmit.world.PackWorld;
import org.junit.Test;
import java.util.EnumMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** An Iris world answers the built-ins' narrow questions: Iris's own seeds, and the settings still on its dimension. */
public class IrisWorldFacadesTest {
@Test
public void everyIrisSeedIsTheSeedManagersSeedOfThatName() {
SeedManager seeds = mock(SeedManager.class);
when(seeds.getBiome()).thenReturn(1L);
when(seeds.getCarve()).thenReturn(2L);
when(seeds.getComponent()).thenReturn(3L);
when(seeds.getDecorator()).thenReturn(4L);
when(seeds.getDeposit()).thenReturn(5L);
when(seeds.getEntity()).thenReturn(6L);
when(seeds.getLoot()).thenReturn(7L);
when(seeds.getMantle()).thenReturn(8L);
when(seeds.getPost()).thenReturn(9L);
when(seeds.getTerrain()).thenReturn(10L);
Engine engine = engine(new IrisDimension());
when(engine.getSeedManager()).thenReturn(seeds);
PackWorld world = new IrisPackWorld(engine);
Map<IrisSeed, Long> expected = new EnumMap<>(IrisSeed.class);
long next = 1;
for (IrisSeed seed : IrisSeed.values()) {
expected.put(seed, next++);
}
for (IrisSeed seed : IrisSeed.values()) {
assertEquals(seed.name(), expected.get(seed).longValue(), seed.of(world));
}
}
@Test
public void pendingSettingsAreTheDimensionsOwn() {
IrisDimension dimension = new IrisDimension();
dimension.setHideOresForHiddenOre(true);
dimension.setPostProcessingWalls(false);
PendingSettings pending = PendingSettings.of(new IrisPackWorld(engine(dimension)));
assertTrue(pending.hidesOres());
assertFalse(pending.postProcessingWalls());
assertTrue("slabs are on by default", pending.postProcessingSlabs());
}
@Test
public void aWorldIrisDoesNotGenerateHasNeither() {
PackWorld foreign = mock(PackWorld.class);
assertThrows(IllegalArgumentException.class, () -> IrisSeed.POST.of(foreign));
assertThrows(IllegalArgumentException.class, () -> PendingSettings.of(foreign));
}
private static Engine engine(IrisDimension dimension) {
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(dimension);
return engine;
}
}