Skip to content

Commit 138b8e7

Browse files
committed
Updated test units to 1.13 API
1 parent e6418f0 commit 138b8e7

File tree

8 files changed

+42
-107
lines changed

8 files changed

+42
-107
lines changed

src/test/java/world/bentobox/bentobox/api/panels/builders/PanelItemBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testIconString() {
9696
assertNotNull(item.getItem().getType());
9797
SkullMeta skullMeta = (SkullMeta)item.getItem().getItemMeta();
9898
assertEquals("tastybento",skullMeta.getOwner());
99-
assertEquals(Material.SKULL_ITEM, item.getItem().getType());
99+
assertEquals(Material.PLAYER_HEAD, item.getItem().getType());
100100
}
101101

102102
@Test

src/test/java/world/bentobox/bentobox/listeners/NetherPortalsTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,13 @@ public void testOnTreeGrow() {
709709
// Wrong world to start
710710
when(loc.getWorld()).thenReturn(world);
711711
BlockState log = mock(BlockState.class);
712-
when(log.getType()).thenReturn(Material.LOG);
712+
when(log.getType()).thenReturn(Material.OAK_LOG);
713713
BlockState log2 = mock(BlockState.class);
714-
when(log2.getType()).thenReturn(Material.LOG_2);
714+
when(log2.getType()).thenReturn(Material.ACACIA_LOG);
715715
BlockState leaves = mock(BlockState.class);
716-
when(leaves.getType()).thenReturn(Material.LEAVES);
716+
when(leaves.getType()).thenReturn(Material.OAK_LEAVES);
717717
BlockState leaves2 = mock(BlockState.class);
718-
when(leaves2.getType()).thenReturn(Material.LEAVES_2);
718+
when(leaves2.getType()).thenReturn(Material.OAK_LEAVES);
719719
List<BlockState> blocks = new ArrayList<>();
720720
blocks.add(log);
721721
blocks.add(log2);
@@ -738,7 +738,6 @@ public void testOnTreeGrow() {
738738
Mockito.verify(log2).setType(Material.GRAVEL);
739739
Mockito.verify(leaves).setType(Material.GLOWSTONE);
740740
Mockito.verify(leaves2).setType(Material.GLOWSTONE);
741-
742741
}
743742

744743
}

src/test/java/world/bentobox/bentobox/listeners/flags/EndermanListenerTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ public void testNotEnderman() {
152152
EndermanListener listener = new EndermanListener();
153153
Block to = mock(Block.class);
154154
Material block = Material.ACACIA_DOOR;
155-
byte data = 0;
156-
@SuppressWarnings("deprecation")
157-
EntityChangeBlockEvent e = new EntityChangeBlockEvent(slime, to, block, data);
155+
EntityChangeBlockEvent e = new EntityChangeBlockEvent(slime, to, block.createBlockData());
158156
listener.onEndermanGrief(e);
159157
assertFalse(e.isCancelled());
160158
}
@@ -168,9 +166,7 @@ public void testOnEndermanGriefWrongWorld() {
168166
EndermanListener listener = new EndermanListener();
169167
Block to = mock(Block.class);
170168
Material block = Material.ACACIA_DOOR;
171-
byte data = 0;
172-
@SuppressWarnings("deprecation")
173-
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
169+
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
174170
listener.onEndermanGrief(e);
175171
assertFalse(e.isCancelled());
176172
}
@@ -184,9 +180,7 @@ public void testOnEndermanGriefAllowed() {
184180
EndermanListener listener = new EndermanListener();
185181
Block to = mock(Block.class);
186182
Material block = Material.ACACIA_DOOR;
187-
byte data = 0;
188-
@SuppressWarnings("deprecation")
189-
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
183+
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
190184
listener.onEndermanGrief(e);
191185
assertFalse(e.isCancelled());
192186
}
@@ -199,9 +193,7 @@ public void testOnEndermanGrief() {
199193
EndermanListener listener = new EndermanListener();
200194
Block to = mock(Block.class);
201195
Material block = Material.ACACIA_DOOR;
202-
byte data = 0;
203-
@SuppressWarnings("deprecation")
204-
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block, data);
196+
EntityChangeBlockEvent e = new EntityChangeBlockEvent(enderman, to, block.createBlockData());
205197
listener.onEndermanGrief(e);
206198
assertTrue(e.isCancelled());
207199
}

