Clean up tests.

This commit is contained in:
tastybento 2021-08-08 18:19:55 -07:00
parent 00938e67da
commit 6c4c42ff64
5 changed files with 26 additions and 29 deletions

View File

@ -219,7 +219,7 @@ public class WarpPanelManagerTest {
PanelBuilder pb = mock(PanelBuilder.class);
wpm.addNavigation(pb, user, world, 60, 2, 20);
verify(pb).item(any());
verify(user).getTranslation(eq("warps.previous"));
verify(user).getTranslation("warps.previous");
}
/**
@ -230,8 +230,8 @@ public class WarpPanelManagerTest {
PanelBuilder pb = mock(PanelBuilder.class);
wpm.addNavigation(pb, user, world, 60, 2, 100);
verify(pb, times(2)).item(any());
verify(user).getTranslation(eq("warps.previous"));
verify(user).getTranslation(eq("warps.next"));
verify(user).getTranslation("warps.previous");
verify(user).getTranslation("warps.next");
}
@ -241,9 +241,9 @@ public class WarpPanelManagerTest {
int r = wpm.buildMainBody(pb, user, page, world, list);
verify(pb, times(j)).item(any());
if (random && page <= 0) {
verify(user).getTranslation(eq("warps.random"));
verify(user).getTranslation("warps.random");
} else {
verify(user, never()).getTranslation(eq("warps.random"));
verify(user, never()).getTranslation("warps.random");
}
return r;
}

View File

@ -183,7 +183,7 @@ public class WarpSignsManagerTest {
when(block.getRelative(any())).thenReturn(block);
// Handler
when(handler.objectExists(eq("warps"))).thenReturn(true);
when(handler.objectExists("warps")).thenReturn(true);
Map<Location, UUID> warpMap = Collections.singletonMap(location, uuid);
when(load.getWarpSigns()).thenReturn(warpMap);
when(handler.loadObject(anyString())).thenReturn(load);
@ -200,7 +200,7 @@ public class WarpSignsManagerTest {
// Players Manager
when(plugin.getPlayers()).thenReturn(pm);
when(pm.getName(eq(uuid))).thenReturn("tastybento");
when(pm.getName(uuid)).thenReturn("tastybento");
// Offline player
when(server.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
@ -283,7 +283,7 @@ public class WarpSignsManagerTest {
*/
@Test
public void testGetWarpMapNothingInDatabase() {
when(handler.objectExists(eq("warps"))).thenReturn(false);
when(handler.objectExists("warps")).thenReturn(false);
wsm = new WarpSignsManager(addon, plugin);
assertTrue("Map is not empty", wsm.getWarpMap(world).isEmpty());
}
@ -460,7 +460,7 @@ public class WarpSignsManagerTest {
// Save
wsm.saveWarpList();
// Default load in constructor check
verify(addon, times(2)).log(eq("Loading warps..."));
verify(addon, times(2)).log("Loading warps...");
assertTrue(wsm.getWarpMap(world).isEmpty());
}
@ -476,7 +476,7 @@ public class WarpSignsManagerTest {
// Save
wsm.saveWarpList();
// Default load in constructor check
verify(addon, times(2)).log(eq("Loading warps..."));
verify(addon, times(2)).log("Loading warps...");
assertTrue(wsm.getWarpMap(world).isEmpty());
}
}

View File

