Test clean up.

Due to changes in the PAPI API code, the current tests don't run and are
ignored.
This commit is contained in:
tastybento 2021-01-17 11:31:40 -08:00
parent c62221efb8
commit 942c1ff3b3
5 changed files with 19 additions and 16 deletions

View File

@ -257,7 +257,6 @@ public class FlagTest {
/**
* Test method for {@link world.bentobox.bentobox.api.flags.Flag#equals(java.lang.Object)}.
*/
@SuppressWarnings("unlikely-arg-type")
@Test
public void testEqualsObject() {
Flag flag1 = null;

View File

@ -452,7 +452,6 @@ public class UserTest {
verify(player).performCommand("test");
}
@SuppressWarnings("unlikely-arg-type")
@Test
public void testEqualsObject() {
User user1 = User.getInstance(UUID.randomUUID());

View File

@ -1,10 +1,6 @@
/**
*
*/
package world.bentobox.bentobox.database.objects.adapters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.LinkedList;

View File

@ -13,6 +13,7 @@ import static org.mockito.Mockito.when;
import java.util.Optional;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.junit.Before;
import org.junit.Ignore;
@ -27,6 +28,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.AddonDescription;
@ -41,7 +43,6 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({BentoBox.class, PlaceholderAPI.class, Bukkit.class })
@Ignore("Issues with mocking.")
public class PlaceholderAPIHookTest {
// Class under test
@ -57,18 +58,23 @@ public class PlaceholderAPIHookTest {
@Mock
private GameModeAddon gma;
PlaceholderAPIPlugin papi;
@Mock
private Server server;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// Bukkit
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
// Set up plugin
plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
when(plugin.getIWM()).thenReturn(iwm);
when(iwm.getAddon(any())).thenReturn(Optional.of(gma));
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
// Desc
AddonDescription desc = new AddonDescription.Builder("main", "name", "1.0").build();
when(addon.getDescription()).thenReturn(desc);
@ -104,7 +110,8 @@ public class PlaceholderAPIHookTest {
* Test method for {@link world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook#registerPlaceholder(world.bentobox.bentobox.api.addons.Addon, java.lang.String, world.bentobox.bentobox.api.placeholders.PlaceholderReplacer)}.
*/
@Test
public void testRegisterPlaceholderAddonStringPlaceholderReplacer() {
@Ignore("New version of PAPI breaks test")
public void testRegisterPlaceholderAddonStringPlaceholderReplacer() {
PlaceholderReplacer replacer = mock(PlaceholderReplacer.class);
pah.registerPlaceholder(addon, "testing.placeholder", replacer);
assertTrue(pah.isPlaceholder(addon, "testing.placeholder"));
@ -114,6 +121,7 @@ public class PlaceholderAPIHookTest {
* Test method for {@link world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook#unregisterPlaceholder(java.lang.String)}.
*/
@Test
@Ignore("New version of PAPI breaks test")
public void testUnregisterPlaceholderString() {
testRegisterPlaceholderAddonStringPlaceholderReplacer();
pah.unregisterPlaceholder("testing.placeholder");
@ -125,6 +133,7 @@ public class PlaceholderAPIHookTest {
* Test method for {@link world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook#unregisterPlaceholder(world.bentobox.bentobox.api.addons.Addon, java.lang.String)}.
*/
@Test
@Ignore("New version of PAPI breaks test")
public void testUnregisterPlaceholderAddonString() {
testRegisterPlaceholderAddonStringPlaceholderReplacer();
pah.unregisterPlaceholder(addon, "testing.placeholder");
@ -135,6 +144,7 @@ public class PlaceholderAPIHookTest {
* Test method for {@link world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook#isPlaceholder(world.bentobox.bentobox.api.addons.Addon, java.lang.String)}.
*/
@Test
@Ignore("New version of PAPI breaks test")
public void testIsPlaceholder() {
testRegisterPlaceholderAddonStringPlaceholderReplacer();
assertFalse(pah.isPlaceholder(addon, "not.a.placeholder"));
@ -145,19 +155,19 @@ public class PlaceholderAPIHookTest {
*/
@Test
public void testReplacePlaceholders() {
assertEquals("This is a %test.name.level% test, with %placeholders%, and %name%",
pah.replacePlaceholders(mock(Player.class), "This is a %test.[gamemode].level% test, with %placeholders%, and %[gamemode]%"));
assertEquals("This is a %test.name.level% test, with %placeholders%, and %name%",
pah.replacePlaceholders(mock(Player.class), "This is a %test.[gamemode].level% test, with %placeholders%, and %[gamemode]%"));
}
/**
* Test method for {@link world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook#replacePlaceholders(org.bukkit.entity.Player, java.lang.String)}.
*/
@Test
public void testReplacePlaceholdersNonGameWorld() {
when(iwm.getAddon(any())).thenReturn(Optional.empty());
assertEquals("This is a test, with %placeholders%, and ",
pah.replacePlaceholders(mock(Player.class), "This is a %test.[gamemode].level% test, with %placeholders%, and %[gamemode]%"));
assertEquals("This is a test, with %placeholders%, and ",
pah.replacePlaceholders(mock(Player.class), "This is a %test.[gamemode].level% test, with %placeholders%, and %[gamemode]%"));
}
}

View File

@ -1,7 +1,6 @@
package world.bentobox.bentobox.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;