src/test/java/world/bentobox/bentobox/listeners/flags/FireListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public void testOnBlockIgnite() {
300300
assertFalse(listener.onBlockIgnite(e));
301301

302302
// Now set to something flammable
303-
when(block.getType()).thenReturn(Material.WOOD);
303+
when(block.getType()).thenReturn(Material.OAK_PLANKS);
304304

305305
// Disallow fire
306306
when(island.isAllowed(Mockito.any())).thenReturn(false);

src/test/java/world/bentobox/bentobox/listeners/flags/PVPListenerTest.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@
2222
import org.bukkit.Bukkit;
2323
import org.bukkit.Location;
2424
import org.bukkit.World;
25-
import org.bukkit.entity.AreaEffectCloud;
26-
import org.bukkit.entity.Creeper;
27-
import org.bukkit.entity.Entity;
28-
import org.bukkit.entity.Fish;
29-
import org.bukkit.entity.LingeringPotion;
30-
import org.bukkit.entity.LivingEntity;
31-
import org.bukkit.entity.Player;
32-
import org.bukkit.entity.Projectile;
33-
import org.bukkit.entity.ThrownPotion;
34-
import org.bukkit.entity.Witch;
35-
import org.bukkit.entity.Zombie;
25+
import org.bukkit.entity.*;
3626
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
3727
import org.bukkit.event.entity.EntityDamageByEntityEvent;
3828
import org.bukkit.event.entity.EntityDamageEvent;
@@ -516,14 +506,13 @@ public void testOnEntityDamagePVPAllowedProjectile() {
516506

517507
}
518508

519-
520509
/**
521510
* Test method for {@link world.bentobox.bentobox.listeners.flags.PVPListener#onFishing(org.bukkit.event.player.PlayerFishEvent)}.
522511
*/
523512
@Test
524513
public void testOnFishing() {
525514
// Fish hook
526-
Fish hook = mock(Fish.class);
515+
FishHook hook = mock(FishHook.class);
527516
// Catch a zombie - fine
528517
Entity caught = mock(Zombie.class);
529518
PlayerFishEvent pfe = new PlayerFishEvent(player, caught, hook, null);
@@ -568,7 +557,7 @@ public void testOnFishing() {
568557
@Test
569558
public void testOnFishingProtectVisitors() {
570559
// Fish hook
571-
Fish hook = mock(Fish.class);
560+
FishHook hook = mock(FishHook.class);
572561
// Catch a player
573562
PlayerFishEvent pfe = new PlayerFishEvent(player, player2, hook, null);
574563

@@ -591,7 +580,7 @@ public void testOnFishingProtectVisitors() {
591580
@Test
592581
public void testOnFishingSelfDamage() {
593582
// Fish hook
594-
Fish hook = mock(Fish.class);
583+
FishHook hook = mock(FishHook.class);
595584
// Catch a player
596585
PlayerFishEvent pfe = new PlayerFishEvent(player, player, hook, null);
597586
assertFalse(pfe.isCancelled());
@@ -604,7 +593,7 @@ public void testOnFishingSelfDamage() {
604593
@Test
605594
public void testOnFishingNoPVPProtectVisitors() {
606595
// Fish hook
607-
Fish hook = mock(Fish.class);
596+
FishHook hook = mock(FishHook.class);
608597
// Catch a player
609598
PlayerFishEvent pfe = new PlayerFishEvent(player, player2, hook, null);
610599

src/test/java/world/bentobox/bentobox/listeners/protection/FlyingMobEventsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public void testOnWitherChangeBlocks() {
356356
* @deprecated Magic value
357357
*/
358358
@SuppressWarnings("deprecation")
359-
EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR, (byte) 0);
359+
EntityChangeBlockEvent e = new EntityChangeBlockEvent(wither, mock(Block.class), Material.AIR.createBlockData());
360360
// Blocked
361361
fme.onWitherChangeBlocks(e);
362362
assertTrue(e.isCancelled());

src/test/java/world/bentobox/bentobox/managers/IslandsManagerTest.java

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -220,25 +220,25 @@ public void testIsSafeLocationSubmerged() {
220220
public void testIsSafeLocationPortals() {
221221
when(ground.getType()).thenReturn(Material.STONE);
222222
when(space1.getType()).thenReturn(Material.AIR);
223-
when(space2.getType()).thenReturn(Material.PORTAL);
223+
when(space2.getType()).thenReturn(Material.NETHER_PORTAL);
224224
assertFalse(manager.isSafeLocation(location));
225225
when(ground.getType()).thenReturn(Material.STONE);
226226
when(space1.getType()).thenReturn(Material.AIR);
227-
when(space2.getType()).thenReturn(Material.ENDER_PORTAL);
227+
when(space2.getType()).thenReturn(Material.END_PORTAL);
228228
assertFalse(manager.isSafeLocation(location));
229229
when(ground.getType()).thenReturn(Material.STONE);
230-
when(space1.getType()).thenReturn(Material.PORTAL);
230+
when(space1.getType()).thenReturn(Material.NETHER_PORTAL);
231231
when(space2.getType()).thenReturn(Material.AIR);
232232
assertFalse(manager.isSafeLocation(location));
233233
when(ground.getType()).thenReturn(Material.STONE);
234-
when(space1.getType()).thenReturn(Material.ENDER_PORTAL);
234+
when(space1.getType()).thenReturn(Material.END_PORTAL);
235235
when(space2.getType()).thenReturn(Material.AIR);
236236
assertFalse(manager.isSafeLocation(location));
237-
when(ground.getType()).thenReturn(Material.PORTAL);
237+
when(ground.getType()).thenReturn(Material.NETHER_PORTAL);
238238
when(space1.getType()).thenReturn(Material.AIR);
239239
when(space2.getType()).thenReturn(Material.AIR);
240240
assertFalse(manager.isSafeLocation(location));
241-
when(ground.getType()).thenReturn(Material.ENDER_PORTAL);
241+
when(ground.getType()).thenReturn(Material.END_PORTAL);
242242
when(space1.getType()).thenReturn(Material.AIR);
243243
when(space2.getType()).thenReturn(Material.AIR);
244244
assertFalse(manager.isSafeLocation(location));
@@ -261,26 +261,14 @@ public void testIsSafeLocationLava() {
261261
when(space1.getType()).thenReturn(Material.AIR);
262262
when(space2.getType()).thenReturn(Material.LAVA);
263263
assertFalse("In lava", manager.isSafeLocation(location));
264-
when(ground.getType()).thenReturn(Material.STATIONARY_LAVA);
265-
when(space1.getType()).thenReturn(Material.AIR);
266-
when(space2.getType()).thenReturn(Material.AIR);
267-
assertFalse("In lava", manager.isSafeLocation(location));
268-
when(ground.getType()).thenReturn(Material.AIR);
269-
when(space1.getType()).thenReturn(Material.STATIONARY_LAVA);
270-
when(space2.getType()).thenReturn(Material.AIR);
271-
assertFalse("In lava", manager.isSafeLocation(location));
272-
when(ground.getType()).thenReturn(Material.AIR);
273-
when(space1.getType()).thenReturn(Material.AIR);
274-
when(space2.getType()).thenReturn(Material.STATIONARY_LAVA);
275-
assertFalse("In lava", manager.isSafeLocation(location));
276264
}
277265

278266
/**
279267
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
280268
*/
281269
@Test
282270
public void testTrapDoor() {
283-
when(ground.getType()).thenReturn(Material.TRAP_DOOR);
271+
when(ground.getType()).thenReturn(Material.OAK_TRAPDOOR);
284272

285273
// Open trapdoor
286274
TrapDoor trapDoor = mock(TrapDoor.class);
@@ -309,12 +297,12 @@ public void testBadBlocks() {
309297
assertFalse("Fence :" + m.toString(), manager.isSafeLocation(location));
310298
});
311299
// Signs
312-
when(ground.getType()).thenReturn(Material.SIGN_POST);
300+
when(ground.getType()).thenReturn(Material.SIGN);
313301
assertFalse("Sign", manager.isSafeLocation(location));
314302
when(ground.getType()).thenReturn(Material.WALL_SIGN);
315303
assertFalse("Sign", manager.isSafeLocation(location));
316304
// Bad Blocks
317-
Material[] badMats = {Material.CACTUS, Material.BOAT};
305+
Material[] badMats = {Material.CACTUS, Material.OAK_BOAT};
318306
Arrays.asList(badMats).forEach(m -> {
319307
when(ground.getType()).thenReturn(m);
320308
assertFalse("Bad mat :" + m.toString(), manager.isSafeLocation(location));
@@ -342,12 +330,12 @@ public void testSolidBlocks() {
342330
when(space2.getType()).thenReturn(Material.WALL_SIGN);
343331
assertTrue("Wall sign 2", manager.isSafeLocation(location));
344332

345-
when(space1.getType()).thenReturn(Material.SIGN_POST);
333+
when(space1.getType()).thenReturn(Material.SIGN);
346334
when(space2.getType()).thenReturn(Material.AIR);
347335
assertTrue("Wall sign 1", manager.isSafeLocation(location));
348336

349337
when(space1.getType()).thenReturn(Material.AIR);
350-
when(space2.getType()).thenReturn(Material.SIGN_POST);
338+
when(space2.getType()).thenReturn(Material.SIGN);
351339
assertTrue("Wall sign 2", manager.isSafeLocation(location));
352340
}
353341

@@ -456,7 +444,7 @@ public void testGetCount() {
456444
}
457445

458446
/**
459-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(java.util.UUID)}.
447+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(World, UUID)}.
460448
*/
461449
@Test
462450
public void testGetIsland() {
@@ -497,7 +485,7 @@ public void testGetIslandAtLocation() throws Exception {
497485
}
498486

499487
/**
500-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(java.util.UUID)}.
488+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIslandLocation(World, UUID)}.
501489
*/
502490
@Test
503491
public void testGetIslandLocation() {
@@ -508,7 +496,7 @@ public void testGetIslandLocation() {
508496
}
509497

510498
/**
511-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getLast()}.
499+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getLast(World)}.
512500
*/
513501
@Test
514502
public void testGetLast() {
@@ -519,7 +507,7 @@ public void testGetLast() {
519507
}
520508

521509
/**
522-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getMembers(java.util.UUID)}.
510+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getMembers(World, UUID)}.
523511
* @throws Exception
524512
*/
525513
@Test
@@ -572,7 +560,7 @@ public void testGetProtectedIslandAt() throws Exception {
572560
}
573561

574562
/**
575-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(java.util.UUID, int)}.
563+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(World, User, int)}.
576564
*/
577565
@Test
578566
public void testGetSafeHomeLocation() {
@@ -585,7 +573,7 @@ public void testGetSafeHomeLocation() {
585573
}
586574

587575
/**
588-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint()}.
576+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint(World)}.
589577
*/
590578
@Test
591579
public void testGetSpawnPoint() {
@@ -602,7 +590,7 @@ public void testGetSpawnPoint() {
602590
}
603591

604592
/**
605-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(org.bukkit.entity.Player, int)}.
593+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(World, Player, int)}.
606594
*/
607595
@Test
608596
public void testHomeTeleportPlayerInt() {
@@ -618,7 +606,7 @@ public void testHomeTeleportPlayerInt() {
618606
}
619607

620608
/**
621-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(org.bukkit.entity.Player, int)}.
609+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(World, Player, int)}.
622610
*/
623611
@Test
624612
public void testHomeTeleportPlayerIntDifferentGameMode() {
@@ -648,7 +636,7 @@ public void testIsAtSpawn() {
648636
}
649637

650638
/**
651-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isOwner(java.util.UUID)}.
639+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isOwner(World, UUID)}.
652640
* @throws Exception
653641
*/
654642
@Test
@@ -753,7 +741,7 @@ public void testUserIsOnIsland() throws Exception {
753741
}
754742

755743
/**
756-
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(java.util.UUID)}.
744+
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(World, User)}.
757745
*/
758746
@Test
759747
public void testRemovePlayer() {

0 commit comments

Comments
 (0)