|
42 | 42 | import org.junit.jupiter.api.AfterEach; |
43 | 43 | import org.junit.jupiter.api.BeforeEach; |
44 | 44 | import org.junit.jupiter.api.Test; |
| 45 | +import org.mockbukkit.mockbukkit.MockBukkit; |
45 | 46 | import org.mockito.Mock; |
46 | 47 | import org.mockito.MockedStatic; |
47 | 48 | import org.mockito.Mockito; |
48 | 49 | import org.mockito.MockitoAnnotations; |
49 | 50 | import org.mockito.stubbing.Answer; |
50 | 51 |
|
| 52 | +import world.bentobox.challenges.panel.PanelTestHelper; |
| 53 | + |
51 | 54 | import world.bentobox.bentobox.BentoBox; |
52 | 55 | import world.bentobox.bentobox.Settings; |
53 | 56 | import world.bentobox.bentobox.api.addons.Addon; |
@@ -101,6 +104,15 @@ public class ChallengesAddonTest { |
101 | 104 | @BeforeEach |
102 | 105 | public void setUp() throws Exception { |
103 | 106 | closeable = MockitoAnnotations.openMocks(this); |
| 107 | + // Force Bukkit's Tag.<clinit> to run against a real MockBukkit ServerMock before |
| 108 | + // we install the Mockito static mock below. Without this, Tag.<clinit> can later |
| 109 | + // fire while Bukkit is statically mocked, permanently null-ing every Tag constant |
| 110 | + // for the JVM and corrupting any subsequent test that creates an ItemStack |
| 111 | + // (e.g. CommonPagedPanelTest -> ItemType.<clinit> -> MaterialTags.<clinit> -> |
| 112 | + // Objects.requireNonNull(Tag.ALL_SIGNS) -> NPE). |
| 113 | + MockBukkit.mock(); |
| 114 | + PanelTestHelper.primeBukkitRegistry(); |
| 115 | + MockBukkit.unmock(); |
104 | 116 | // Set up plugin |
105 | 117 | WhiteBox.setInternalState(BentoBox.class, "instance", plugin); |
106 | 118 | when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger()); |
|
0 commit comments