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

View File

@ -180,7 +180,6 @@ public class InvincibleVisitorsListenerTest {
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageNotPlayer() {
LivingEntity le = mock(LivingEntity.class);
@ -189,7 +188,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled());
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageNotInWorld() {
when(iwm.inWorld(Mockito.any())).thenReturn(false);
@ -198,7 +196,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled());
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageNotInIvSettings() {
when(iwm.inWorld(Mockito.any())).thenReturn(false);
@ -207,7 +204,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled());
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageNotVisitor() {
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
@ -216,7 +212,6 @@ public class InvincibleVisitorsListenerTest {
assertFalse(e.isCancelled());
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageNotVoid() {
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));
}
@SuppressWarnings("deprecation")
@Test
public void testOnVisitorGetDamageVoid() {
// 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.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
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.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.PluginManager;
import org.junit.Before;
import org.junit.Test;
@ -115,7 +113,6 @@ public class ItemFrameListenerTest {
enderman = mock(Enderman.class);
when(enderman.getLocation()).thenReturn(location);
when(enderman.getWorld()).thenReturn(world);
when(enderman.getCarriedMaterial()).thenReturn(new MaterialData(Material.STONE));
slime = mock(Slime.class);
when(slime.getLocation()).thenReturn(location);
@ -152,7 +149,6 @@ public class ItemFrameListenerTest {
ItemFrameListener ifl = new ItemFrameListener();
Entity entity = mock(ItemFrame.class);
DamageCause cause = DamageCause.ENTITY_ATTACK;
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0);
ifl.onItemFrameDamage(e);
assertTrue(e.isCancelled());
@ -166,7 +162,6 @@ public class ItemFrameListenerTest {
ItemFrameListener ifl = new ItemFrameListener();
Entity entity = mock(Monster.class);
DamageCause cause = DamageCause.ENTITY_ATTACK;
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0);
ifl.onItemFrameDamage(e);
assertFalse(e.isCancelled());
@ -182,7 +177,6 @@ public class ItemFrameListenerTest {
DamageCause cause = DamageCause.ENTITY_ATTACK;
Projectile p = mock(Projectile.class);
when(p.getShooter()).thenReturn(enderman);
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
ifl.onItemFrameDamage(e);
assertTrue(e.isCancelled());
@ -199,7 +193,6 @@ public class ItemFrameListenerTest {
Projectile p = mock(Projectile.class);
Player player = mock(Player.class);
when(p.getShooter()).thenReturn(player);
@SuppressWarnings("deprecation")
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
ifl.onItemFrameDamage(e);
assertFalse(e.isCancelled());

View File

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