Added GreenhouseFinder test class

This commit is contained in:
tastybento 2020-10-04 16:32:34 -07:00
parent a96a926a7d
commit 2419e40241
2 changed files with 594 additions and 82 deletions

View File

@ -1,12 +1,15 @@
package world.bentobox.greenhouses.managers;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import world.bentobox.greenhouses.data.Greenhouse;
import world.bentobox.greenhouses.greenhouse.Roof;
@ -15,9 +18,29 @@ import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
public class GreenhouseFinder {
private Greenhouse gh;
private Greenhouse gh = new Greenhouse();
private final Set<Location> redGlass = new HashSet<>();
// Counts
private int wallDoors = 0;
// Hoppers
private int ghHopper = 0;
// Air
private boolean airHoles = false;
// Other blocks
private boolean otherBlocks = false;
// Ceiling issue
private boolean inCeiling = false;
// The y height where other blocks were found
// If this is the bottom layer, the player has most likely uneven walls
private int otherBlockLayer = -1;
private int wallBlockCount;
class CounterCheck {
int doorCount;
int hopperCount;
boolean airHole;
boolean otherBlock;
}
/**
* Find out if there is a greenhouse here
@ -41,98 +64,34 @@ public class GreenhouseFinder {
// Set the original biome
gh.setOriginalBiome(location.getBlock().getBiome());
// Now check again to see if the floor really is the floor and the walls follow the rules
// Now check to see if the floor really is the floor and the walls follow the rules
result.addAll(checkGreenhouse(gh, roof, walls));
return result;
}
Set<GreenhouseResult> checkGreenhouse(Greenhouse gh2, Roof roof, Walls walls) {
Set<GreenhouseResult> result = new HashSet<>();
World world = roof.getLocation().getWorld();
int minX = walls.getMinX();
int minZ = walls.getMinZ();
int maxX = walls.getMaxX();
int maxZ = walls.getMaxZ();
// Counts
int wallDoors = 0;
// Hoppers
int ghHopper = 0;
// Air
boolean airHoles = false;
// Other blocks
boolean otherBlocks = false;
// Ceiling issue
boolean inCeiling = false;
// The y height where other blocks were found
// If this is the bottom layer, the player has most likely uneven walls
int otherBlockLayer = -1;
int wallBlockCount;
int y;
for (y = world.getMaxHeight() - 1; y >= walls.getFloor(); y--) {
int doorCount = 0;
int hopperCount = 0;
boolean airHole = false;
boolean otherBlock = false;
CounterCheck cc = new CounterCheck();
wallBlockCount = 0;
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
Location thisBlock = new Location(world, x, y, z);
Material blockType = world.getBlockAt(x, y, z).getType();
// Checking above greenhouse - no blocks allowed
if (y > roof.getHeight()) {
// We are above the greenhouse
if ((world.getEnvironment().equals(Environment.NORMAL) || world.getEnvironment().equals(Environment.THE_END))
&& blockType != Material.AIR) {
result.add(GreenhouseResult.FAIL_BLOCKS_ABOVE);
redGlass.add(thisBlock);
}
} else {
// Check just the walls
if (y == roof.getHeight() || x == minX || x == maxX || z == minZ || z== maxZ) {
if ((y != roof.getHeight() && !Walls.wallBlocks(blockType))
|| (y == roof.getHeight() && !Roof.roofBlocks(blockType))) {
//logger(2,"DEBUG: bad block found at " + x + "," + y+ "," + z + " " + blockType);
if (blockType == Material.AIR) {
airHole = true;
if (y == roof.getHeight()) {
inCeiling = true;
}
} else {
otherBlock = true;
}
redGlass.add(thisBlock);
} else {
wallBlockCount++;
// A string comparison is used to capture 1.8+ door types without stopping pre-1.8
// servers from working
if (blockType.toString().contains("DOOR")) {
doorCount++;
// If we already have 8 doors add these blocks to the red list
if (wallDoors == 8) {
redGlass.add(thisBlock);
}
}
if (blockType.equals(Material.HOPPER)) {
hopperCount++;
if (ghHopper > 0) {
// Problem! Add extra hoppers to the red glass list
redGlass.add(thisBlock);
} else {
// This is the first hopper
gh.setRoofHopperLocation(thisBlock);
}
}
}
}
}
for (int x = walls.getMinX(); x <= walls.getMaxX(); x++) {
for (int z = walls.getMinZ(); z <= walls.getMaxZ(); z++) {
result.addAll(checkBlock(cc, roof, walls, world.getBlockAt(x, y, z)));
}
}
if (wallBlockCount == 0 && y < roof.getHeight()) {
// This is the floor
break;
} else {
wallDoors += doorCount;
ghHopper += hopperCount;
if (airHole) {
wallDoors += cc.doorCount;
ghHopper += cc.hopperCount;
if (cc.airHole) {
airHoles = true;
}
if (otherBlock) {
if (cc.otherBlock) {
otherBlocks = true;
if (otherBlockLayer < 0) {
otherBlockLayer = y;
@ -140,6 +99,13 @@ public class GreenhouseFinder {
}
}
}
result.addAll(checkErrors(roof, y));
return result;
}
Collection<GreenhouseResult> checkErrors(Roof roof, int y) {
Set<GreenhouseResult> result = new HashSet<>();
// Check that the player is vertically in the greenhouse
if (roof.getLocation().getBlockY() <= y) {
result.add(GreenhouseResult.FAIL_BELOW);
@ -166,10 +132,83 @@ public class GreenhouseFinder {
if (ghHopper > 1) {
result.add(GreenhouseResult.FAIL_TOO_MANY_HOPPERS);
}
return result;
}
Set<GreenhouseResult> checkBlock(CounterCheck cc, Roof roof, Walls walls, Block block) {
Set<GreenhouseResult> result = new HashSet<>();
World world = block.getWorld();
// Checking above greenhouse - no blocks allowed
if (block.getY() > roof.getHeight()) {
// We are above the greenhouse
if (!world.getEnvironment().equals(Environment.NETHER) && !block.isEmpty()) {
result.add(GreenhouseResult.FAIL_BLOCKS_ABOVE);
redGlass.add(block.getLocation());
}
} else {
// Check just the walls
checkWalls(block, roof, walls, cc);
}
return result;
}
/**
* Check a wall block
* @param block - block
* @param roof - roof object
* @param walls - wall object
* @param cc - count
* @return true if block was in the wall
*/
boolean checkWalls(Block block, Roof roof, Walls walls, CounterCheck cc) {
int x = block.getX();
int y = block.getY();
int z = block.getZ();
// Check wall blocks only
if (y == roof.getHeight() || x == walls.getMinX() || x == walls.getMaxX() || z == walls.getMinZ() || z== walls.getMaxZ()) {
// Check for non-wall blocks or non-roof blocks at the top of walls
if ((y != roof.getHeight() && !Walls.wallBlocks(block.getType())) || (y == roof.getHeight() && !Roof.roofBlocks(block.getType()))) {
if (block.isEmpty()) {
cc.airHole = true;
if (y == roof.getHeight()) {
inCeiling = true;
}
} else {
cc.otherBlock = true;
}
redGlass.add(block.getLocation());
} else {
// Normal wall blocks
wallBlockCount++;
checkDoorsHoppers(cc, block);
}
return true;
}
return false;
}
void checkDoorsHoppers(CounterCheck cc, Block block) {
// Count doors
if (Tag.DOORS.isTagged(block.getType())) {
cc.doorCount++;
// If we already have 8 doors add these blocks to the red list
if (wallDoors == 8) {
redGlass.add(block.getLocation());
}
}
// Count hoppers
if (block.getType().equals(Material.HOPPER)) {
cc.hopperCount++;
if (ghHopper > 0) {
// Problem! Add extra hoppers to the red glass list
redGlass.add(block.getLocation());
} else {
// This is the first hopper
gh.setRoofHopperLocation(block.getLocation());
}
}
}
/**
* @return the greenhouse
*/
@ -184,4 +223,102 @@ public class GreenhouseFinder {
return redGlass;
}
/**
* @return the wallDoors
*/
int getWallDoors() {
return wallDoors;
}
/**
* @param wallDoors the wallDoors to set
*/
void setWallDoors(int wallDoors) {
this.wallDoors = wallDoors;
}
/**
* @return the ghHopper
*/
int getGhHopper() {
return ghHopper;
}
/**
* @return the airHoles
*/
boolean isAirHoles() {
return airHoles;
}
/**
* @return the otherBlocks
*/
boolean isOtherBlocks() {
return otherBlocks;
}
/**
* @return the inCeiling
*/
boolean isInCeiling() {
return inCeiling;
}
/**
* @return the otherBlockLayer
*/
int getOtherBlockLayer() {
return otherBlockLayer;
}
/**
* @return the wallBlockCount
*/
int getWallBlockCount() {
return wallBlockCount;
}
/**
* @param ghHopper the ghHopper to set
*/
void setGhHopper(int ghHopper) {
this.ghHopper = ghHopper;
}
/**
* @param airHoles the airHoles to set
*/
void setAirHoles(boolean airHoles) {
this.airHoles = airHoles;
}
/**
* @param otherBlocks the otherBlocks to set
*/
void setOtherBlocks(boolean otherBlocks) {
this.otherBlocks = otherBlocks;
}
/**
* @param inCeiling the inCeiling to set
*/
void setInCeiling(boolean inCeiling) {
this.inCeiling = inCeiling;
}
/**
* @param otherBlockLayer the otherBlockLayer to set
*/
void setOtherBlockLayer(int otherBlockLayer) {
this.otherBlockLayer = otherBlockLayer;
}
/**
* @param wallBlockCount the wallBlockCount to set
*/
void setWallBlockCount(int wallBlockCount) {
this.wallBlockCount = wallBlockCount;
}
}

