Skip to content

Commit

Permalink
Updated test units to 1.13 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Aug 1, 2018
1 parent e6418f0 commit 138b8e7
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testIconString() {
assertNotNull(item.getItem().getType());
SkullMeta skullMeta = (SkullMeta)item.getItem().getItemMeta();
assertEquals("tastybento",skullMeta.getOwner());
assertEquals(Material.SKULL_ITEM, item.getItem().getType());
assertEquals(Material.PLAYER_HEAD, item.getItem().getType());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,13 @@ public void testOnTreeGrow() {
// Wrong world to start
when(loc.getWorld()).thenReturn(world);
BlockState log = mock(BlockState.class);
when(log.getType()).thenReturn(Material.LOG);
when(log.getType()).thenReturn(Material.OAK_LOG);
BlockState log2 = mock(BlockState.class);
when(log2.getType()).thenReturn(Material.LOG_2);
when(log2.getType()).thenReturn(Material.ACACIA_LOG);
BlockState leaves = mock(BlockState.class);
when(leaves.getType()).thenReturn(Material.LEAVES);
when(leaves.getType()).thenReturn(Material.OAK_LEAVES);
BlockState leaves2 = mock(BlockState.class);
when(leaves2.getType()).thenReturn(Material.LEAVES_2);
when(leaves2.getType()).thenReturn(Material.OAK_LEAVES);
List<BlockState> blocks = new ArrayList<>();
blocks.add(log);
blocks.add(log2);
Expand All @@ -738,7 +738,6 @@ public void testOnTreeGrow() {
Mockito.verify(log2).setType(Material.GRAVEL);
Mockito.verify(leaves).setType(Material.GLOWSTONE);
Mockito.verify(leaves2).setType(Material.GLOWSTONE);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ public void testNotEnderman() {
EndermanListener listener = new EndermanListener();
Block to = mock(Block.class);
Material block = Material.ACACIA_DOOR;
byte data = 0;
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(slime, to, block, data);
EntityChangeBlockEvent e = new EntityChangeBlockEvent(slime, to, block.createBlockData());
listener.onEndermanGrief(e);
assertFalse(e.isCancelled());
}
Expand All @@ -168,9 +166,7 @@ public void testOnEndermanGriefWrongWorld() {
EndermanListener listener = new EndermanListener();
Block to = mock(Block.class);
Material block = Material.ACACIA_DOOR;
byte data = 0;
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
listener.onEndermanGrief(e);
assertFalse(e.isCancelled());
}
Expand All @@ -184,9 +180,7 @@ public void testOnEndermanGriefAllowed() {
EndermanListener listener = new EndermanListener();
Block to = mock(Block.class);
Material block = Material.ACACIA_DOOR;
byte data = 0;
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
listener.onEndermanGrief(e);
assertFalse(e.isCancelled());
}
Expand All @@ -199,9 +193,7 @@ public void testOnEndermanGrief() {
EndermanListener listener = new EndermanListener();
Block to = mock(Block.class);
Material block = Material.ACACIA_DOOR;
byte data = 0;
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
listener.onEndermanGrief(e);
assertTrue(e.isCancelled());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void testOnBlockIgnite() {
assertFalse(listener.onBlockIgnite(e));

// Now set to something flammable
when(block.getType()).thenReturn(Material.WOOD);
when(block.getType()).thenReturn(Material.OAK_PLANKS);

// Disallow fire
when(island.isAllowed(Mockito.any())).thenReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Witch;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.*;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
Expand Down Expand Up @@ -516,14 +506,13 @@ public void testOnEntityDamagePVPAllowedProjectile() {

}


/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.PVPListener#onFishing(org.bukkit.event.player.PlayerFishEvent)}.
*/
@Test
public void testOnFishing() {
// Fish hook
Fish hook = mock(Fish.class);
FishHook hook = mock(FishHook.class);
// Catch a zombie - fine
Entity caught = mock(Zombie.class);
PlayerFishEvent pfe = new PlayerFishEvent(player, caught, hook, null);
Expand Down Expand Up @@ -568,7 +557,7 @@ public void testOnFishing() {
@Test
public void testOnFishingProtectVisitors() {
// Fish hook
Fish hook = mock(Fish.class);
FishHook hook = mock(FishHook.class);
// Catch a player
PlayerFishEvent pfe = new PlayerFishEvent(player, player2, hook, null);

Expand All @@ -591,7 +580,7 @@ public void testOnFishingProtectVisitors() {
@Test
public void testOnFishingSelfDamage() {
// Fish hook
Fish hook = mock(Fish.class);
FishHook hook = mock(FishHook.class);
// Catch a player
PlayerFishEvent pfe = new PlayerFishEvent(player, player, hook, null);
assertFalse(pfe.isCancelled());
Expand All @@ -604,7 +593,7 @@ public void testOnFishingSelfDamage() {
@Test
public void testOnFishingNoPVPProtectVisitors() {
// Fish hook
Fish hook = mock(Fish.class);
FishHook hook = mock(FishHook.class);
// Catch a player
PlayerFishEvent pfe = new PlayerFishEvent(player, player2, hook, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public void testOnWitherChangeBlocks() {
* @deprecated Magic value
*/
@SuppressWarnings("deprecation")
EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR, (byte) 0);
EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR.createBlockData());
// Blocked
fme.onWitherChangeBlocks(e);
assertTrue(e.isCancelled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,25 @@ public void testIsSafeLocationSubmerged() {
public void testIsSafeLocationPortals() {
when(ground.getType()).thenReturn(Material.STONE);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.PORTAL);
when(space2.getType()).thenReturn(Material.NETHER_PORTAL);
assertFalse(manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.STONE);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.ENDER_PORTAL);
when(space2.getType()).thenReturn(Material.END_PORTAL);
assertFalse(manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.STONE);
when(space1.getType()).thenReturn(Material.PORTAL);
when(space1.getType()).thenReturn(Material.NETHER_PORTAL);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse(manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.STONE);
when(space1.getType()).thenReturn(Material.ENDER_PORTAL);
when(space1.getType()).thenReturn(Material.END_PORTAL);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse(manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.PORTAL);
when(ground.getType()).thenReturn(Material.NETHER_PORTAL);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse(manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.ENDER_PORTAL);
when(ground.getType()).thenReturn(Material.END_PORTAL);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse(manager.isSafeLocation(location));
Expand All @@ -261,26 +261,14 @@ public void testIsSafeLocationLava() {
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.LAVA);
assertFalse("In lava", manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.STATIONARY_LAVA);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse("In lava", manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.AIR);
when(space1.getType()).thenReturn(Material.STATIONARY_LAVA);
when(space2.getType()).thenReturn(Material.AIR);
assertFalse("In lava", manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.AIR);
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.STATIONARY_LAVA);
assertFalse("In lava", manager.isSafeLocation(location));
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
*/
@Test
public void testTrapDoor() {
when(ground.getType()).thenReturn(Material.TRAP_DOOR);
when(ground.getType()).thenReturn(Material.OAK_TRAPDOOR);

// Open trapdoor
TrapDoor trapDoor = mock(TrapDoor.class);
Expand Down Expand Up @@ -309,12 +297,12 @@ public void testBadBlocks() {
assertFalse("Fence :" + m.toString(), manager.isSafeLocation(location));
});
// Signs
when(ground.getType()).thenReturn(Material.SIGN_POST);
when(ground.getType()).thenReturn(Material.SIGN);
assertFalse("Sign", manager.isSafeLocation(location));
when(ground.getType()).thenReturn(Material.WALL_SIGN);
assertFalse("Sign", manager.isSafeLocation(location));
// Bad Blocks
Material[] badMats = {Material.CACTUS, Material.BOAT};
Material[] badMats = {Material.CACTUS, Material.OAK_BOAT};
Arrays.asList(badMats).forEach(m -> {
when(ground.getType()).thenReturn(m);
assertFalse("Bad mat :" + m.toString(), manager.isSafeLocation(location));
Expand Down Expand Up @@ -342,12 +330,12 @@ public void testSolidBlocks() {
when(space2.getType()).thenReturn(Material.WALL_SIGN);
assertTrue("Wall sign 2", manager.isSafeLocation(location));

when(space1.getType()).thenReturn(Material.SIGN_POST);
when(space1.getType()).thenReturn(Material.SIGN);
when(space2.getType()).thenReturn(Material.AIR);
assertTrue("Wall sign 1", manager.isSafeLocation(location));

when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.SIGN_POST);
when(space2.getType()).thenReturn(Material.SIGN);
assertTrue("Wall sign 2", manager.isSafeLocation(location));
}

Expand Down Expand Up @@ -456,7 +444,7 @@ public void testGetCount() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(java.util.UUID)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(World, UUID)}.
*/
@Test
public void testGetIsland() {
Expand Down Expand Up @@ -497,7 +485,7 @@ public void testGetIslandAtLocation() throws Exception {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(java.util.UUID)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(World, UUID)}.
*/
@Test
public void testGetIslandLocation() {
Expand All @@ -508,7 +496,7 @@ public void testGetIslandLocation() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getLast()}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getLast(World)}.
*/
@Test
public void testGetLast() {
Expand All @@ -519,7 +507,7 @@ public void testGetLast() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getMembers(java.util.UUID)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getMembers(World, UUID)}.
* @throws Exception
*/
@Test
Expand Down Expand Up @@ -572,7 +560,7 @@ public void testGetProtectedIslandAt() throws Exception {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(java.util.UUID, int)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(World, User, int)}.
*/
@Test
public void testGetSafeHomeLocation() {
Expand All @@ -585,7 +573,7 @@ public void testGetSafeHomeLocation() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint()}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint(World)}.
*/
@Test
public void testGetSpawnPoint() {
Expand All @@ -602,7 +590,7 @@ public void testGetSpawnPoint() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(org.bukkit.entity.Player, int)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(World, Player, int)}.
*/
@Test
public void testHomeTeleportPlayerInt() {
Expand All @@ -618,7 +606,7 @@ public void testHomeTeleportPlayerInt() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(org.bukkit.entity.Player, int)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(World, Player, int)}.
*/
@Test
public void testHomeTeleportPlayerIntDifferentGameMode() {
Expand Down Expand Up @@ -648,7 +636,7 @@ public void testIsAtSpawn() {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isOwner(java.util.UUID)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isOwner(World, UUID)}.
* @throws Exception
*/
@Test
Expand Down Expand Up @@ -753,7 +741,7 @@ public void testUserIsOnIsland() throws Exception {
}

/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(java.util.UUID)}.
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(World, User)}.
*/
@Test
public void testRemovePlayer() {
Expand Down
Loading

0 comments on commit 138b8e7

Please sign in to comment.