2019-10-12 03:52:32 +02:00
|
|
|
package world.bentobox.greenhouses.greenhouse;
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
import static org.junit.Assert.assertEquals;
|
2019-10-12 03:52:32 +02:00
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
2019-10-13 02:09:38 +02:00
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
|
import static org.mockito.ArgumentMatchers.anyDouble;
|
2019-10-12 03:52:32 +02:00
|
|
|
import static org.mockito.ArgumentMatchers.anyInt;
|
2019-10-13 02:09:38 +02:00
|
|
|
import static org.mockito.ArgumentMatchers.eq;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
import static org.mockito.Mockito.never;
|
|
|
|
import static org.mockito.Mockito.verify;
|
2019-10-12 03:52:32 +02:00
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
2019-10-18 07:37:27 +02:00
|
|
|
import java.util.Optional;
|
2019-10-12 03:52:32 +02:00
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
2019-10-13 02:09:38 +02:00
|
|
|
import org.bukkit.Location;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.bukkit.Material;
|
2019-10-13 02:09:38 +02:00
|
|
|
import org.bukkit.Particle;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.bukkit.World;
|
2020-11-16 00:54:06 +01:00
|
|
|
import org.bukkit.World.Environment;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.bukkit.block.Biome;
|
|
|
|
import org.bukkit.block.Block;
|
2019-10-13 02:09:38 +02:00
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.block.data.Bisected;
|
|
|
|
import org.bukkit.block.data.Bisected.Half;
|
|
|
|
import org.bukkit.block.data.BlockData;
|
|
|
|
import org.bukkit.entity.Cat;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.EntityType;
|
2020-11-16 00:54:06 +01:00
|
|
|
import org.bukkit.entity.Hoglin;
|
|
|
|
import org.bukkit.entity.Piglin;
|
2019-10-18 07:37:27 +02:00
|
|
|
import org.bukkit.scheduler.BukkitScheduler;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.bukkit.util.BoundingBox;
|
2019-10-18 07:37:27 +02:00
|
|
|
import org.bukkit.util.Vector;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.mockito.Mock;
|
2019-10-13 02:09:38 +02:00
|
|
|
import org.powermock.api.mockito.PowerMockito;
|
2019-10-12 03:52:32 +02:00
|
|
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
|
|
import org.powermock.modules.junit4.PowerMockRunner;
|
|
|
|
|
|
|
|
import world.bentobox.bentobox.BentoBox;
|
|
|
|
import world.bentobox.greenhouses.Greenhouses;
|
2020-01-30 18:52:53 +01:00
|
|
|
import world.bentobox.greenhouses.Settings;
|
2019-10-12 03:52:32 +02:00
|
|
|
import world.bentobox.greenhouses.data.Greenhouse;
|
2019-10-18 07:37:27 +02:00
|
|
|
import world.bentobox.greenhouses.managers.GreenhouseManager;
|
|
|
|
import world.bentobox.greenhouses.managers.GreenhouseMap;
|
2019-10-12 03:52:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author tastybento
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@RunWith(PowerMockRunner.class)
|
|
|
|
@PrepareForTest({Bukkit.class, BentoBox.class})
|
|
|
|
public class BiomeRecipeTest {
|
2019-10-12 18:31:51 +02:00
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
private BiomeRecipe br;
|
|
|
|
@Mock
|
|
|
|
private Greenhouses addon;
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
private Greenhouse gh;
|
|
|
|
|
|
|
|
private BoundingBox bb;
|
|
|
|
@Mock
|
|
|
|
private World world;
|
|
|
|
@Mock
|
|
|
|
private Block block;
|
2019-10-13 02:09:38 +02:00
|
|
|
@Mock
|
|
|
|
private Location location;
|
|
|
|
@Mock
|
|
|
|
private BlockData bd;
|
2019-10-18 07:37:27 +02:00
|
|
|
@Mock
|
|
|
|
private BentoBox plugin;
|
|
|
|
@Mock
|
|
|
|
private GreenhouseManager mgr;
|
|
|
|
@Mock
|
|
|
|
private GreenhouseMap map;
|
|
|
|
@Mock
|
|
|
|
private BukkitScheduler scheduler;
|
2020-01-30 18:52:53 +01:00
|
|
|
@Mock
|
|
|
|
private Settings settings;
|
2019-10-12 03:52:32 +02:00
|
|
|
|
2021-08-01 08:10:07 +02:00
|
|
|
@Before
|
|
|
|
public void setUp() {
|
2019-10-13 02:09:38 +02:00
|
|
|
PowerMockito.mockStatic(Bukkit.class);
|
|
|
|
when(Bukkit.createBlockData(any(Material.class))).thenReturn(bd);
|
2021-08-01 08:10:07 +02:00
|
|
|
Biome type = Biome.BADLANDS;
|
2019-10-12 03:52:32 +02:00
|
|
|
// Greenhouse
|
|
|
|
when(gh.getArea()).thenReturn(100);
|
|
|
|
when(gh.getFloorHeight()).thenReturn(100);
|
|
|
|
when(gh.getCeilingHeight()).thenReturn(120);
|
|
|
|
bb = new BoundingBox(10, 100, 10, 20, 120, 20);
|
2019-10-12 18:31:51 +02:00
|
|
|
when(gh.getBoundingBox()).thenReturn(bb);
|
2019-10-12 03:52:32 +02:00
|
|
|
when(gh.getWorld()).thenReturn(world);
|
2020-11-15 23:38:19 +01:00
|
|
|
when(gh.contains(any())).thenReturn(true);
|
2019-10-12 03:52:32 +02:00
|
|
|
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
|
2019-10-13 02:09:38 +02:00
|
|
|
// Block
|
2019-10-12 03:52:32 +02:00
|
|
|
when(block.getType()).thenReturn(Material.AIR,
|
|
|
|
Material.GRASS_BLOCK, Material.GRASS_BLOCK,
|
|
|
|
Material.WATER,
|
|
|
|
Material.BLUE_ICE, Material.PACKED_ICE, Material.ICE,
|
|
|
|
Material.LAVA,
|
|
|
|
Material.AIR);
|
2019-10-13 02:09:38 +02:00
|
|
|
when(block.getWorld()).thenReturn(world);
|
|
|
|
when(block.getLocation()).thenReturn(location);
|
2019-10-18 07:37:27 +02:00
|
|
|
when(location.clone()).thenReturn(location);
|
|
|
|
when(location.add(any(Vector.class))).thenReturn(location);
|
2020-08-23 00:22:14 +02:00
|
|
|
|
2019-10-18 07:37:27 +02:00
|
|
|
// Plugin
|
|
|
|
when(addon.getPlugin()).thenReturn(plugin);
|
|
|
|
// Manager
|
|
|
|
when(addon.getManager()).thenReturn(mgr);
|
|
|
|
// GH Map
|
|
|
|
when(mgr.getMap()).thenReturn(map);
|
|
|
|
Optional<Greenhouse> optionalGh = Optional.of(gh);
|
|
|
|
when(map.getGreenhouse(any(Location.class))).thenReturn(optionalGh);
|
|
|
|
// Bukkit Scheduler
|
|
|
|
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
2020-01-30 18:52:53 +01:00
|
|
|
// Settings
|
|
|
|
when(addon.getSettings()).thenReturn(settings);
|
|
|
|
when(settings.isStartupLog()).thenReturn(true);
|
2020-11-16 00:54:06 +01:00
|
|
|
// World
|
|
|
|
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
2020-08-23 00:22:14 +02:00
|
|
|
|
2020-01-30 18:52:53 +01:00
|
|
|
// Set up default recipe
|
|
|
|
br = new BiomeRecipe(addon, type, 0);
|
|
|
|
br.setIcecoverage(2); // 1%
|
|
|
|
br.setLavacoverage(1); // 1%
|
|
|
|
br.setWatercoverage(1); // 1%
|
|
|
|
br.addReqBlocks(Material.GRASS_BLOCK, 2);
|
|
|
|
br.setFriendlyName("name");
|
|
|
|
br.setName("name2");
|
|
|
|
br.setIcon(Material.ACACIA_BOAT);
|
|
|
|
br.setPermission("perm");
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addConvBlocks(org.bukkit.Material, org.bukkit.Material, double, org.bukkit.Material)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddConvBlocks() {
|
2019-10-13 02:09:38 +02:00
|
|
|
Material oldMaterial = Material.SAND;
|
|
|
|
Material newMaterial = Material.CLAY;
|
|
|
|
double convChance = 100D;
|
|
|
|
Material localMaterial = Material.WATER;
|
|
|
|
br.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
|
|
|
verify(addon).log(eq(" 100.0% chance for Sand to convert to Clay"));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-09 20:47:54 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddMobs() {
|
2019-10-13 02:09:38 +02:00
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 50;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
2020-11-16 00:35:59 +01:00
|
|
|
verify(addon).log(eq(" 50.0% chance for Cat to spawn on Grass Path."));
|
2019-10-13 02:09:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-09 20:47:54 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
2019-10-13 02:09:38 +02:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddMobsOver100Percent() {
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 50;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
verify(addon).logError(eq("Mob chances add up to > 100% in BADLANDS biome recipe! Skipping CAT"));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
2020-11-16 00:35:59 +01:00
|
|
|
/**
|
2021-05-09 20:47:54 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}.
|
2020-11-16 00:35:59 +01:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddMobsOver100PercentDouble() {
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
double mobProbability = 50.5;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
verify(addon).logError(eq("Mob chances add up to > 100% in BADLANDS biome recipe! Skipping CAT"));
|
|
|
|
}
|
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
/**
|
2021-05-09 20:47:54 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddPlants() {
|
2019-10-13 02:09:38 +02:00
|
|
|
Material plantMaterial = Material.JUNGLE_SAPLING;
|
|
|
|
int plantProbability = 20;
|
|
|
|
Material plantGrowOn = Material.DIRT;
|
|
|
|
br.addPlants(plantMaterial, plantProbability, plantGrowOn);
|
2020-11-16 00:35:59 +01:00
|
|
|
verify(addon).log(eq(" 20.0% chance for Jungle Sapling to grow on Dirt"));
|
2019-10-13 02:09:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-09 20:47:54 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}.
|
2019-10-13 02:09:38 +02:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddPlantsOver100Percent() {
|
|
|
|
Material plantMaterial = Material.JUNGLE_SAPLING;
|
|
|
|
int plantProbability = 60;
|
|
|
|
Material plantGrowOn = Material.DIRT;
|
|
|
|
br.addPlants(plantMaterial, plantProbability, plantGrowOn);
|
|
|
|
br.addPlants(plantMaterial, plantProbability, plantGrowOn);
|
|
|
|
verify(addon).logError(eq("Plant chances add up to > 100% in BADLANDS biome recipe! Skipping JUNGLE_SAPLING"));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addReqBlocks(org.bukkit.Material, int)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testAddReqBlocks() {
|
2019-10-13 02:09:38 +02:00
|
|
|
Material blockMaterial = Material.BLACK_CONCRETE;
|
|
|
|
int blockQty = 30;
|
|
|
|
br.addReqBlocks(blockMaterial, blockQty);
|
|
|
|
verify(addon).log(eq(" BLACK_CONCRETE x 30"));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#checkRecipe(world.bentobox.greenhouses.data.Greenhouse)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testCheckRecipe() {
|
2021-01-17 17:41:50 +01:00
|
|
|
br.checkRecipe(gh).thenAccept(result ->
|
|
|
|
assertTrue(result.isEmpty()));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
2019-10-12 18:31:51 +02:00
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#checkRecipe(world.bentobox.greenhouses.data.Greenhouse)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testCheckRecipeNotEnough() {
|
|
|
|
br.addReqBlocks(Material.ACACIA_LEAVES, 3);
|
2021-01-17 17:41:50 +01:00
|
|
|
br.checkRecipe(gh).thenAccept(result ->
|
|
|
|
assertFalse(result.isEmpty()));
|
2019-10-12 18:31:51 +02:00
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testConvertBlock() {
|
2019-10-13 02:09:38 +02:00
|
|
|
// Setup
|
|
|
|
this.testAddConvBlocks();
|
|
|
|
// Mock
|
|
|
|
Block b = mock(Block.class);
|
|
|
|
when(b.getType()).thenReturn(Material.SAND);
|
|
|
|
Block ab = mock(Block.class);
|
|
|
|
when(ab.getType()).thenReturn(Material.WATER);
|
|
|
|
when(b.getRelative(any())).thenReturn(ab);
|
2021-04-19 16:26:43 +02:00
|
|
|
br.convertBlock(b);
|
2019-10-13 02:09:38 +02:00
|
|
|
verify(b).setType(Material.CLAY);
|
|
|
|
}
|
|
|
|
|
2020-11-15 23:38:19 +01:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
2021-05-09 20:47:54 +02:00
|
|
|
public void testConvertBlockNoWater() {
|
2020-11-15 23:38:19 +01:00
|
|
|
// Setup
|
|
|
|
this.testAddConvBlocks();
|
|
|
|
// Mock
|
|
|
|
Block b = mock(Block.class);
|
|
|
|
when(b.getType()).thenReturn(Material.SAND);
|
|
|
|
Block ab = mock(Block.class);
|
2021-05-09 20:47:54 +02:00
|
|
|
when(ab.getType()).thenReturn(Material.SAND);
|
2020-11-15 23:38:19 +01:00
|
|
|
when(b.getRelative(any())).thenReturn(ab);
|
2021-04-19 16:26:43 +02:00
|
|
|
br.convertBlock(b);
|
2021-05-09 20:47:54 +02:00
|
|
|
verify(b, never()).setType(Material.CLAY);
|
2020-11-15 23:38:19 +01:00
|
|
|
}
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
2021-05-09 20:47:54 +02:00
|
|
|
public void testConvertBlockNoConverts() {
|
2019-10-13 02:09:38 +02:00
|
|
|
// Mock
|
|
|
|
Block b = mock(Block.class);
|
|
|
|
when(b.getType()).thenReturn(Material.SAND);
|
2021-04-19 16:26:43 +02:00
|
|
|
br.convertBlock(b);
|
2019-10-13 02:09:38 +02:00
|
|
|
verify(b, never()).setType(Material.CLAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
2021-05-09 20:47:54 +02:00
|
|
|
public void testConvertBlockNoLocalBlock() {
|
|
|
|
// Setup
|
|
|
|
Material oldMaterial = Material.SAND;
|
|
|
|
Material newMaterial = Material.CLAY;
|
|
|
|
double convChance = 100D;
|
|
|
|
br.addConvBlocks(oldMaterial, newMaterial, convChance, null);
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
// Mock
|
|
|
|
Block b = mock(Block.class);
|
|
|
|
when(b.getType()).thenReturn(Material.SAND);
|
2021-04-19 16:26:43 +02:00
|
|
|
br.convertBlock(b);
|
2021-05-09 20:47:54 +02:00
|
|
|
|
|
|
|
verify(b, never()).getRelative(any());
|
|
|
|
verify(b).setType(Material.CLAY);
|
2019-10-13 02:09:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testConvertBlockNoProbability() {
|
|
|
|
// Setup
|
|
|
|
Material oldMaterial = Material.SAND;
|
|
|
|
Material newMaterial = Material.CLAY;
|
|
|
|
double convChance = 0D;
|
|
|
|
Material localMaterial = Material.WATER;
|
|
|
|
br.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
|
|
|
|
|
|
|
// Mock
|
|
|
|
Block b = mock(Block.class);
|
|
|
|
when(b.getType()).thenReturn(Material.SAND);
|
|
|
|
Block ab = mock(Block.class);
|
|
|
|
when(ab.getType()).thenReturn(Material.WATER);
|
|
|
|
when(b.getRelative(any())).thenReturn(ab);
|
2021-04-19 16:26:43 +02:00
|
|
|
br.convertBlock(b);
|
2019-10-13 02:09:38 +02:00
|
|
|
verify(b, never()).setType(Material.CLAY);
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getBiome()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetBiome() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(Biome.BADLANDS, br.getBiome());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getBlockConvert()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetBlockConvert() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertFalse(br.getBlockConvert());
|
|
|
|
this.testAddConvBlocks();
|
|
|
|
assertTrue(br.getBlockConvert());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getFriendlyName()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetFriendlyName() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals("name", br.getFriendlyName());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getIceCoverage()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetIceCoverage() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(2, br.getIceCoverage());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getIcon()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetIcon() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(Material.ACACIA_BOAT, br.getIcon());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getLavaCoverage()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetLavaCoverage() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(1, br.getLavaCoverage());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getMobLimit()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetMobLimit() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(9, br.getMobLimit());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getName()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetName() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals("name2", br.getName());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getPermission()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetPermission() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals("perm", br.getPermission());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobyZero() {
|
|
|
|
when(block.getY()).thenReturn(0);
|
|
|
|
assertFalse(br.spawnMob(block));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnNoMobs() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
assertFalse(br.spawnMob(block));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-18 07:37:27 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobOutsideWall() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Entity cat = mock(Cat.class);
|
|
|
|
// Same box as greenhouse
|
|
|
|
when(cat.getBoundingBox()).thenReturn(bb);
|
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(cat);
|
2020-11-16 00:54:06 +01:00
|
|
|
when(cat.getWorld()).thenReturn(world);
|
2019-10-18 07:37:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertFalse(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.CAT));
|
|
|
|
verify(location).add(any(Vector.class));
|
|
|
|
}
|
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMob() {
|
2019-10-13 02:09:38 +02:00
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Entity cat = mock(Cat.class);
|
2019-10-18 07:37:27 +02:00
|
|
|
// Exactly 1 block smaller than the greenhouse blocks
|
|
|
|
BoundingBox small = new BoundingBox(11, 101, 11, 19, 119, 19);
|
|
|
|
when(cat.getBoundingBox()).thenReturn(small);
|
2019-10-13 02:09:38 +02:00
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(cat);
|
2020-11-16 00:54:06 +01:00
|
|
|
when(cat.getWorld()).thenReturn(world);
|
2019-10-13 02:09:38 +02:00
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertTrue(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.CAT));
|
2019-10-18 07:37:27 +02:00
|
|
|
verify(location).add(any(Vector.class));
|
2019-10-13 02:09:38 +02:00
|
|
|
}
|
|
|
|
|
2020-11-16 00:54:06 +01:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobHoglin() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.HOGLIN;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Hoglin hoglin = mock(Hoglin.class);
|
|
|
|
// Exactly 1 block smaller than the greenhouse blocks
|
|
|
|
BoundingBox small = new BoundingBox(11, 101, 11, 19, 119, 19);
|
|
|
|
when(hoglin.getBoundingBox()).thenReturn(small);
|
|
|
|
when(hoglin.getWorld()).thenReturn(world);
|
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(hoglin);
|
|
|
|
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertTrue(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.HOGLIN));
|
|
|
|
verify(location).add(any(Vector.class));
|
|
|
|
verify(hoglin).setImmuneToZombification(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobPiglin() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.PIGLIN;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Piglin piglin = mock(Piglin.class);
|
|
|
|
// Exactly 1 block smaller than the greenhouse blocks
|
|
|
|
BoundingBox small = new BoundingBox(11, 101, 11, 19, 119, 19);
|
|
|
|
when(piglin.getBoundingBox()).thenReturn(small);
|
|
|
|
when(piglin.getWorld()).thenReturn(world);
|
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(piglin);
|
|
|
|
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertTrue(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.PIGLIN));
|
|
|
|
verify(location).add(any(Vector.class));
|
|
|
|
verify(piglin).setImmuneToZombification(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobPiglinNether() {
|
|
|
|
when(world.getEnvironment()).thenReturn(Environment.NETHER);
|
|
|
|
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.PIGLIN;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Piglin piglin = mock(Piglin.class);
|
|
|
|
// Exactly 1 block smaller than the greenhouse blocks
|
|
|
|
BoundingBox small = new BoundingBox(11, 101, 11, 19, 119, 19);
|
|
|
|
when(piglin.getBoundingBox()).thenReturn(small);
|
|
|
|
when(piglin.getWorld()).thenReturn(world);
|
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(piglin);
|
|
|
|
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertTrue(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.PIGLIN));
|
|
|
|
verify(location).add(any(Vector.class));
|
|
|
|
verify(piglin, never()).setImmuneToZombification(true);
|
|
|
|
}
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobWrongSurface() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_BLOCK);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
Entity cat = mock(Cat.class);
|
|
|
|
when(world.spawnEntity(any(), any())).thenReturn(cat);
|
|
|
|
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertFalse(br.spawnMob(block));
|
|
|
|
verify(world, never()).spawnEntity(eq(location), eq(EntityType.CAT));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#spawnMob(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSpawnMobFailToSpawn() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.GRASS_PATH);
|
|
|
|
when(block.getRelative(any())).thenReturn(block);
|
|
|
|
|
|
|
|
EntityType mobType = EntityType.CAT;
|
|
|
|
int mobProbability = 100;
|
|
|
|
Material mobSpawnOn = Material.GRASS_PATH;
|
|
|
|
|
|
|
|
br.addMobs(mobType, mobProbability, mobSpawnOn);
|
|
|
|
assertFalse(br.spawnMob(block));
|
|
|
|
verify(world).spawnEntity(eq(location), eq(EntityType.CAT));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
|
2019-10-12 03:52:32 +02:00
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getRecipeBlocks()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetRecipeBlocks() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(1, br.getRecipeBlocks().size());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getWaterCoverage()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetWaterCoverage() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(1, br.getWaterCoverage());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantNotAir() {
|
|
|
|
when(block.getType()).thenReturn(Material.SOUL_SAND);
|
|
|
|
assertFalse(br.growPlant(block));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantNoPlants() {
|
|
|
|
when(block.getType()).thenReturn(Material.AIR);
|
2020-08-23 00:22:14 +02:00
|
|
|
when(block.isEmpty()).thenReturn(true);
|
2019-10-13 02:09:38 +02:00
|
|
|
assertFalse(br.growPlant(block));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantPlantsYZero() {
|
|
|
|
when(block.getY()).thenReturn(0);
|
|
|
|
when(block.getType()).thenReturn(Material.AIR);
|
2020-08-23 00:22:14 +02:00
|
|
|
when(block.isEmpty()).thenReturn(true);
|
2019-10-13 02:09:38 +02:00
|
|
|
assertTrue(br.addPlants(Material.BAMBOO_SAPLING, 100, Material.GRASS_BLOCK));
|
|
|
|
assertFalse(br.growPlant(block));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantPlants() {
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.AIR);
|
2020-08-23 00:22:14 +02:00
|
|
|
when(block.isEmpty()).thenReturn(true);
|
2019-10-13 02:09:38 +02:00
|
|
|
Block ob = mock(Block.class);
|
|
|
|
when(ob.getType()).thenReturn(Material.GRASS_BLOCK);
|
2020-08-23 00:22:14 +02:00
|
|
|
|
2019-10-13 02:09:38 +02:00
|
|
|
when(block.getRelative(any())).thenReturn(ob);
|
|
|
|
assertTrue(br.addPlants(Material.BAMBOO_SAPLING, 100, Material.GRASS_BLOCK));
|
|
|
|
assertTrue(br.growPlant(block));
|
|
|
|
verify(world).spawnParticle(eq(Particle.SNOWBALL), any(Location.class), anyInt(), anyDouble(), anyDouble(), anyDouble());
|
|
|
|
verify(block).setBlockData(eq(bd), eq(false));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantPlantsDoublePlant() {
|
|
|
|
Bisected bisected = mock(Bisected.class);
|
|
|
|
when(Bukkit.createBlockData(any(Material.class))).thenReturn(bisected);
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.AIR);
|
2020-08-23 00:22:14 +02:00
|
|
|
when(block.isEmpty()).thenReturn(true);
|
2019-10-13 02:09:38 +02:00
|
|
|
Block ob = mock(Block.class);
|
|
|
|
when(ob.getType()).thenReturn(Material.GRASS_BLOCK);
|
|
|
|
when(block.getRelative(eq(BlockFace.DOWN))).thenReturn(ob);
|
|
|
|
when(block.getRelative(eq(BlockFace.UP))).thenReturn(block);
|
|
|
|
assertTrue(br.addPlants(Material.SUNFLOWER, 100, Material.GRASS_BLOCK));
|
|
|
|
assertTrue(br.growPlant(block));
|
|
|
|
verify(world).spawnParticle(eq(Particle.SNOWBALL), any(Location.class), anyInt(), anyDouble(), anyDouble(), anyDouble());
|
|
|
|
verify(bisected).setHalf(eq(Half.BOTTOM));
|
|
|
|
verify(bisected).setHalf(eq(Half.TOP));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#growPlant(org.bukkit.block.Block)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testGrowPlantPlantsDoublePlantNoRoom() {
|
|
|
|
Bisected bisected = mock(Bisected.class);
|
|
|
|
when(Bukkit.createBlockData(any(Material.class))).thenReturn(bisected);
|
|
|
|
when(block.getY()).thenReturn(10);
|
|
|
|
when(block.getType()).thenReturn(Material.AIR);
|
2020-08-23 00:22:14 +02:00
|
|
|
when(block.isEmpty()).thenReturn(true);
|
2019-10-13 02:09:38 +02:00
|
|
|
Block ob = mock(Block.class);
|
|
|
|
when(ob.getType()).thenReturn(Material.GRASS_BLOCK);
|
|
|
|
when(block.getRelative(eq(BlockFace.DOWN))).thenReturn(ob);
|
|
|
|
when(block.getRelative(eq(BlockFace.UP))).thenReturn(ob);
|
|
|
|
assertTrue(br.addPlants(Material.SUNFLOWER, 100, Material.GRASS_BLOCK));
|
|
|
|
assertFalse(br.growPlant(block));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setIcecoverage(int)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testSetIcecoverage() {
|
|
|
|
verify(addon).log(" Ice > 2%");
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setLavacoverage(int)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testSetLavacoverage() {
|
|
|
|
verify(addon).log(" Lava > 1%");
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-13 02:09:38 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setMobLimit(int)}.
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2019-10-13 02:09:38 +02:00
|
|
|
public void testSetMobLimit() {
|
|
|
|
br.setMobLimit(0);
|
|
|
|
assertEquals(0, br.getMobLimit());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setPriority(int)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSetPriority() {
|
2019-10-13 02:09:38 +02:00
|
|
|
br.setPriority(20);
|
|
|
|
assertEquals(20, br.getPriority());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setType(org.bukkit.block.Biome)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSetType() {
|
2019-10-13 02:09:38 +02:00
|
|
|
br.setType(Biome.BADLANDS_PLATEAU);
|
|
|
|
assertEquals(Biome.BADLANDS_PLATEAU, br.getBiome());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-12 18:31:51 +02:00
|
|
|
*
|
2019-10-12 03:52:32 +02:00
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#setWatercoverage(int)}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testSetWatercoverage() {
|
2019-10-13 02:09:38 +02:00
|
|
|
verify(addon).log(" Water > 1%");
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#compareTo(world.bentobox.greenhouses.greenhouse.BiomeRecipe)}.
|
2019-10-13 02:09:38 +02:00
|
|
|
* Only priorty is compared
|
2019-10-12 03:52:32 +02:00
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testCompareTo() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertEquals(0, br.compareTo(br));
|
|
|
|
BiomeRecipe a = new BiomeRecipe();
|
|
|
|
a.setPriority(20);
|
|
|
|
assertEquals(1, br.compareTo(a));
|
|
|
|
assertEquals(-1, a.compareTo(br));
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#noMobs()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testNoMobs() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertTrue(br.noMobs());
|
|
|
|
this.testAddMobs();
|
|
|
|
assertFalse(br.noMobs());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#getMobTypes()}.
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testGetMobTypes() {
|
2019-10-13 02:09:38 +02:00
|
|
|
assertTrue(br.getMobTypes().isEmpty());
|
|
|
|
this.testAddMobs();
|
|
|
|
assertFalse(br.getMobTypes().isEmpty());
|
2019-10-12 03:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|