From 8a7e9e100366dcf3d8deb12d409c3247a68cc6ec Mon Sep 17 00:00:00 2001 From: Rosskaman <32296125+Rosskaman@users.noreply.github.com> Date: Wed, 21 Apr 2021 23:26:31 +0200 Subject: [PATCH] Fix BiomeRecipe tests. Added a test for ConvertBlock with localBlock == null, Removed unnecessary test for trying to convert a block outside of a greenhouse, Fixed @Links for addPlants having wrong parameters --- .../greenhouse/BiomeRecipeTest.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java b/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java index b58304c..e9b0fbe 100644 --- a/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java +++ b/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java @@ -156,7 +156,7 @@ public class BiomeRecipeTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}. */ @Test public void testAddMobs() { @@ -168,7 +168,7 @@ public class BiomeRecipeTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}. */ @Test public void testAddMobsOver100Percent() { @@ -182,7 +182,7 @@ public class BiomeRecipeTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, int, org.bukkit.Material)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addMobs(org.bukkit.entity.EntityType, double, org.bukkit.Material)}. */ @Test public void testAddMobsOver100PercentDouble() { @@ -195,7 +195,7 @@ public class BiomeRecipeTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, int, org.bukkit.Material)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}. */ @Test public void testAddPlants() { @@ -207,7 +207,7 @@ public class BiomeRecipeTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, int, org.bukkit.Material)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#addPlants(org.bukkit.Material, double, org.bukkit.Material)}. */ @Test public void testAddPlantsOver100Percent() { @@ -267,25 +267,6 @@ public class BiomeRecipeTest { verify(b).setType(Material.CLAY); } - /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}. - */ - @Test - public void testConvertBlockNotInGreenhouse() { - // 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); - when(ab.getLocation()).thenReturn(location); - when(gh.contains(any())).thenReturn(false); - br.convertBlock(b); - verify(b, never()).setType(any()); - } - /** * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}. */ @@ -315,6 +296,26 @@ public class BiomeRecipeTest { verify(b, never()).setType(Material.CLAY); } + /** + * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}. + */ + @Test + public void testConvertBlockNoLocalBlock() { + // Setup + Material oldMaterial = Material.SAND; + Material newMaterial = Material.CLAY; + double convChance = 100D; + br.addConvBlocks(oldMaterial, newMaterial, convChance, null); + + // Mock + Block b = mock(Block.class); + when(b.getType()).thenReturn(Material.SAND); + br.convertBlock(b); + + verify(b, never()).getRelative(any()); + verify(b).setType(Material.CLAY); + } + /** * Test method for {@link world.bentobox.greenhouses.greenhouse.BiomeRecipe#convertBlock(org.bukkit.block.Block)}. */