Update tests
This commit is contained in:
parent
3a3c8a320c
commit
1a4077be8c
|
@ -174,15 +174,14 @@ public class LevelTest {
|
||||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Player has island to begin with
|
// Player has island to begin with
|
||||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||||
when(plugin.getIslands()).thenReturn(im);
|
when(plugin.getIslands()).thenReturn(im);
|
||||||
|
|
||||||
// Locales
|
// Locales
|
||||||
// Return the reference (USE THIS IN THE FUTURE)
|
// Return the reference (USE THIS IN THE FUTURE)
|
||||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
when(user.getTranslation(Mockito.anyString()))
|
||||||
|
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
|
@ -196,14 +195,16 @@ public class LevelTest {
|
||||||
File dataFolder = new File("addons/Level");
|
File dataFolder = new File("addons/Level");
|
||||||
addon.setDataFolder(dataFolder);
|
addon.setDataFolder(dataFolder);
|
||||||
addon.setFile(jFile);
|
addon.setFile(jFile);
|
||||||
AddonDescription desc = new AddonDescription.Builder("bentobox", "Level", "1.3").description("test").authors("tastybento").build();
|
AddonDescription desc = new AddonDescription.Builder("bentobox", "Level", "1.3").description("test")
|
||||||
|
.authors("tastybento").build();
|
||||||
addon.setDescription(desc);
|
addon.setDescription(desc);
|
||||||
addon.setSettings(new ConfigSettings());
|
addon.setSettings(new ConfigSettings());
|
||||||
// Addons manager
|
// Addons manager
|
||||||
when(plugin.getAddonsManager()).thenReturn(am);
|
when(plugin.getAddonsManager()).thenReturn(am);
|
||||||
// One game mode
|
// One game mode
|
||||||
when(am.getGameModeAddons()).thenReturn(Collections.singletonList(gameMode));
|
when(am.getGameModeAddons()).thenReturn(Collections.singletonList(gameMode));
|
||||||
AddonDescription desc2 = new AddonDescription.Builder("bentobox", "BSkyBlock", "1.3").description("test").authors("tasty").build();
|
AddonDescription desc2 = new AddonDescription.Builder("bentobox", "BSkyBlock", "1.3").description("test")
|
||||||
|
.authors("tasty").build();
|
||||||
when(gameMode.getDescription()).thenReturn(desc2);
|
when(gameMode.getDescription()).thenReturn(desc2);
|
||||||
when(gameMode.getOverWorld()).thenReturn(world);
|
when(gameMode.getOverWorld()).thenReturn(world);
|
||||||
|
|
||||||
|
@ -219,7 +220,6 @@ public class LevelTest {
|
||||||
when(plugin.getFlagsManager()).thenReturn(fm);
|
when(plugin.getFlagsManager()).thenReturn(fm);
|
||||||
when(fm.getFlags()).thenReturn(Collections.emptyList());
|
when(fm.getFlags()).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
|
|
||||||
// Bukkit
|
// Bukkit
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||||
|
@ -260,10 +260,7 @@ public class LevelTest {
|
||||||
|
|
||||||
private static void deleteAll(File file) throws IOException {
|
private static void deleteAll(File file) throws IOException {
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
Files.walk(file.toPath())
|
Files.walk(file.toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||||
.sorted(Comparator.reverseOrder())
|
|
||||||
.map(Path::toFile)
|
|
||||||
.forEach(File::delete);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +273,7 @@ public class LevelTest {
|
||||||
verify(plugin).logWarning("[Level] Level Addon: No such world in blockconfig.yml : acidisland_world");
|
verify(plugin).logWarning("[Level] Level Addon: No such world in blockconfig.yml : acidisland_world");
|
||||||
verify(plugin).log("[Level] Level hooking into BSkyBlock");
|
verify(plugin).log("[Level] Level hooking into BSkyBlock");
|
||||||
verify(cmd, times(3)).getAddon(); // 3 commands
|
verify(cmd, times(3)).getAddon(); // 3 commands
|
||||||
verify(adminCmd, times(4)).getAddon(); // Four commands
|
verify(adminCmd, times(5)).getAddon(); // Five commands
|
||||||
// Placeholders
|
// Placeholders
|
||||||
verify(phm).registerPlaceholder(eq(addon), eq("bskyblock_island_level"), any());
|
verify(phm).registerPlaceholder(eq(addon), eq("bskyblock_island_level"), any());
|
||||||
verify(phm).registerPlaceholder(eq(addon), eq("bskyblock_visited_island_level"), any());
|
verify(phm).registerPlaceholder(eq(addon), eq("bskyblock_visited_island_level"), any());
|
||||||
|
|
Loading…
Reference in New Issue