View File

@ -0,0 +1,375 @@
package world.bentobox.greenhouses.managers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
import java.util.Collection;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.data.Greenhouse;
import world.bentobox.greenhouses.greenhouse.Roof;
import world.bentobox.greenhouses.greenhouse.Walls;
import world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck;
import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
/**
* @author tastybento
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, User.class})
public class GreenhouseFinderTest {
private static final int ROOF_HEIGHT = 15;
@Mock
private Greenhouses addon;
@Mock
private World world;
@Mock
private Location location;
// Class under test
private GreenhouseFinder gf;
@Mock
private Block block;
private CounterCheck cc;
@Mock
private Roof roof;
@Mock
private Walls walls;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
// Location
when(location.getBlockX()).thenReturn(5);
when(location.getBlockY()).thenReturn(14);
when(location.getBlockZ()).thenReturn(25);
when(location.getWorld()).thenReturn(world);
// Block
when(block.getX()).thenReturn(5);
when(block.getY()).thenReturn(14);
when(block.getZ()).thenReturn(25);
when(block.getType()).thenReturn(Material.GLASS);
when(block.getLocation()).thenReturn(location);
when(block.getWorld()).thenReturn(world);
// Roof
when(roof.getHeight()).thenReturn(ROOF_HEIGHT);
when(walls.getMinX()).thenReturn(5);
when(walls.getMaxX()).thenReturn(25);
when(walls.getMinZ()).thenReturn(6);
when(walls.getMaxZ()).thenReturn(26);
when(walls.getFloor()).thenReturn(0);
when(roof.getLocation()).thenReturn(location);
// World
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
when(world.getMaxHeight()).thenReturn(30);
gf = new GreenhouseFinder();
cc = gf.new CounterCheck();
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkGreenhouse(world.bentobox.greenhouses.data.Greenhouse, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls)}.
*/
@Test
public void testCheckGreenhouse() {
Greenhouse gh2 = new Greenhouse(world, walls, ROOF_HEIGHT);
Set<GreenhouseResult> result = gf.checkGreenhouse(gh2, roof, walls);
assertTrue(result.isEmpty()); // Success
assertEquals(441, gf.getWallBlockCount());
assertEquals(0, gf.getWallDoors());
assertEquals(0, gf.getGhHopper());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkErrors(world.bentobox.greenhouses.greenhouse.Roof, int)}.
*/
@Test
public void testCheckErrors() {
Collection<GreenhouseResult> result = gf.checkErrors(roof, 0);
assertTrue(result.isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkErrors(world.bentobox.greenhouses.greenhouse.Roof, int)}.
*/
@Test
public void testCheckErrorsFailBelow() {
Collection<GreenhouseResult> result = gf.checkErrors(roof, ROOF_HEIGHT);
assertFalse(result.isEmpty());
result.forEach(gr -> assertEquals(GreenhouseResult.FAIL_BELOW, gr));
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkErrors(world.bentobox.greenhouses.greenhouse.Roof, int)}.
*/
@Test
public void testCheckErrorsFailAllErrors() {
gf.setGhHopper(2);
gf.setWallDoors(10);
gf.setAirHoles(true);
gf.setInCeiling(true);
gf.setOtherBlocks(true);
gf.setOtherBlockLayer(ROOF_HEIGHT + 1);
Collection<GreenhouseResult> result = gf.checkErrors(roof, ROOF_HEIGHT);
assertFalse(result.isEmpty());
assertTrue(result.contains(GreenhouseResult.FAIL_BELOW));
assertTrue(result.contains(GreenhouseResult.FAIL_TOO_MANY_HOPPERS));
assertTrue(result.contains(GreenhouseResult.FAIL_TOO_MANY_DOORS));
assertTrue(result.contains(GreenhouseResult.FAIL_UNEVEN_WALLS));
assertTrue(result.contains(GreenhouseResult.FAIL_HOLE_IN_ROOF));
assertEquals(5, result.size());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkErrors(world.bentobox.greenhouses.greenhouse.Roof, int)}.
*/
@Test
public void testCheckErrorsFailHoleInWall() {
gf.setGhHopper(2);
gf.setWallDoors(10);
gf.setAirHoles(true);
gf.setInCeiling(false);
gf.setOtherBlocks(true);
gf.setOtherBlockLayer(5);
Collection<GreenhouseResult> result = gf.checkErrors(roof, 0);
assertFalse(result.isEmpty());
assertTrue(result.contains(GreenhouseResult.FAIL_TOO_MANY_HOPPERS));
assertTrue(result.contains(GreenhouseResult.FAIL_TOO_MANY_DOORS));
assertTrue(result.contains(GreenhouseResult.FAIL_BAD_WALL_BLOCKS));
assertTrue(result.contains(GreenhouseResult.FAIL_HOLE_IN_WALL));
assertEquals(4, result.size());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkBlock(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, org.bukkit.block.Block)}.
*/
@Test
public void testCheckBlock() {
// Block has to be > roof height
when(block.getY()).thenReturn(ROOF_HEIGHT + 1);
Set<GreenhouseResult> result = gf.checkBlock(cc, roof, walls, block);
result.forEach(gr -> assertEquals(GreenhouseResult.FAIL_BLOCKS_ABOVE, gr));
gf.getRedGlass().forEach(l -> assertEquals(location, l));
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkBlock(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, org.bukkit.block.Block)}.
*/
@Test
public void testCheckBlockRoofHeight() {
// Block has to be > roof height
when(block.getY()).thenReturn(ROOF_HEIGHT);
Set<GreenhouseResult> result = gf.checkBlock(cc, roof, walls, block);
assertTrue(result.isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkBlock(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, org.bukkit.block.Block)}.
*/
@Test
public void testCheckBlockNether() {
when(world.getEnvironment()).thenReturn(Environment.NETHER);
// Block has to be > roof height
when(block.getY()).thenReturn(ROOF_HEIGHT + 1);
Set<GreenhouseResult> result = gf.checkBlock(cc, roof, walls, block);
assertTrue(result.isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkBlock(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, org.bukkit.block.Block)}.
*/
@Test
public void testCheckBlockAir() {
when(block.isEmpty()).thenReturn(true);
// Block has to be > roof height
when(block.getY()).thenReturn(ROOF_HEIGHT + 1);
Set<GreenhouseResult> result = gf.checkBlock(cc, roof, walls, block);
assertTrue(result.isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkWalls(org.bukkit.block.Block, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck)}.
*/
@Test
public void testCheckWallsAirHole() {
// Make block AIR
when(block.isEmpty()).thenReturn(true);
when(block.getType()).thenReturn(Material.AIR);
assertTrue(gf.checkWalls(block, roof, walls, cc));
assertFalse(gf.getRedGlass().isEmpty());
gf.getRedGlass().forEach(l -> assertEquals(location, l));
assertTrue(cc.airHole);
assertFalse(gf.isInCeiling());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkWalls(org.bukkit.block.Block, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck)}.
*/
@Test
public void testCheckWallsAirHoleInRoof() {
// Make block AIR
when(block.isEmpty()).thenReturn(true);
when(block.getType()).thenReturn(Material.AIR);
when(block.getY()).thenReturn(ROOF_HEIGHT);
assertTrue(gf.checkWalls(block, roof, walls, cc));
assertFalse(gf.getRedGlass().isEmpty());
gf.getRedGlass().stream().forEach(l -> assertEquals(location, l));
assertTrue(cc.airHole);
assertTrue(gf.isInCeiling());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkWalls(org.bukkit.block.Block, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck)}.
*/
@Test
public void testCheckWalls() {
// Make block GLASS
when(block.isEmpty()).thenReturn(false);
when(block.getType()).thenReturn(Material.GLASS);
assertTrue(gf.checkWalls(block, roof, walls, cc));
assertTrue(gf.getRedGlass().isEmpty());
assertFalse(cc.airHole);
assertFalse(gf.isInCeiling());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkWalls(org.bukkit.block.Block, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck)}.
*/
@Test
public void testCheckWallsInRoof() {
// Make block GLASS
when(block.isEmpty()).thenReturn(false);
when(block.getType()).thenReturn(Material.GLASS);
when(block.getY()).thenReturn(ROOF_HEIGHT);
assertTrue(gf.checkWalls(block, roof, walls, cc));
assertTrue(gf.getRedGlass().isEmpty());
assertFalse(cc.airHole);
assertFalse(gf.isInCeiling());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkWalls(org.bukkit.block.Block, world.bentobox.greenhouses.greenhouse.Roof, world.bentobox.greenhouses.greenhouse.Walls, world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck)}.
*/
@Test
public void testCheckWallsNotInWall() {
when(block.getX()).thenReturn(0);
when(block.getY()).thenReturn(0);
when(block.getZ()).thenReturn(0);
// Make block GLASS
when(block.isEmpty()).thenReturn(false);
when(block.getType()).thenReturn(Material.GLASS);
assertFalse(gf.checkWalls(block, roof, walls, cc));
assertTrue(gf.getRedGlass().isEmpty());
assertFalse(cc.airHole);
assertFalse(gf.isInCeiling());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkDoorsHoppers(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, org.bukkit.block.Block)}.
*/
@Test
public void testCheckDoorsHoppers() {
when(Tag.DOORS.isTagged(any(Material.class))).thenReturn(true);
when(block.getType()).thenReturn(Material.ACACIA_DOOR);
gf.checkDoorsHoppers(cc, block);
assertTrue(gf.getRedGlass().isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkDoorsHoppers(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, org.bukkit.block.Block)}.
*/
@Test
public void testCheckDoorsHoppersTooManyDoors() {
gf.setWallDoors(8);
when(Tag.DOORS.isTagged(any(Material.class))).thenReturn(true);
when(block.getType()).thenReturn(Material.ACACIA_DOOR);
CounterCheck cc = gf.new CounterCheck();
gf.checkDoorsHoppers(cc, block);
assertFalse(gf.getRedGlass().isEmpty());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkDoorsHoppers(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, org.bukkit.block.Block)}.
*/
@Test
public void testCheckDoorsHoppersHopper() {
when(Tag.DOORS.isTagged(any(Material.class))).thenReturn(false);
when(block.getType()).thenReturn(Material.HOPPER);
when(block.getLocation()).thenReturn(location);
CounterCheck cc = gf.new CounterCheck();
gf.checkDoorsHoppers(cc, block);
assertTrue(gf.getRedGlass().isEmpty());
assertEquals(location, gf.getGh().getRoofHopperLocation());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#checkDoorsHoppers(world.bentobox.greenhouses.managers.GreenhouseFinder.CounterCheck, org.bukkit.block.Block)}.
*/
@Test
public void testCheckDoorsHoppersTooManyHoppers() {
gf.setGhHopper(3);
when(Tag.DOORS.isTagged(any(Material.class))).thenReturn(false);
when(block.getType()).thenReturn(Material.HOPPER);
when(block.getLocation()).thenReturn(location);
CounterCheck cc = gf.new CounterCheck();
gf.checkDoorsHoppers(cc, block);
assertFalse(gf.getRedGlass().isEmpty());
assertNull(gf.getGh().getRoofHopperLocation());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#getGh()}.
*/
@Test
public void testGetGh() {
assertNotNull(gf.getGh());
}
/**
* Test method for {@link world.bentobox.greenhouses.managers.GreenhouseFinder#getRedGlass()}.
*/
@Test
public void testGetRedGlass() {
assertTrue(gf.getRedGlass().isEmpty());
}
}