Skip to content

Add JUnit 5 test suite and migrate to Paper API 1.21.11#49

Merged
tastybento merged 3 commits into
developfrom
copilot/add-junit5-test-classes
Mar 17, 2026
Merged

Add JUnit 5 test suite and migrate to Paper API 1.21.11#49
tastybento merged 3 commits into
developfrom
copilot/add-junit5-test-classes

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

No tests existed for the Chat addon, making refactoring and validation impossible. This PR introduces a full JUnit 5 test suite using MockBukkit and migrates the project to Paper API 1.21.11.

pom.xml

  • Replaced spigot-api with paper-api:1.21.11-R0.1-SNAPSHOT
  • Updated BentoBox: 2.7.1-SNAPSHOT3.10.2
  • Removed PowerMock (JUnit 4); added JUnit Jupiter 5.10.2, MockBukkit v1.21-SNAPSHOT, mockito-junit-jupiter
  • Upgraded Mockito: 3.11.25.11.0
  • Updated maven-surefire-plugin: 3.0.0-M53.5.2
  • Added papermc and codemc-snapshots repositories

Test infrastructure

  • WhiteBox — reflection utility to set private/static fields (replaces PowerMock's Whitebox)
  • CommonTestSetup — abstract base with @BeforeEach/@AfterEach wiring up MockBukkit server, static Bukkit mock, BentoBox plugin/island/player mocks, locales, and full teardown including MockBukkit.unmock() and User.clearUsers()

Test classes

Class Coverage
SettingsTest Default values, all setters, EventPriority string parsing including invalid input
ChatPladdonTest Addon instantiation, singleton guarantee
ChatListenerTest togglePlayerTeamChat, toggleSpy, toggleIslandSpy, toggleIslandChat, isChat, onChat routing (team/island/unregistered world), teamChat/islandChat log control, onLeave/onKick cleanup
IslandTeamChatCommandTest setup(), canExecute (team membership gate), execute toggle + inline send
IslandChatCommandTest setup(), canExecute (island presence gate), execute toggle + inline send
AdminIslandChatSpyCommandTest setup(), spy toggle on/off
AdminTeamChatSpyCommandTest setup(), spy toggle on/off
IsTeamChatHandlerTest Null/empty/wrong-type map guards, player in/out of team chat
// Example: all tests extend CommonTestSetup for consistent BentoBox + MockBukkit wiring
public class ChatListenerTest extends CommonTestSetup {
    @Override @BeforeEach
    public void setUp() throws Exception {
        super.setUp();
        when(addon.isRegisteredGameWorld(any(World.class))).thenReturn(true);
        listener = new ChatListener(addon);
    }

    @Test
    public void testOnChatTeamChatActive() {
        listener.togglePlayerTeamChat(uuid);
        when(im.inTeam(any(World.class), any(UUID.class))).thenReturn(true);
        AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(false, player, "Hello team!", Collections.emptySet());
        listener.onChat(event);
        assertTrue(event.isCancelled());
    }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hub.spigotmc.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Chat/Chat org.codehaus.plexus.classworlds.launcher.Launcher dependency:resolve -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Chat/Chat org.codehaus.plexus.classworlds.launcher.Launcher dependency:list -q (dns block)
    • Triggering command: /usr/bin/curl curl -s --max-time 5 REDACTED (dns block)
  • repo.codemc.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Chat/Chat org.codehaus.plexus.classworlds.launcher.Launcher dependency:resolve -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Chat/Chat org.codehaus.plexus.classworlds.launcher.Launcher dependency:list -q (dns block)
    • Triggering command: /usr/bin/curl curl -s --max-time 5 REDACTED (dns block)
  • repo.papermc.io
    • Triggering command: /usr/bin/curl curl -sv --max-time 10 REDACTED (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Chat/Chat org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>JUnit 5 test classes</issue_title>
<issue_description>### Is your feature request related to a problem?

Cannot validate changes or refactoring

Describe the solution you'd like.

Write junit 5 test classes for the whole project. Use MockBukkit. Update to Paper 1.21.11 and Java 21.

Describe alternatives you've considered.

Doing nothing

Agreements

  • I have searched for and ensured there isn't already an open issue regarding this.
  • I have ensured the feature I'm requesting isn't already in the latest supported BentoBox build or Addons.

Other

No response</issue_description>

<agent_instructions>Make a plan then implement it. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 2 commits March 17, 2026 03:03
Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Add JUnit 5 test classes for the project Add JUnit 5 test suite and migrate to Paper API 1.21.11 Mar 17, 2026
Copilot AI requested a review from tastybento March 17, 2026 03:06
@tastybento tastybento marked this pull request as ready for review March 17, 2026 03:08
@tastybento tastybento merged commit fdd016c into develop Mar 17, 2026
@tastybento tastybento deleted the copilot/add-junit5-test-classes branch July 3, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUnit 5 test classes

2 participants