refactor(reflection): migrate to using cutin library
All checks were successful
github-mirror / push-github (push) Successful in 12s
Build / Gradle-Build (push) Successful in 15s
Test / Gradle-Test (push) Successful in 24s

This commit is contained in:
2025-04-13 23:15:38 +02:00
parent ebf5600e29
commit ef9384336a
47 changed files with 452 additions and 756 deletions

View File

@@ -38,7 +38,7 @@ class AutoCompleteTest {
LibraryWrapper wrapper = new Discord4JWrapper(null); //null okay as we don't use the discord API in this test.
Marinara marinara = Marinara.load(wrapper);
marinara.getRegistry().addInteractions(new TestAutocomplete());
marinara.getInteractionContainer().addAllMethods(new TestAutocomplete());
wrapper.handleInteraction(autoCompleteEventMock);
verify(autoCompleteEventMock).respondWithSuggestions(any());
}

View File

@@ -13,15 +13,15 @@ import net.tomatentum.marinara.wrapper.LibraryWrapper;
import net.tomatentum.marinara.wrapper.discord4j.Discord4JWrapper;
@TestInstance(Lifecycle.PER_CLASS)
public class ButtonTest {
class ButtonTest {
@Test
public void testButtonExecution() {
void testButtonExecution() {
ButtonInteractionEvent buttonEventMock = CommonMocks.getButtonEventMock("test");
LibraryWrapper wrapper = new Discord4JWrapper(null); //null okay as we don't use the discord API in this test.
Marinara marinara = Marinara.load(wrapper);
marinara.getRegistry().addInteractions(new TestButton());
marinara.getInteractionContainer().addAllMethods(new TestButton());
wrapper.handleInteraction(buttonEventMock);
assertTrue(TestButton.didRun);
}

View File

@@ -24,16 +24,16 @@ import net.tomatentum.marinara.wrapper.discord4j.checks.PermissionCheck;
import reactor.core.publisher.Mono;
@TestInstance(Lifecycle.PER_CLASS)
public class InteractionCheckTest {
class InteractionCheckTest {
@Test
public void testInteractionCheck() {
void testInteractionCheck() {
ButtonInteractionEvent buttonEventMock = CommonMocks.getButtonEventMock("test");
LibraryWrapper wrapper = new Discord4JWrapper(null);
Marinara marinara = Marinara.load(wrapper);
marinara.getCheckRegistry().addCheck(new TestInteractionCheck());
marinara.getRegistry().addInteractions(new TestButton());
marinara.getCheckContainer().addAllMethods(new TestInteractionCheck());
marinara.getInteractionContainer().addAllMethods(new TestButton());
wrapper.handleInteraction(buttonEventMock);
assertTrue(TestInteractionCheck.preExecuted);
@@ -42,7 +42,7 @@ public class InteractionCheckTest {
}
@Test
public void testPermissionCheck() {
void testPermissionCheck() {
Member memberMock = mock();
Interaction interactionMock = mock();
@@ -54,8 +54,8 @@ public class InteractionCheckTest {
LibraryWrapper wrapper = new Discord4JWrapper(null);
Marinara marinara = Marinara.load(wrapper);
marinara.getCheckRegistry().addCheck(new PermissionCheck());
marinara.getRegistry().addInteractions(new TestButton());
marinara.getCheckContainer().addAllMethods(new PermissionCheck());
marinara.getInteractionContainer().addAllMethods(new TestButton());
wrapper.handleInteraction(buttonEventMock);
assertFalse(TestButton.didPermRun);

View File

@@ -22,9 +22,9 @@ import net.tomatentum.marinara.Marinara;
import net.tomatentum.marinara.wrapper.LibraryWrapper;
import net.tomatentum.marinara.wrapper.discord4j.Discord4JWrapper;
@TestInstance(Lifecycle.PER_CLASS)
public class SlashCommandTest {
class SlashCommandTest {
String DISCORD_TOKEN = System.getenv("DISCORD_TEST_TOKEN");
private static String DISCORD_TOKEN = System.getenv("DISCORD_TEST_TOKEN");
GatewayDiscordClient client;
@BeforeAll
@@ -41,8 +41,8 @@ public class SlashCommandTest {
@Test
void testSlashCommand() {
Marinara marinara = Marinara.load(new Discord4JWrapper(client));
marinara.getRegistry().addInteractions(new TestCommand());
marinara.getRegistry().registerCommands();
marinara.getInteractionContainer().addAllMethods(new TestCommand());
marinara.registerCommands();
System.out.println("Success!");
}
@@ -64,7 +64,7 @@ public class SlashCommandTest {
LibraryWrapper wrapper = new Discord4JWrapper(client);
Marinara marinara = Marinara.load(wrapper);
marinara.getRegistry().addInteractions(new TestCommand());
marinara.getInteractionContainer().addAllMethods(new TestCommand());
wrapper.handleInteraction(eventMock);
}

View File

@@ -2,8 +2,6 @@ package net.tomatentum.marinara.test.discord4j;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import discord4j.core.event.domain.interaction.ChatInputAutoCompleteEvent;
import discord4j.core.event.domain.interaction.ChatInputInteractionEvent;
import discord4j.discordjson.json.ApplicationCommandOptionChoiceData;
@@ -23,9 +21,8 @@ public class TestAutocomplete implements InteractionHandler {
autocompletes = @AutoComplete("testAuto")
)
)
@AutoComplete("testAuto")
public void exec(ChatInputInteractionEvent context) {
// Not executed just there for autocomplete to work
}
@AutoComplete("testAuto")

View File

@@ -26,7 +26,7 @@ public class TestCommand implements InteractionHandler {
}
)
public void exec(ChatInputInteractionEvent event, String test) {
assertEquals(test, "test");
assertEquals("test", test);
System.out.println("Success!");
}
}