Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 2, 2024
1 parent 5d74dda commit 30bd435
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.4.0-SNAPSHOT</bentobox.version>
<bentobox.version>2.4.1-SNAPSHOT</bentobox.version>
<level.version>2.6.2</level.version>
<bank.version>1.3.0</bank.version>
<!-- Revision variable removes warning about dynamic version -->
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/world/bentobox/aoneblock/AOneBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private void deleteAll(File file) throws IOException {
*/
@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
// Set up plugin
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger());
Expand Down Expand Up @@ -171,7 +172,6 @@ public void setUp() throws Exception {
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));

// Server
PowerMockito.mockStatic(Bukkit.class);
Server server = mock(Server.class);
when(Bukkit.getServer()).thenReturn(server);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private void deleteAll(File file) throws IOException {
*/
@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
// Set up plugin
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.UUID;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
Expand All @@ -19,6 +20,8 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import world.bentobox.aoneblock.AOneBlock;
Expand All @@ -31,12 +34,14 @@
import world.bentobox.bentobox.managers.IslandsManager;
import world.bentobox.bentobox.managers.LocalesManager;
import world.bentobox.bentobox.managers.PlaceholdersManager;
import world.bentobox.bentobox.util.Util;

/**
* @author tastybento
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ Bukkit.class, Util.class })
public class InfoListenerTest {
@Mock
private BentoBox plugin;
Expand Down Expand Up @@ -72,6 +77,7 @@ public class InfoListenerTest {
*/
@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
when(addon.getPlugin()).thenReturn(plugin);
when(plugin.getLocalesManager()).thenReturn(lm);
when(lm.get(toString())).thenAnswer(invocation -> invocation.getArgument(0, String.class));
Expand Down

0 comments on commit 30bd435

Please sign in to comment.