Skip to content

Commit b4db0ab

Browse files
tastybentoclaude
andcommitted
Remove unnecessary public modifiers from JUnit 5 test methods
JUnit 5 does not require public visibility on test, setup, or teardown methods. Removes public from all void method declarations across 12 test classes to address SonarCloud warnings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7323b89 commit b4db0ab

12 files changed

Lines changed: 336 additions & 336 deletions

src/test/java/world/bentobox/acidisland/AISettingsTest.java

Lines changed: 196 additions & 196 deletions
Large diffs are not rendered by default.

src/test/java/world/bentobox/acidisland/AcidIslandTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class AcidIslandTest {
9999

100100
@SuppressWarnings("unchecked")
101101
@BeforeAll
102-
public static void beforeAll() throws Exception {
102+
static void beforeAll() throws Exception {
103103
// This has to be done beforeAll otherwise the tests will interfere with each other
104104
h = mock(AbstractDatabaseHandler.class);
105105
// Database
@@ -111,12 +111,12 @@ public static void beforeAll() throws Exception {
111111
}
112112

113113
@AfterAll
114-
public static void afterAll() {
114+
static void afterAll() {
115115
mockedDbSetup.close();
116116
}
117117

118118
@AfterEach
119-
public void tearDown() throws IOException {
119+
void tearDown() throws IOException {
120120
User.clearUsers();
121121
if (mockedBukkit != null) {
122122
mockedBukkit.closeOnDemand();
@@ -136,7 +136,7 @@ private void deleteAll(File file) throws IOException {
136136
}
137137

138138
@BeforeEach
139-
public void setUp() throws Exception {
139+
void setUp() throws Exception {
140140
// Set up plugin via reflection
141141
Field instanceField = BentoBox.class.getDeclaredField("instance");
142142
instanceField.setAccessible(true);
@@ -221,7 +221,7 @@ public void setUp() throws Exception {
221221
* Test method for {@link world.bentobox.acidisland.AcidIsland#onLoad()}.
222222
*/
223223
@Test
224-
public void testOnLoad() {
224+
void testOnLoad() {
225225
addon.onLoad();
226226
// Check that config.yml file has been saved
227227
File check = new File("addons/AcidIsland", "config.yml");
@@ -232,7 +232,7 @@ public void testOnLoad() {
232232
* Test method for {@link world.bentobox.acidisland.AcidIsland#onEnable()}.
233233
*/
234234
@Test
235-
public void testOnEnable() {
235+
void testOnEnable() {
236236
testOnLoad();
237237
addon.onEnable();
238238
assertTrue(addon.getPlayerCommand().isPresent());
@@ -243,7 +243,7 @@ public void testOnEnable() {
243243
* Test method for {@link world.bentobox.acidisland.AcidIsland#onReload()}.
244244
*/
245245
@Test
246-
public void testOnReload() {
246+
void testOnReload() {
247247
addon.onReload();
248248
// Check that config.yml file has been saved
249249
File check = new File("addons/AcidIsland", "config.yml");
@@ -254,7 +254,7 @@ public void testOnReload() {
254254
* Test method for {@link world.bentobox.acidisland.AcidIsland#createWorlds()}.
255255
*/
256256
@Test
257-
public void testCreateWorlds() {
257+
void testCreateWorlds() {
258258
addon.onLoad();
259259
addon.createWorlds();
260260
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland...");
@@ -266,7 +266,7 @@ public void testCreateWorlds() {
266266
* Test method for {@link world.bentobox.acidisland.AcidIsland#getSettings()}.
267267
*/
268268
@Test
269-
public void testGetSettings() {
269+
void testGetSettings() {
270270
addon.onLoad();
271271
assertNotNull(addon.getSettings());
272272
}
@@ -275,7 +275,7 @@ public void testGetSettings() {
275275
* Test method for {@link world.bentobox.acidisland.AcidIsland#getWorldSettings()}.
276276
*/
277277
@Test
278-
public void testGetWorldSettings() {
278+
void testGetWorldSettings() {
279279
addon.onLoad();
280280
assertEquals(addon.getSettings(), addon.getWorldSettings());
281281
}
@@ -284,7 +284,7 @@ public void testGetWorldSettings() {
284284
* Test method for {@link world.bentobox.acidisland.AcidIsland#getDefaultWorldGenerator(java.lang.String, java.lang.String)}.
285285
*/
286286
@Test
287-
public void testGetDefaultWorldGeneratorStringString() {
287+
void testGetDefaultWorldGeneratorStringString() {
288288
assertNull(addon.getDefaultWorldGenerator("", ""));
289289
addon.onLoad();
290290
addon.createWorlds();
@@ -296,23 +296,23 @@ public void testGetDefaultWorldGeneratorStringString() {
296296
* Test method for {@link world.bentobox.acidisland.AcidIsland#allLoaded()}.
297297
*/
298298
@Test
299-
public void testAllLoaded() {
299+
void testAllLoaded() {
300300
addon.allLoaded();
301301
}
302302

303303
/**
304304
* Test method for {@link world.bentobox.acidisland.AcidIsland#saveWorldSettings()}.
305305
*/
306306
@Test
307-
public void testSaveWorldSettings() {
307+
void testSaveWorldSettings() {
308308
addon.saveWorldSettings();
309309
}
310310

311311
/**
312312
* Test onDisable cancels acidTask.
313313
*/
314314
@Test
315-
public void testOnDisable() {
315+
void testOnDisable() {
316316
testOnEnable();
317317
addon.onDisable();
318318
// Should not throw - acidTask.cancelTasks() is called
@@ -322,7 +322,7 @@ public void testOnDisable() {
322322
* Test onDisable when acidTask is null (no prior onEnable).
323323
*/
324324
@Test
325-
public void testOnDisableNoTask() {
325+
void testOnDisableNoTask() {
326326
// No onEnable called, acidTask is null
327327
addon.onDisable();
328328
// Should not throw
@@ -332,7 +332,7 @@ public void testOnDisableNoTask() {
332332
* Test onEnable does nothing when settings is null.
333333
*/
334334
@Test
335-
public void testOnEnableNullSettings() {
335+
void testOnEnableNullSettings() {
336336
// Don't call onLoad, so settings is null
337337
addon.onEnable();
338338
// Should return early without registering listeners

src/test/java/world/bentobox/acidisland/commands/IslandAboutCommandTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class IslandAboutCommandTest {
4848
private IslandAboutCommand command;
4949

5050
@BeforeEach
51-
public void setUp() {
51+
void setUp() {
5252
server = MockBukkit.mock();
5353
mockedBukkit = Mockito.mockStatic(Bukkit.class, Mockito.RETURNS_DEEP_STUBS);
5454
mockedBukkit.when(Bukkit::getMinecraftVersion).thenReturn("1.21.11");
@@ -71,14 +71,14 @@ public void setUp() {
7171
}
7272

7373
@AfterEach
74-
public void tearDown() {
74+
void tearDown() {
7575
mockedBukkit.closeOnDemand();
7676
Mockito.framework().clearInlineMocks();
7777
MockBukkit.unmock();
7878
}
7979

8080
@Test
81-
public void testExecute() {
81+
void testExecute() {
8282
boolean result = command.execute(user, "about", Collections.emptyList());
8383
assertTrue(result);
8484
verify(user, atLeastOnce()).sendRawMessage(anyString());

src/test/java/world/bentobox/acidisland/events/AcidEventTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,62 +25,62 @@ public class AcidEventTest {
2525
private AcidEvent e;
2626

2727
@BeforeEach
28-
public void setUp() {
28+
void setUp() {
2929
List<PotionEffectType> effects = List.of();
3030
e = new AcidEvent(player, 10, 5, effects);
3131
}
3232

3333
@Test
34-
public void testAcidEvent() {
34+
void testAcidEvent() {
3535
assertNotNull(e);
3636
}
3737

3838
@Test
39-
public void testGetPlayer() {
39+
void testGetPlayer() {
4040
assertEquals(player, e.getPlayer());
4141
}
4242

4343
@Test
44-
public void testSetPlayer() {
44+
void testSetPlayer() {
4545
Player player2 = mock(Player.class);
4646
e.setPlayer(player2);
4747
assertEquals(player2, e.getPlayer());
4848
}
4949

5050
@Test
51-
public void testGetTotalDamage() {
51+
void testGetTotalDamage() {
5252
assertEquals(10D, e.getTotalDamage(), 0D);
5353
}
5454

5555
@Test
56-
public void testGetProtection() {
56+
void testGetProtection() {
5757
assertEquals(5D, e.getProtection(), 0D);
5858
}
5959

6060
@Test
61-
public void testSetTotalDamage() {
61+
void testSetTotalDamage() {
6262
e.setTotalDamage(50);
6363
assertEquals(50D, e.getTotalDamage(), 0D);
6464
}
6565

6666
@Test
67-
public void testGetPotionEffects() {
67+
void testGetPotionEffects() {
6868
assertEquals(0, e.getPotionEffects().toArray().length);
6969
}
7070

7171
@Test
72-
public void testSetPotionEffects() {
72+
void testSetPotionEffects() {
7373
e.setPotionEffects(new ArrayList<>());
7474
assertTrue(e.getPotionEffects().isEmpty());
7575
}
7676

7777
@Test
78-
public void testIsCancelled() {
78+
void testIsCancelled() {
7979
assertFalse(e.isCancelled());
8080
}
8181

8282
@Test
83-
public void testSetCancelled() {
83+
void testSetCancelled() {
8484
e.setCancelled(true);
8585
assertTrue(e.isCancelled());
8686
e.setCancelled(false);

src/test/java/world/bentobox/acidisland/events/AcidRainEventTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,62 +25,62 @@ public class AcidRainEventTest {
2525
private AcidRainEvent e;
2626

2727
@BeforeEach
28-
public void setUp() {
28+
void setUp() {
2929
List<PotionEffectType> effects = List.of();
3030
e = new AcidRainEvent(player, 10, 5, effects);
3131
}
3232

3333
@Test
34-
public void testAcidEvent() {
34+
void testAcidEvent() {
3535
assertNotNull(e);
3636
}
3737

3838
@Test
39-
public void testGetPlayer() {
39+
void testGetPlayer() {
4040
assertEquals(player, e.getPlayer());
4141
}
4242

4343
@Test
44-
public void testSetPlayer() {
44+
void testSetPlayer() {
4545
Player player2 = mock(Player.class);
4646
e.setPlayer(player2);
4747
assertEquals(player2, e.getPlayer());
4848
}
4949

5050
@Test
51-
public void testGetTotalDamage() {
51+
void testGetTotalDamage() {
5252
assertTrue(e.getRainDamage() == 10D);
5353
}
5454

5555
@Test
56-
public void testGetProtection() {
56+
void testGetProtection() {
5757
assertTrue(e.getProtection() == 5D);
5858
}
5959

6060
@Test
61-
public void testSetTotalDamage() {
61+
void testSetTotalDamage() {
6262
e.setRainDamage(50);
6363
assertTrue(e.getRainDamage() == 50D);
6464
}
6565

6666
@Test
67-
public void testGetPotionEffects() {
67+
void testGetPotionEffects() {
6868
assertEquals(0, e.getPotionEffects().toArray().length);
6969
}
7070

7171
@Test
72-
public void testSetPotionEffects() {
72+
void testSetPotionEffects() {
7373
e.setPotionEffects(new ArrayList<>());
7474
assertTrue(e.getPotionEffects().isEmpty());
7575
}
7676

7777
@Test
78-
public void testIsCancelled() {
78+
void testIsCancelled() {
7979
assertFalse(e.isCancelled());
8080
}
8181

8282
@Test
83-
public void testSetCancelled() {
83+
void testSetCancelled() {
8484
e.setCancelled(true);
8585
assertTrue(e.isCancelled());
8686
e.setCancelled(false);

src/test/java/world/bentobox/acidisland/events/EntityDamageByAcidEventTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,64 +23,64 @@ public class EntityDamageByAcidEventTest {
2323
private EntityDamageByAcidEvent rainEvent;
2424

2525
@BeforeEach
26-
public void setUp() {
26+
void setUp() {
2727
waterEvent = new EntityDamageByAcidEvent(entity, 10.0, Acid.WATER);
2828
rainEvent = new EntityDamageByAcidEvent(entity, 5.0, Acid.RAIN);
2929
}
3030

3131
@Test
32-
public void testConstructor() {
32+
void testConstructor() {
3333
assertNotNull(waterEvent);
3434
assertNotNull(rainEvent);
3535
}
3636

3737
@Test
38-
public void testGetEntity() {
38+
void testGetEntity() {
3939
assertEquals(entity, waterEvent.getEntity());
4040
}
4141

4242
@Test
43-
public void testGetDamage() {
43+
void testGetDamage() {
4444
assertEquals(10.0, waterEvent.getDamage(), 0D);
4545
assertEquals(5.0, rainEvent.getDamage(), 0D);
4646
}
4747

4848
@Test
49-
public void testSetDamage() {
49+
void testSetDamage() {
5050
waterEvent.setDamage(25.0);
5151
assertEquals(25.0, waterEvent.getDamage(), 0D);
5252
}
5353

5454
@Test
55-
public void testGetCauseWater() {
55+
void testGetCauseWater() {
5656
assertEquals(Acid.WATER, waterEvent.getCause());
5757
}
5858

5959
@Test
60-
public void testGetCauseRain() {
60+
void testGetCauseRain() {
6161
assertEquals(Acid.RAIN, rainEvent.getCause());
6262
}
6363

6464
@Test
65-
public void testIsCancelled() {
65+
void testIsCancelled() {
6666
assertFalse(waterEvent.isCancelled());
6767
}
6868

6969
@Test
70-
public void testSetCancelled() {
70+
void testSetCancelled() {
7171
waterEvent.setCancelled(true);
7272
assertTrue(waterEvent.isCancelled());
7373
waterEvent.setCancelled(false);
7474
assertFalse(waterEvent.isCancelled());
7575
}
7676

7777
@Test
78-
public void testGetHandlers() {
78+
void testGetHandlers() {
7979
assertNotNull(waterEvent.getHandlers());
8080
}
8181

8282
@Test
83-
public void testGetHandlerList() {
83+
void testGetHandlerList() {
8484
assertNotNull(EntityDamageByAcidEvent.getHandlerList());
8585
}
8686
}

0 commit comments

Comments
 (0)