mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2025-02-01 21:11:19 +01:00
Fix tests
This commit is contained in:
parent
ea16a45114
commit
b703e91129
@ -138,7 +138,7 @@ public class AcidEffectTest {
|
||||
when(inv.getArmorContents()).thenReturn(armor);
|
||||
|
||||
// Location
|
||||
when(location.getBlockY()).thenReturn(0);
|
||||
when(location.getBlockY()).thenReturn(-66);
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
when(location.getBlock()).thenReturn(block);
|
||||
|
||||
@ -172,6 +172,7 @@ public class AcidEffectTest {
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock);
|
||||
when(world.getMaxHeight()).thenReturn(5);
|
||||
when(world.getMinHeight()).thenReturn(-65);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
|
||||
// Plugin
|
||||
|
@ -1,26 +1,14 @@
|
||||
package world.bentobox.acidisland.world;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -45,9 +33,6 @@ public class ChunkGeneratorWorldTest {
|
||||
private ChunkGeneratorWorld cg;
|
||||
@Mock
|
||||
private World world;
|
||||
private final Random random = new Random();
|
||||
@Mock
|
||||
private BiomeGrid biomeGrid;
|
||||
private AISettings settings;
|
||||
@Mock
|
||||
private ChunkData data;
|
||||
@ -69,135 +54,6 @@ public class ChunkGeneratorWorldTest {
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldNormal() {
|
||||
// Instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Default biome
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Void
|
||||
verify(cd).setRegion(0, 0, 0, 16, 55, 16, Material.WATER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldNormalVoid() {
|
||||
settings.setSeaHeight(0);
|
||||
// Instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Default biome
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Void
|
||||
verify(cd, never()).setRegion(anyInt(), anyInt(),anyInt(),anyInt(),anyInt(),anyInt(), any(Material.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldVoidLava() {
|
||||
settings.setSeaHeight(54);
|
||||
settings.setWaterBlock(Material.LAVA);
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Default biome
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Void
|
||||
verify(cd).setRegion(0, 0, 0, 16, 55, 16, Material.LAVA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldSea() {
|
||||
// Set sea height
|
||||
settings.setSeaHeight(10);
|
||||
// new instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Default biome
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Water. Blocks = 16 x 16 x 11 because block 0
|
||||
verify(cd).setRegion(0, 0, 0, 16, 11, 16, Material.WATER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridEnd() {
|
||||
settings.setEndSeaHeight(0);
|
||||
// Instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
when(world.getEnvironment()).thenReturn(World.Environment.THE_END);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Set biome in end
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Void
|
||||
verify(cd, never()).setRegion(anyInt(), anyInt(),anyInt(),anyInt(),anyInt(),anyInt(), any(Material.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridNetherWithRoof() {
|
||||
// Instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Never set biome in nether
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Nether roof - at least bedrock layer
|
||||
verify(cd, atLeast(16 * 16)).setBlock(anyInt(), anyInt(), anyInt(), eq(Material.BEDROCK));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGenerateChunkDataWorldRandomIntIntBiomeGridNetherNoRoof() {
|
||||
settings.setNetherRoof(false);
|
||||
// Instance
|
||||
cg = new ChunkGeneratorWorld(addon);
|
||||
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
|
||||
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
|
||||
assertEquals(data, cd);
|
||||
// Verifications
|
||||
// Never set biome in nether
|
||||
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
|
||||
// Nether roof - at least bedrock layer
|
||||
verify(cd, never()).setBlock(anyInt(), anyInt(), anyInt(), any(Material.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#canSpawn(org.bukkit.World, int, int)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user