refactor(reflection): migrate to using cutin library
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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")
|
||||
|
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user