Fix tests

This commit is contained in:
tastybento 2024-08-22 19:15:44 -07:00
parent 8e3f368602
commit 8d75bc697b
10 changed files with 13 additions and 4 deletions

View File

@ -527,9 +527,10 @@ public class User implements MetaDataAble {
// Replace game mode and friendly name in general
// Replace the [gamemode] text variable
translation = translation.replace("[gamemode]",
addon != null ? addon.getDescription().getName() : "[gamemode]");
if (getWorld() != null) {
if (addon != null && addon.getDescription() != null) {
translation = translation.replace("[gamemode]", addon.getDescription().getName());
}
if (player != null && player.getWorld() != null) {
// Replace the [friendly_name] text variable
translation = translation.replace("[friendly_name]",
isPlayer() ? plugin.getIWM().getFriendlyName(getWorld()) : "[friendly_name]");

View File

@ -127,6 +127,7 @@ public class IslandSpawnCommandTest {
when(plugin.getSettings()).thenReturn(s);
// IWM
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
when(plugin.getIWM()).thenReturn(iwm);
when(iwm.getWorldSettings(any())).thenReturn(ws);
map = new HashMap<>();

View File

@ -120,6 +120,7 @@ public class IslandTeamLeaveCommandTest {
when(Bukkit.getScheduler()).thenReturn(sch);
// Island World Manager
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
when(plugin.getIWM()).thenReturn(iwm);
// Plugin Manager

View File

@ -935,7 +935,7 @@ public class UserTest {
when(addon.getDescription()).thenReturn(new Builder("main", "gameAddon", "1.0").build());
p.setAddon(addon);
p.getTranslation(TEST_TRANSLATION);
verify(addon, times(2)).getDescription();
verify(addon, times(3)).getDescription();
}
/**

View File

@ -77,6 +77,7 @@ public class BannedCommandsTest {
when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock.");
when(iwm.getVisitorBannedCommands(any())).thenReturn(new ArrayList<>());
when(iwm.getFallingBannedCommands(any())).thenReturn(new ArrayList<>());
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
WorldSettings ws = new MyWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(ws);
when(plugin.getIWM()).thenReturn(iwm);

View File

@ -134,6 +134,7 @@ public class JoinLeaveListenerTest {
when(iwm.getAddon(any())).thenReturn(opGm);
when(gameMode.getPermissionPrefix()).thenReturn("acidisland.");
when(iwm.getIslandDistance(any())).thenReturn(100);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
UUID uuid = UUID.randomUUID();
// Player

View File

@ -110,6 +110,7 @@ public class StandardSpawnProtectionListenerTest extends AbstractCommonSetup {
when(iwm.inWorld(any(World.class))).thenReturn(true);
when(iwm.getNetherSpawnRadius(any())).thenReturn(25);
when(iwm.getWorldSettings(any())).thenReturn(ws);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
// Util
PowerMockito.mockStatic(Util.class);
when(Util.getWorld(any())).thenReturn(world);

View File

@ -138,6 +138,7 @@ public abstract class AbstractCommonSetup {
when(plugin.getIWM()).thenReturn(iwm);
when(iwm.inWorld(any(Location.class))).thenReturn(true);
when(iwm.inWorld(any(World.class))).thenReturn(true);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
// Addon
when(iwm.getAddon(any())).thenReturn(Optional.empty());

View File

@ -136,6 +136,7 @@ public class PVPListenerTest {
when(iwm.inWorld(any(World.class))).thenReturn(true);
when(iwm.inWorld(any(Location.class))).thenReturn(true);
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock.");
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
// No visitor protection right now
when(iwm.getIvSettings(any())).thenReturn(new ArrayList<>());
when(plugin.getIWM()).thenReturn(iwm);

View File

@ -114,6 +114,7 @@ public class ObsidianScoopingListenerTest {
when(iwm.getIslandWorld(Mockito.any())).thenReturn(world);
when(iwm.getNetherWorld(Mockito.any())).thenReturn(world);
when(iwm.getEndWorld(Mockito.any())).thenReturn(world);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
// Mock up IslandsManager
when(plugin.getIslands()).thenReturn(im);