Skip to content

Commit

Permalink
Added test case to FlagTest
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Aug 8, 2019
1 parent d4814a6 commit 1e04e48
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/test/java/world/bentobox/bentobox/api/flags/FlagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,24 @@ public class FlagTest {
@Mock
private World world;
private Map<String, Boolean> worldFlags;
@Mock
private IslandWorldManager iwm;
@Mock
private BentoBox plugin;

/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// Set up plugin
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);

PowerMockito.mockStatic(Util.class);
// Return world
when(Util.getWorld(Mockito.any())).thenAnswer((Answer<World>) invocation -> invocation.getArgument(0, World.class));

// World Settings
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(plugin.getIWM()).thenReturn(iwm);
WorldSettings ws = mock(WorldSettings.class);
when(iwm.getWorldSettings(any())).thenReturn(ws);
Expand Down Expand Up @@ -217,6 +219,16 @@ public void testSetDefaultSettingWorldBoolean() {
assertFalse(f.isSetForWorld(world));
}

/**
* Test method for {@link world.bentobox.bentobox.api.flags.Flag#setDefaultSetting(org.bukkit.World, boolean)}.
*/
@Test
public void testSetDefaultSettingWorldBooleanNullWorldSettings() {
when(iwm.getWorldSettings(any())).thenReturn(null);
f.setDefaultSetting(world, true);
verify(plugin).logError("Attempt to set default world setting for unregistered world. Register flags in onEnable.");
}

/**
* Test method for {@link world.bentobox.bentobox.api.flags.Flag#getType()}.
*/
Expand Down Expand Up @@ -391,4 +403,5 @@ public void testCompareTo() {
assertTrue(aaa.compareTo(aaa) == 0);
}


}

0 comments on commit 1e04e48

Please sign in to comment.