|
21 | 21 | import java.util.logging.Logger; |
22 | 22 |
|
23 | 23 | import org.bukkit.Bukkit; |
24 | | -import org.bukkit.ChatColor; |
25 | 24 | import org.bukkit.Location; |
26 | 25 | import org.bukkit.Material; |
27 | 26 | import org.bukkit.OfflinePlayer; |
|
71 | 70 | * |
72 | 71 | */ |
73 | 72 | @RunWith(PowerMockRunner.class) |
74 | | -@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class, ChatColor.class}) |
| 73 | +@PrepareForTest({Bukkit.class, Util.class, DatabaseSetup.class}) |
75 | 74 | public class WarpSignsManagerTest { |
76 | 75 |
|
77 | 76 | @Mock |
@@ -139,12 +138,15 @@ public void setUp() throws Exception { |
139 | 138 |
|
140 | 139 | // Player |
141 | 140 | when(player.getUniqueId()).thenReturn(uuid); |
| 141 | + when(player.isOnline()).thenReturn(true); |
| 142 | + when(player.canSee(any(Player.class))).thenReturn(true); |
142 | 143 | User.setPlugin(plugin); |
143 | 144 | User.getInstance(player); |
144 | 145 |
|
145 | 146 | // Locales |
146 | 147 | LocalesManager lm = mock(LocalesManager.class); |
147 | | - when(lm.get(Mockito.any(), Mockito.any())).thenReturn(null); |
| 148 | + when(lm.getAvailablePrefixes(any())).thenReturn(Collections.emptySet()); |
| 149 | + when(lm.get(Mockito.any(), Mockito.any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class)); |
148 | 150 | when(plugin.getLocalesManager()).thenReturn(lm); |
149 | 151 | // Return the same string |
150 | 152 | PlaceholdersManager phm = mock(PlaceholdersManager.class); |
@@ -212,6 +214,7 @@ public void setUp() throws Exception { |
212 | 214 | // IWM |
213 | 215 | when(plugin.getIWM()).thenReturn(iwm); |
214 | 216 | when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock."); |
| 217 | + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); |
215 | 218 |
|
216 | 219 | // Island Manager |
217 | 220 | when(addon.getIslands()).thenReturn(im); |
@@ -425,13 +428,15 @@ public void testWarpPlayer() { |
425 | 428 | when(p.getWorld()).thenReturn(world); |
426 | 429 | when(p.getName()).thenReturn("tastybento"); |
427 | 430 | when(p.getLocation()).thenReturn(location); |
| 431 | + when(p.isOnline()).thenReturn(true); |
| 432 | + when(p.canSee(any(Player.class))).thenReturn(true); |
428 | 433 | @Nullable |
429 | 434 | User u = User.getInstance(p); |
430 | 435 | PowerMockito.when(Util.teleportAsync(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(true)); |
431 | 436 | wsm.warpPlayer(world, u, uuid); |
432 | 437 | PowerMockito.verifyStatic(Util.class); |
433 | 438 | Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND)); |
434 | | - verify(player).sendMessage("warps.player-warped"); |
| 439 | + verify(player).sendMessage(anyString()); |
435 | 440 | } |
436 | 441 |
|
437 | 442 | /** |
|
0 commit comments