mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 18:55:17 +01:00
Fix placeholders manager test
This commit is contained in:
parent
2c75939bc3
commit
5834dcbb59
@ -18,10 +18,14 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
|
import world.bentobox.bentobox.Settings;
|
||||||
|
import world.bentobox.bentobox.TestWorldSettings;
|
||||||
import world.bentobox.bentobox.api.addons.AddonDescription;
|
import world.bentobox.bentobox.api.addons.AddonDescription;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||||
import world.bentobox.bentobox.api.hooks.Hook;
|
import world.bentobox.bentobox.api.hooks.Hook;
|
||||||
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
||||||
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
||||||
@ -43,9 +47,17 @@ public class PlaceholdersManagerTest {
|
|||||||
private HooksManager hm;
|
private HooksManager hm;
|
||||||
@Mock
|
@Mock
|
||||||
private PlaceholderAPIHook hook;
|
private PlaceholderAPIHook hook;
|
||||||
|
@Mock
|
||||||
|
private IslandWorldManager iwm;
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
// Set up plugin
|
||||||
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
settings = new Settings();
|
||||||
|
when(plugin.getSettings()).thenReturn(settings);
|
||||||
|
|
||||||
// Addon
|
// Addon
|
||||||
@NonNull
|
@NonNull
|
||||||
AddonDescription desc = new AddonDescription.Builder("main", "bskyblock", "1.0").build();
|
AddonDescription desc = new AddonDescription.Builder("main", "bskyblock", "1.0").build();
|
||||||
@ -61,6 +73,13 @@ public class PlaceholdersManagerTest {
|
|||||||
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
||||||
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
||||||
|
|
||||||
|
// World settings
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
WorldSettings ws = new TestWorldSettings();
|
||||||
|
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||||
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
// Placeholder manager
|
// Placeholder manager
|
||||||
pm = new PlaceholdersManager(plugin);
|
pm = new PlaceholdersManager(plugin);
|
||||||
}
|
}
|
||||||
@ -77,7 +96,7 @@ public class PlaceholdersManagerTest {
|
|||||||
public void testRegisterGameModePlaceholdersAllDefaults() {
|
public void testRegisterGameModePlaceholdersAllDefaults() {
|
||||||
pm.registerDefaultPlaceholders(addon);
|
pm.registerDefaultPlaceholders(addon);
|
||||||
// + 300 because we register team member placeholders up to 50 members
|
// + 300 because we register team member placeholders up to 50 members
|
||||||
verify(hook, times(GameModePlaceholder.values().length + 302)).registerPlaceholder(any(), anyString(), any());
|
verify(hook, times(GameModePlaceholder.values().length + 304)).registerPlaceholder(any(), anyString(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +110,7 @@ public class PlaceholdersManagerTest {
|
|||||||
pm.registerDefaultPlaceholders(addon);
|
pm.registerDefaultPlaceholders(addon);
|
||||||
|
|
||||||
// 3 less registrations for this addon
|
// 3 less registrations for this addon
|
||||||
verify(hook, times(GameModePlaceholder.values().length - 3 + 302)).registerPlaceholder(any(), anyString(),
|
verify(hook, times(GameModePlaceholder.values().length - 3 + 304)).registerPlaceholder(any(), anyString(),
|
||||||
any());
|
any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user