Clean up on the test classes for 1.13.

This commit is contained in:
tastybento 2018-08-01 10:12:43 -07:00
parent 733fc3d1c9
commit df5d63acf0
4 changed files with 28 additions and 43 deletions

View File

@ -29,7 +29,6 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -112,7 +111,7 @@ public class EndermanListenerTest {
enderman = mock(Enderman.class); enderman = mock(Enderman.class);
when(enderman.getLocation()).thenReturn(location); when(enderman.getLocation()).thenReturn(location);
when(enderman.getWorld()).thenReturn(world); when(enderman.getWorld()).thenReturn(world);
when(enderman.getCarriedMaterial()).thenReturn(new MaterialData(Material.STONE)); when(enderman.getCarriedBlock()).thenReturn(Material.STONE.createBlockData());
slime = mock(Slime.class); slime = mock(Slime.class);
when(slime.getLocation()).thenReturn(location); when(slime.getLocation()).thenReturn(location);
@ -215,7 +214,7 @@ public class EndermanListenerTest {
*/ */
@Test @Test
public void testOnEndermanDeathCarryAir() { public void testOnEndermanDeathCarryAir() {
when(enderman.getCarriedMaterial()).thenReturn(new MaterialData(Material.AIR)); when(enderman.getCarriedBlock()).thenReturn(Material.AIR.createBlockData());
EndermanListener listener = new EndermanListener(); EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>()); EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>());
listener.onEndermanDeath(e); listener.onEndermanDeath(e);

View File

@ -180,7 +180,6 @@ public class InvincibleVisitorsListenerTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageNotPlayer() { public void testOnVisitorGetDamageNotPlayer() {
LivingEntity le = mock(LivingEntity.class); LivingEntity le = mock(LivingEntity.class);
@ -189,7 +188,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageNotInWorld() { public void testOnVisitorGetDamageNotInWorld() {
when(iwm.inWorld(Mockito.any())).thenReturn(false); when(iwm.inWorld(Mockito.any())).thenReturn(false);
@ -198,7 +196,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageNotInIvSettings() { public void testOnVisitorGetDamageNotInIvSettings() {
when(iwm.inWorld(Mockito.any())).thenReturn(false); when(iwm.inWorld(Mockito.any())).thenReturn(false);
@ -207,7 +204,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageNotVisitor() { public void testOnVisitorGetDamageNotVisitor() {
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D); EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
@ -216,7 +212,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageNotVoid() { public void testOnVisitorGetDamageNotVoid() {
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D); EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
@ -225,7 +220,6 @@ public class InvincibleVisitorsListenerTest {
Mockito.verify(player, Mockito.never()).setGameMode(Mockito.eq(GameMode.SPECTATOR)); Mockito.verify(player, Mockito.never()).setGameMode(Mockito.eq(GameMode.SPECTATOR));
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testOnVisitorGetDamageVoid() { public void testOnVisitorGetDamageVoid() {
// For testing, have no island to teleport to // For testing, have no island to teleport to

View File

@ -17,7 +17,6 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Enderman; import org.bukkit.entity.Enderman;
@ -33,7 +32,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -115,7 +113,6 @@ public class ItemFrameListenerTest {
enderman = mock(Enderman.class); enderman = mock(Enderman.class);
when(enderman.getLocation()).thenReturn(location); when(enderman.getLocation()).thenReturn(location);
when(enderman.getWorld()).thenReturn(world); when(enderman.getWorld()).thenReturn(world);
when(enderman.getCarriedMaterial()).thenReturn(new MaterialData(Material.STONE));
slime = mock(Slime.class); slime = mock(Slime.class);
when(slime.getLocation()).thenReturn(location); when(slime.getLocation()).thenReturn(location);
@ -152,7 +149,6 @@ public class ItemFrameListenerTest {
ItemFrameListener ifl = new ItemFrameListener(); ItemFrameListener ifl = new ItemFrameListener();
Entity entity = mock(ItemFrame.class); Entity entity = mock(ItemFrame.class);
DamageCause cause = DamageCause.ENTITY_ATTACK; DamageCause cause = DamageCause.ENTITY_ATTACK;
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0); EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0);
ifl.onItemFrameDamage(e); ifl.onItemFrameDamage(e);
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
@ -166,7 +162,6 @@ public class ItemFrameListenerTest {
ItemFrameListener ifl = new ItemFrameListener(); ItemFrameListener ifl = new ItemFrameListener();
Entity entity = mock(Monster.class); Entity entity = mock(Monster.class);
DamageCause cause = DamageCause.ENTITY_ATTACK; DamageCause cause = DamageCause.ENTITY_ATTACK;
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0); EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0);
ifl.onItemFrameDamage(e); ifl.onItemFrameDamage(e);
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
@ -182,7 +177,6 @@ public class ItemFrameListenerTest {
DamageCause cause = DamageCause.ENTITY_ATTACK; DamageCause cause = DamageCause.ENTITY_ATTACK;
Projectile p = mock(Projectile.class); Projectile p = mock(Projectile.class);
when(p.getShooter()).thenReturn(enderman); when(p.getShooter()).thenReturn(enderman);
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0); EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
ifl.onItemFrameDamage(e); ifl.onItemFrameDamage(e);
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
@ -199,7 +193,6 @@ public class ItemFrameListenerTest {
Projectile p = mock(Projectile.class); Projectile p = mock(Projectile.class);
Player player = mock(Player.class); Player player = mock(Player.class);
when(p.getShooter()).thenReturn(player); when(p.getShooter()).thenReturn(player);
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0); EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
ifl.onItemFrameDamage(e); ifl.onItemFrameDamage(e);
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package world.bentobox.bentobox.listeners.protection; package world.bentobox.bentobox.listeners.protection;
@ -93,7 +93,7 @@ public class FlyingMobEventsTest {
when(user.getName()).thenReturn("tastybento"); when(user.getName()).thenReturn("tastybento");
User.setPlugin(plugin); User.setPlugin(plugin);
// Player has island to begin with // Player has island to begin with
im = mock(IslandsManager.class); im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
@ -111,16 +111,16 @@ public class FlyingMobEventsTest {
LocalesManager lm = mock(LocalesManager.class); LocalesManager lm = mock(LocalesManager.class);
when(lm.get(Mockito.any(), Mockito.any())).thenReturn("mock translation"); when(lm.get(Mockito.any(), Mockito.any())).thenReturn("mock translation");
when(plugin.getLocalesManager()).thenReturn(lm); when(plugin.getLocalesManager()).thenReturn(lm);
// Normally in world // Normally in world
Util.setPlugin(plugin); Util.setPlugin(plugin);
// Worlds // Worlds
iwm = mock(IslandWorldManager.class); iwm = mock(IslandWorldManager.class);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
when(iwm.inWorld(any())).thenReturn(true); when(iwm.inWorld(any())).thenReturn(true);
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#FlyingMobEvents(world.bentobox.bentobox.BentoBox)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#FlyingMobEvents(world.bentobox.bentobox.BentoBox)}.
*/ */
@ -142,9 +142,9 @@ public class FlyingMobEventsTest {
// Not in world // Not in world
when(iwm.inWorld(any())).thenReturn(false); when(iwm.inWorld(any())).thenReturn(false);
fme.onMobSpawn(e); fme.onMobSpawn(e);
Mockito.verify(im, Mockito.never()).getIslandAt(Mockito.any(Location.class)); Mockito.verify(im, Mockito.never()).getIslandAt(Mockito.any(Location.class));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobSpawn(org.bukkit.event.entity.CreatureSpawnEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobSpawn(org.bukkit.event.entity.CreatureSpawnEvent)}.
*/ */
@ -155,9 +155,9 @@ public class FlyingMobEventsTest {
when(le.getType()).thenReturn(EntityType.AREA_EFFECT_CLOUD); when(le.getType()).thenReturn(EntityType.AREA_EFFECT_CLOUD);
CreatureSpawnEvent e = new CreatureSpawnEvent(le, SpawnReason.BUILD_WITHER); CreatureSpawnEvent e = new CreatureSpawnEvent(le, SpawnReason.BUILD_WITHER);
fme.onMobSpawn(e); fme.onMobSpawn(e);
Mockito.verify(im, Mockito.never()).getIslandAt(Mockito.any(Location.class)); Mockito.verify(im, Mockito.never()).getIslandAt(Mockito.any(Location.class));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobSpawn(org.bukkit.event.entity.CreatureSpawnEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobSpawn(org.bukkit.event.entity.CreatureSpawnEvent)}.
*/ */
@ -195,18 +195,18 @@ public class FlyingMobEventsTest {
EntityExplodeEvent e = new EntityExplodeEvent(null, null, null, 0); EntityExplodeEvent e = new EntityExplodeEvent(null, null, null, 0);
// null entity // null entity
assertFalse(fme.onMobExplosion(e)); assertFalse(fme.onMobExplosion(e));
// Not in world // Not in world
Entity ent = mock(Entity.class); Entity ent = mock(Entity.class);
when(iwm.inWorld(any())).thenReturn(false); when(iwm.inWorld(any())).thenReturn(false);
e = new EntityExplodeEvent(ent, null, null, 0); e = new EntityExplodeEvent(ent, null, null, 0);
assertFalse(fme.onMobExplosion(e)); assertFalse(fme.onMobExplosion(e));
// Unknown entity (not in the list) // Unknown entity (not in the list)
when(iwm.inWorld(any())).thenReturn(true); when(iwm.inWorld(any())).thenReturn(true);
assertFalse(fme.onMobExplosion(e)); assertFalse(fme.onMobExplosion(e));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobExplosion(org.bukkit.event.entity.EntityExplodeEvent)}.
*/ */
@ -232,13 +232,13 @@ public class FlyingMobEventsTest {
List<Block> affectedBlocks = new ArrayList<>(); List<Block> affectedBlocks = new ArrayList<>();
affectedBlocks.add(block); affectedBlocks.add(block);
// Create event // Create event
EntityExplodeEvent e = new EntityExplodeEvent(le, mock(Location.class), affectedBlocks, 0); EntityExplodeEvent e = new EntityExplodeEvent(le, mock(Location.class), affectedBlocks, 0);
// Nothing blocked // Nothing blocked
assertFalse(fme.onMobExplosion(e)); assertFalse(fme.onMobExplosion(e));
assertFalse(e.isCancelled()); assertFalse(e.isCancelled());
assertFalse(e.blockList().isEmpty()); assertFalse(e.blockList().isEmpty());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onMobExplosion(org.bukkit.event.entity.EntityExplodeEvent)}.
*/ */
@ -264,7 +264,7 @@ public class FlyingMobEventsTest {
List<Block> affectedBlocks = new ArrayList<>(); List<Block> affectedBlocks = new ArrayList<>();
affectedBlocks.add(block); affectedBlocks.add(block);
// Create event // Create event
EntityExplodeEvent e = new EntityExplodeEvent(le, mock(Location.class), affectedBlocks, 0); EntityExplodeEvent e = new EntityExplodeEvent(le, mock(Location.class), affectedBlocks, 0);
// Blocked // Blocked
assertTrue(fme.onMobExplosion(e)); assertTrue(fme.onMobExplosion(e));
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
@ -291,12 +291,12 @@ public class FlyingMobEventsTest {
fme.onMobSpawn(cee); fme.onMobSpawn(cee);
// Make the wither explode // Make the wither explode
// Create event // Create event
ExplosionPrimeEvent e = new ExplosionPrimeEvent(le, 0, false); ExplosionPrimeEvent e = new ExplosionPrimeEvent(le, 0, false);
// Blocked // Blocked
assertTrue(fme.onWitherExplode(e)); assertTrue(fme.onWitherExplode(e));
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onWitherExplode(org.bukkit.event.entity.ExplosionPrimeEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.protection.FlyingMobEvents#onWitherExplode(org.bukkit.event.entity.ExplosionPrimeEvent)}.
*/ */
@ -319,9 +319,9 @@ public class FlyingMobEventsTest {
Projectile skull = mock(Projectile.class); Projectile skull = mock(Projectile.class);
when(skull.getType()).thenReturn(EntityType.WITHER_SKULL); when(skull.getType()).thenReturn(EntityType.WITHER_SKULL);
when(skull.getShooter()).thenReturn(wither); when(skull.getShooter()).thenReturn(wither);
// Create event // Create event
ExplosionPrimeEvent e = new ExplosionPrimeEvent(skull, 0, false); ExplosionPrimeEvent e = new ExplosionPrimeEvent(skull, 0, false);
// Blocked // Blocked
assertTrue(fme.onWitherExplode(e)); assertTrue(fme.onWitherExplode(e));
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
@ -347,14 +347,13 @@ public class FlyingMobEventsTest {
fme.onMobSpawn(cee); fme.onMobSpawn(cee);
// Create event // Create event
/** /**
* *
* @param what the Entity causing the change * @param what the Entity causing the change
* @param block the block (before the change) * @param block the block (before the change)
* @param to the future material being changed to * @param to the future material being changed to
* @param data the future block data * @param data the future block data
* @deprecated Magic value * @deprecated Magic value
*/ */
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR.createBlockData()); EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR.createBlockData());
// Blocked // Blocked
fme.onWitherChangeBlocks(e); fme.onWitherChangeBlocks(e);