|
2 | 2 |
|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
4 | 4 | import static org.mockito.ArgumentMatchers.any; |
| 5 | +import static org.mockito.Mockito.never; |
5 | 6 | import static org.mockito.Mockito.verify; |
6 | 7 | import static org.mockito.Mockito.when; |
7 | 8 |
|
8 | 9 | import org.bukkit.Bukkit; |
| 10 | +import org.bukkit.World.Environment; |
9 | 11 | import org.bukkit.WorldBorder; |
10 | 12 | import org.bukkit.entity.Player; |
11 | 13 | import org.bukkit.util.Vector; |
@@ -123,4 +125,39 @@ public void testHideBorder() { |
123 | 125 | verify(mockPlayer).setWorldBorder(null); |
124 | 126 | } |
125 | 127 |
|
| 128 | + /** |
| 129 | + * Test method for {@link world.bentobox.border.listeners.ShowVirtualWorldBorder#showBorder(org.bukkit.entity.Player, world.bentobox.bentobox.database.objects.Island)}. |
| 130 | + * Tests that border is shown when player is in an island nether world. |
| 131 | + */ |
| 132 | + @Test |
| 133 | + public void testShowBorderInIslandNetherWorld() { |
| 134 | + // Setup: Player is in a nether environment that IS an island nether world |
| 135 | + when(world.getEnvironment()).thenReturn(Environment.NETHER); |
| 136 | + when(iwm.isIslandNether(world)).thenReturn(true); |
| 137 | + when(addon.getPlugin()).thenReturn(plugin); |
| 138 | + |
| 139 | + svwb.showBorder(mockPlayer, island); |
| 140 | + |
| 141 | + // Verify that the border was set (border should show in island nether worlds) |
| 142 | + verify(mockPlayer).setWorldBorder(wb); |
| 143 | + verify(wb).setSize(200.0D); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Test method for {@link world.bentobox.border.listeners.ShowVirtualWorldBorder#showBorder(org.bukkit.entity.Player, world.bentobox.bentobox.database.objects.Island)}. |
| 148 | + * Tests that border is NOT shown when player is in a non-island nether world. |
| 149 | + */ |
| 150 | + @Test |
| 151 | + public void testShowBorderInNonIslandNetherWorld() { |
| 152 | + // Setup: Player is in a nether environment that is NOT an island nether world |
| 153 | + when(world.getEnvironment()).thenReturn(Environment.NETHER); |
| 154 | + when(iwm.isIslandNether(world)).thenReturn(false); |
| 155 | + when(addon.getPlugin()).thenReturn(plugin); |
| 156 | + |
| 157 | + svwb.showBorder(mockPlayer, island); |
| 158 | + |
| 159 | + // Verify that the border was NOT set (border should not show in non-island nether worlds) |
| 160 | + verify(mockPlayer, never()).setWorldBorder(any()); |
| 161 | + } |
| 162 | + |
126 | 163 | } |
0 commit comments