@ -114,7 +114,7 @@ public class WarpCommandTest {
set.add(UUID.randomUUID());
set.add(UUID.randomUUID());
set.add(UUID.randomUUID());
when(wsm.listWarps(eq(world))).thenReturn(set);
when(wsm.listWarps(world)).thenReturn(set);
// Players Manager
when(plugin.getPlayers()).thenReturn(pm);
@ -179,7 +179,7 @@ public class WarpCommandTest {
public void testExecuteUserStringListOfStringNoArgs() {
warpCommandWarpCompositeCommand();
wc.execute(user, "warp", Collections.emptyList());
verify(user).sendMessage(eq("commands.help.header"), eq(TextVariables.LABEL), eq("BSkyBlock"));
verify(user).sendMessage("commands.help.header", TextVariables.LABEL, "BSkyBlock");
}
/**
@ -189,7 +189,6 @@ public class WarpCommandTest {
public void testExecuteUserStringListOfStringKnownPlayer() {
warpCommandWarpCompositeCommand();
assertTrue(wc.execute(user, "warp", Collections.singletonList("tastybento")));
//verify(wsm).warpPlayer(eq(world), eq(user), any());
}
/**
@ -199,7 +198,6 @@ public class WarpCommandTest {
public void testExecuteUserStringListOfStringKnownPlayerWarp() {
warpCommandWarp();
assertTrue(wc.execute(user, "warp", Collections.singletonList("tastybento")));
//verify(wsm).warpPlayer(eq(world), eq(user), any());
}
/**
@ -209,7 +207,6 @@ public class WarpCommandTest {
public void testExecuteUserStringListOfStringKnownPlayerMixedCase() {
warpCommandWarpCompositeCommand();
assertTrue(wc.execute(user, "warp", Collections.singletonList("tAsTyBEnTo")));
//verify(wsm).warpPlayer(eq(world), eq(user), any());
}
/**
@ -220,7 +217,6 @@ public class WarpCommandTest {
when(pm.getName(any())).thenReturn("tastybento");
warpCommandWarpCompositeCommand();
assertTrue(wc.execute(user, "warp", Collections.singletonList("tAsTy")));
//verify(wsm).warpPlayer(eq(world), eq(user), any());
}
@ -231,7 +227,7 @@ public class WarpCommandTest {
public void testExecuteUserStringListOfStringUnknownPlayer() {
warpCommandWarpCompositeCommand();
assertFalse(wc.execute(user, "warp", Collections.singletonList("LSPVicky")));
verify(user).sendMessage(eq("warps.error.does-not-exist"));
verify(user).sendMessage("warps.error.does-not-exist");
}
/**
@ -242,8 +238,8 @@ public class WarpCommandTest {
when(wsm.listWarps(eq(world))).thenReturn(Collections.emptySet());
warpCommandWarpCompositeCommand();
assertFalse(wc.execute(user, "warp", Collections.singletonList("LSPVicky")));
verify(user).sendMessage(eq("warps.error.no-warps-yet"));
verify(user).sendMessage(eq("warps.warpTip"), eq("[text]"), eq(WELCOME_LINE));
verify(user).sendMessage("warps.error.no-warps-yet");
verify(user).sendMessage("warps.warpTip", "[text]", WELCOME_LINE);
}
/**

View File

@ -98,7 +98,7 @@ public class WarpsCommandTest {
set.add(UUID.randomUUID());
set.add(UUID.randomUUID());
set.add(UUID.randomUUID());
when(wsm.listWarps(eq(world))).thenReturn(set);
when(wsm.listWarps(world)).thenReturn(set);
// Warp Panel Manager
when(addon.getWarpPanelManager()).thenReturn(wpm);
@ -146,8 +146,8 @@ public class WarpsCommandTest {
when(wsm.listWarps(eq(world))).thenReturn(Collections.emptySet());
warpCommandWarpsCompositeCommand();
assertFalse(wc.execute(user, "warps", Collections.emptyList()));
verify(user).sendMessage(eq("warps.error.no-warps-yet"));
verify(user).sendMessage(eq("warps.warpTip"), eq("[text]"), eq(WELCOME_LINE));
verify(user).sendMessage("warps.error.no-warps-yet");
verify(user).sendMessage("warps.warpTip", "[text]", WELCOME_LINE);
}
/**
@ -158,8 +158,8 @@ public class WarpsCommandTest {
when(wsm.listWarps(eq(world))).thenReturn(Collections.emptySet());
warpCommandWarps();
assertFalse(wc.execute(user, "warps", Collections.emptyList()));
verify(user).sendMessage(eq("warps.error.no-warps-yet"));
verify(user).sendMessage(eq("warps.warpTip"), eq("[text]"), eq(WELCOME_LINE));
verify(user).sendMessage("warps.error.no-warps-yet");
verify(user).sendMessage("warps.warpTip", "[text]", WELCOME_LINE);
}
/**

View File

@ -6,6 +6,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@ -116,7 +117,7 @@ public class WarpSignsListenerTest {
UUID uuid = UUID.randomUUID();
when(player.getUniqueId()).thenReturn(uuid);
s = mock(Sign.class);
when(s.getLine(Mockito.anyInt())).thenReturn(ChatColor.GREEN + "[WELCOME]");
when(s.getLine(anyInt())).thenReturn(ChatColor.GREEN + "[WELCOME]");
when(block.getState()).thenReturn(s);
// warp signs manager
when(addon.getWarpSignsManager()).thenReturn(wsm);
@ -127,7 +128,7 @@ public class WarpSignsListenerTest {
when(block.getLocation()).thenReturn(location);
list.put(uuid, location);
// Player is in world
when(wsm.getWarpMap(Mockito.eq(world))).thenReturn(list);
when(wsm.getWarpMap(world)).thenReturn(list);
//Player has a warp sign already here
when(wsm.getWarp(any(), any())).thenReturn(location);
// Unique spot
@ -198,7 +199,7 @@ public class WarpSignsListenerTest {
when(addon.inRegisteredWorld(any())).thenReturn(false);
wsl.onSignBreak(e);
assertFalse(e.isCancelled());
verify(addon).inRegisteredWorld(Mockito.eq(world));
verify(addon).inRegisteredWorld(world);
}
@Test
@ -221,7 +222,7 @@ public class WarpSignsListenerTest {
when(s.getLocation()).thenReturn(mock(Location.class));
wsl.onSignBreak(e);
assertFalse(e.isCancelled());
verify(wsm).getWarpMap(Mockito.eq(world));
verify(wsm).getWarpMap(world);
verify(s).getLocation();
}
@ -281,7 +282,7 @@ public class WarpSignsListenerTest {
SignChangeEvent e = new SignChangeEvent(block, player, lines);
when(addon.inRegisteredWorld(any())).thenReturn(false);
wsl.onSignWarpCreate(e);
verify(addon).inRegisteredWorld(Mockito.eq(world));
verify(addon).inRegisteredWorld(world);
}
@Test