49 lines
1.9 KiB
Java
49 lines
1.9 KiB
Java
package games.dmg.spigotbase;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.when;
|
|
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.block.data.type.Slab;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
final class SpawnableBlockPolicyTest {
|
|
@Test
|
|
void acceptsDarkSolidSurfaceWithTwoPassableBlocksAbove() {
|
|
Block surface = mock(Block.class);
|
|
Block above = mock(Block.class);
|
|
Block secondAbove = mock(Block.class);
|
|
Slab slab = mock(Slab.class);
|
|
when(slab.getType()).thenReturn(Slab.Type.TOP);
|
|
when(surface.getBlockData()).thenReturn(slab);
|
|
when(surface.getRelative(BlockFace.UP)).thenReturn(above);
|
|
when(above.getRelative(BlockFace.UP)).thenReturn(secondAbove);
|
|
when(above.isPassable()).thenReturn(true);
|
|
when(secondAbove.isPassable()).thenReturn(true);
|
|
when(above.getLightFromBlocks()).thenReturn((byte) 0);
|
|
when(above.getLightFromSky()).thenReturn((byte) 0);
|
|
|
|
assertTrue(SpawnableBlockPolicy.isCandidate(surface));
|
|
}
|
|
|
|
@Test
|
|
void rejectsBlockLitSurface() {
|
|
Block surface = mock(Block.class);
|
|
Block above = mock(Block.class);
|
|
Block secondAbove = mock(Block.class);
|
|
Slab slab = mock(Slab.class);
|
|
when(slab.getType()).thenReturn(Slab.Type.TOP);
|
|
when(surface.getBlockData()).thenReturn(slab);
|
|
when(surface.getRelative(BlockFace.UP)).thenReturn(above);
|
|
when(above.getRelative(BlockFace.UP)).thenReturn(secondAbove);
|
|
when(above.isPassable()).thenReturn(true);
|
|
when(secondAbove.isPassable()).thenReturn(true);
|
|
when(above.getLightFromBlocks()).thenReturn((byte) 1);
|
|
|
|
assertFalse(SpawnableBlockPolicy.isCandidate(surface));
|
|
}
|
|
}
|