add Discord4J Wrapper #14
@ -0,0 +1,23 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.Marinara;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.AutocompleteInteractionMock;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.DiscordApiMock;
|
||||||
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
|
||||||
|
public class AutoCompleteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAutocomplete() {
|
||||||
|
LibraryWrapper wrapper = new JavacordWrapper(new DiscordApiMock()); //null okay as we don't use the discord API in this test.
|
||||||
|
Marinara marinara = Marinara.load(wrapper);
|
||||||
|
marinara.getRegistry().addInteractions(new TestAutocomplete());
|
||||||
|
wrapper.handleInteraction(new AutocompleteInteractionMock());
|
||||||
|
assertTrue(AutocompleteInteractionMock.didAutocompleteRun);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.Marinara;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.ButtonInteractionMock;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.DiscordApiMock;
|
||||||
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
public class ButtonTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testButtonExecution() {
|
||||||
|
LibraryWrapper wrapper = new JavacordWrapper(new DiscordApiMock()); //null okay as we don't use the discord API in this test.
|
||||||
|
Marinara marinara = Marinara.load(wrapper);
|
||||||
|
marinara.getRegistry().addInteractions(new TestButton());
|
||||||
|
wrapper.handleInteraction(new ButtonInteractionMock("test"));
|
||||||
|
assertTrue(TestButton.didRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import org.javacord.api.entity.permission.PermissionType;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.Marinara;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.ButtonInteractionMock;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.DiscordApiMock;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.ServerMock;
|
||||||
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck;
|
||||||
|
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
public class InteractionCheckTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInteractionCheck() {
|
||||||
|
LibraryWrapper wrapper = new JavacordWrapper(new DiscordApiMock());
|
||||||
|
Marinara marinara = Marinara.load(wrapper);
|
||||||
|
marinara.getCheckRegistry().addCheck(new TestInteractionCheck());
|
||||||
|
marinara.getRegistry().addInteractions(new TestButton());
|
||||||
|
wrapper.handleInteraction(new ButtonInteractionMock("test"));
|
||||||
|
assertTrue(TestInteractionCheck.preExecuted);
|
||||||
|
assertTrue(TestInteractionCheck.postExecuted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPermissionCheck() {
|
||||||
|
LibraryWrapper wrapper = new JavacordWrapper(new DiscordApiMock());
|
||||||
|
Marinara marinara = Marinara.load(wrapper);
|
||||||
|
marinara.getCheckRegistry().addCheck(new PermissionCheck());
|
||||||
|
marinara.getRegistry().addInteractions(new TestButton());
|
||||||
|
wrapper.handleInteraction(new ButtonInteractionMock("permissionCheck"));
|
||||||
|
assertTrue(TestButton.didPermRun);
|
||||||
|
TestButton.didPermRun = false;
|
||||||
|
ServerMock.TESTPERMISSION = PermissionType.ATTACH_FILE;
|
||||||
|
wrapper.handleInteraction(new ButtonInteractionMock("permissionCheck"));
|
||||||
|
assertFalse(TestButton.didPermRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import org.javacord.api.DiscordApi;
|
||||||
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.Marinara;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.mocks.SlashCommandInteractionMock;
|
||||||
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
public class SlashCommandTest {
|
||||||
|
|
||||||
|
String DISCORD_TOKEN = System.getenv("DISCORD_TEST_TOKEN");
|
||||||
|
DiscordApi api;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
void setUp() {
|
||||||
|
api = new DiscordApiBuilder()
|
||||||
|
.setToken(DISCORD_TOKEN)
|
||||||
|
.login().join();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
void tearDown() {
|
||||||
|
api.disconnect();
|
||||||
|
api = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSlashCommand() {
|
||||||
|
Marinara marinara = Marinara.load(new JavacordWrapper(api));
|
||||||
|
marinara.getRegistry().addInteractions(new TestCommand());
|
||||||
|
marinara.getRegistry().registerCommands();
|
||||||
|
System.out.println("Success!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSlashCommandExecution() {
|
||||||
|
LibraryWrapper wrapper = new JavacordWrapper(api);
|
||||||
|
Marinara marinara = Marinara.load(wrapper);
|
||||||
|
marinara.getRegistry().addInteractions(new TestCommand());
|
||||||
|
|
||||||
|
wrapper.handleInteraction(new SlashCommandInteractionMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.javacord.api.interaction.AutocompleteInteraction;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.interaction.InteractionHandler;
|
||||||
|
import net.tomatentum.marinara.interaction.annotation.AutoComplete;
|
||||||
|
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
|
||||||
|
|
||||||
|
public class TestAutocomplete implements InteractionHandler {
|
||||||
|
|
||||||
|
@SlashCommand(name = "test")
|
||||||
|
@AutoComplete
|
||||||
|
public void autocomplete(AutocompleteInteraction context, String value) {
|
||||||
|
System.out.println("Success!");
|
||||||
|
assertEquals(value, "test");
|
||||||
|
context.respondWithChoices(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import org.javacord.api.entity.channel.TextChannel;
|
||||||
|
import org.javacord.api.entity.message.Message;
|
||||||
|
import org.javacord.api.entity.permission.PermissionType;
|
||||||
|
import org.javacord.api.entity.server.Server;
|
||||||
|
import org.javacord.api.entity.user.User;
|
||||||
|
import org.javacord.api.interaction.ButtonInteraction;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.interaction.InteractionHandler;
|
||||||
|
import net.tomatentum.marinara.interaction.annotation.Button;
|
||||||
|
import net.tomatentum.marinara.test.discord4j.TestInteractionCheck.TestCheck;
|
||||||
|
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck.HasPermission;
|
||||||
|
|
||||||
|
public class TestButton implements InteractionHandler {
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean didRun = false;
|
||||||
|
@Button("test")
|
||||||
|
@TestCheck
|
||||||
|
public void exec(ButtonInteraction interaction, TextChannel channel, Message message, User member, Server server) {
|
||||||
|
assertNotNull(interaction);
|
||||||
|
assertNotNull(channel);
|
||||||
|
assertNotNull(message);
|
||||||
|
assertNotNull(member);
|
||||||
|
assertNotNull(server);
|
||||||
|
didRun = true;
|
||||||
|
System.out.println("Success!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean didPermRun = false;
|
||||||
|
|
||||||
|
@Button("permissionCheck")
|
||||||
|
@HasPermission({PermissionType.ADMINISTRATOR})
|
||||||
|
public void exec(ButtonInteraction interaction) {
|
||||||
|
didPermRun = true;
|
||||||
|
System.out.println("It worked!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.interaction.commands.ChoiceValueProvider;
|
||||||
|
|
||||||
|
public enum TestChoiceEnum implements ChoiceValueProvider<String> {
|
||||||
|
TestValue("testValue"),
|
||||||
|
FooBar("fooBar"),
|
||||||
|
Spongebob("spongebob");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private TestChoiceEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getChoiceValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.javacord.api.interaction.SlashCommandInteraction;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.interaction.InteractionHandler;
|
||||||
|
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
|
||||||
|
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommandOption;
|
||||||
|
import net.tomatentum.marinara.interaction.commands.option.SlashCommandOptionType;
|
||||||
|
|
||||||
|
public class TestCommand implements InteractionHandler {
|
||||||
|
@SlashCommand(
|
||||||
|
name = "test",
|
||||||
|
description = "testingen",
|
||||||
|
serverIds = {
|
||||||
|
1037753048602255440L
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
@SlashCommandOption(
|
||||||
|
name = "foo",
|
||||||
|
description = "foo bar is very fooby",
|
||||||
|
type = SlashCommandOptionType.STRING,
|
||||||
|
choiceEnum = TestChoiceEnum.class
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public void exec(SlashCommandInteraction interaction, String test) {
|
||||||
|
assertEquals(test, "test");
|
||||||
|
System.out.println("Success!");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import net.tomatentum.marinara.checks.InteractionCheck;
|
||||||
|
|
||||||
|
public class TestInteractionCheck implements InteractionCheck<TestInteractionCheck.TestCheck> {
|
||||||
|
|
||||||
|
public static boolean preExecuted = false;
|
||||||
|
public static boolean postExecuted = false;
|
||||||
|
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public static @interface TestCheck {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preExec(Object context, TestCheck annotation) {
|
||||||
|
assertNotNull(annotation);
|
||||||
|
assertNotNull(context);
|
||||||
|
preExecuted = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postExec(Object context, TestCheck annotation) {
|
||||||
|
assertNotNull(annotation);
|
||||||
|
assertNotNull(context);
|
||||||
|
postExecuted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import discord4j.core.GatewayDiscordClient;
|
||||||
|
import discord4j.core.event.domain.interaction.ChatInputAutoCompleteEvent;
|
||||||
|
import discord4j.core.object.command.Interaction;
|
||||||
|
import discord4j.gateway.ShardInfo;
|
||||||
|
|
||||||
|
public class AutocompleteInteractionMock extends ChatInputAutoCompleteEvent {
|
||||||
|
|
||||||
|
public AutocompleteInteractionMock(GatewayDiscordClient gateway, ShardInfo shardInfo, Interaction interaction) {
|
||||||
|
super(gateway, shardInfo, interaction);
|
||||||
|
//TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean didAutocompleteRun = false;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import discord4j.core.event.domain.interaction.ButtonInteractionEvent;
|
||||||
|
import discord4j.core.object.command.Interaction;
|
||||||
|
|
||||||
|
public class ButtonInteractionMock extends ButtonInteractionEvent {
|
||||||
|
|
||||||
|
private String customId;
|
||||||
|
|
||||||
|
public ButtonInteractionMock(String customId) {
|
||||||
|
super(null, null, null);
|
||||||
|
this.customId = customId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomId() {
|
||||||
|
return customId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Interaction getInteraction() {
|
||||||
|
return new InteractionMock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.reactivestreams.Publisher;
|
||||||
|
|
||||||
|
import discord4j.common.util.Snowflake;
|
||||||
|
import discord4j.core.GatewayDiscordClient;
|
||||||
|
import discord4j.core.object.entity.Message;
|
||||||
|
import discord4j.core.object.entity.channel.MessageChannel;
|
||||||
|
import discord4j.core.retriever.EntityRetrievalStrategy;
|
||||||
|
import discord4j.core.spec.MessageCreateSpec;
|
||||||
|
import discord4j.core.spec.legacy.LegacyMessageCreateSpec;
|
||||||
|
import discord4j.rest.entity.RestChannel;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public class ChannelMock implements MessageChannel {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getType'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> delete(String reason) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'delete'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RestChannel getRestChannel() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getRestChannel'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Snowflake getId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getId'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GatewayDiscordClient getClient() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getClient'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Snowflake> getLastMessageId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getLastMessageId'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> getLastMessage() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getLastMessage'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> getLastMessage(EntityRetrievalStrategy retrievalStrategy) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getLastMessage'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Instant> getLastPinTimestamp() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getLastPinTimestamp'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> createMessage(Consumer<? super LegacyMessageCreateSpec> spec) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'createMessage'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> createMessage(MessageCreateSpec spec) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'createMessage'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> type() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'type'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<Long> typeUntil(Publisher<?> until) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'typeUntil'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<Message> getMessagesBefore(Snowflake messageId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getMessagesBefore'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<Message> getMessagesAfter(Snowflake messageId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getMessagesAfter'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> getMessageById(Snowflake id) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getMessageById'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Message> getMessageById(Snowflake id, EntityRetrievalStrategy retrievalStrategy) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getMessageById'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<Message> getPinnedMessages() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getPinnedMessages'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import discord4j.core.object.command.Interaction;
|
||||||
|
import discord4j.core.object.entity.Guild;
|
||||||
|
import discord4j.core.object.entity.Message;
|
||||||
|
import discord4j.core.object.entity.User;
|
||||||
|
import discord4j.core.object.entity.channel.MessageChannel;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public class InteractionMock extends Interaction
|
||||||
|
{
|
||||||
|
|
||||||
|
public InteractionMock() {
|
||||||
|
super(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Message> getMessage() {
|
||||||
|
//return Optional.of(new MessageMock());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MessageChannel> getChannel() {
|
||||||
|
return Mono.just(new ChannelMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Guild> getGuild() {
|
||||||
|
//return Mono.just(new ServerMock());
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUser() {
|
||||||
|
return new UserMock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import discord4j.core.event.domain.interaction.ChatInputInteractionEvent;
|
||||||
|
|
||||||
|
public class SlashCommandInteractionMock extends ChatInputInteractionEvent {
|
||||||
|
|
||||||
|
public SlashCommandInteractionMock() {
|
||||||
|
super(null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import discord4j.core.object.command.ApplicationCommandInteractionOption;
|
||||||
|
import discord4j.core.object.command.ApplicationCommandInteractionOptionValue;
|
||||||
|
import discord4j.core.object.command.ApplicationCommandOption.Type;
|
||||||
|
|
||||||
|
public class SlashCommandInteractionOptionMock extends ApplicationCommandInteractionOption {
|
||||||
|
|
||||||
|
public SlashCommandInteractionOptionMock() {
|
||||||
|
super(null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "foo";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<ApplicationCommandInteractionOptionValue> getValue() {
|
||||||
|
return Optional.of(new ApplicationCommandInteractionOptionValue(null, null, Type.STRING.getValue(), "test", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package net.tomatentum.marinara.test.discord4j.mocks;
|
||||||
|
|
||||||
|
import discord4j.core.object.entity.User;
|
||||||
|
|
||||||
|
public class UserMock extends User {
|
||||||
|
|
||||||
|
public UserMock() {
|
||||||
|
super(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import net.tomatentum.marinara.Marinara;
|
import net.tomatentum.marinara.Marinara;
|
||||||
import net.tomatentum.marinara.test.mocks.AutocompleteInteractionMock;
|
import net.tomatentum.marinara.test.javacord.mocks.AutocompleteInteractionMock;
|
||||||
import net.tomatentum.marinara.test.mocks.DiscordApiMock;
|
import net.tomatentum.marinara.test.javacord.mocks.DiscordApiMock;
|
||||||
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@ -7,8 +7,8 @@ import org.junit.jupiter.api.TestInstance;
|
|||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
import net.tomatentum.marinara.Marinara;
|
import net.tomatentum.marinara.Marinara;
|
||||||
import net.tomatentum.marinara.test.mocks.ButtonInteractionMock;
|
import net.tomatentum.marinara.test.javacord.mocks.ButtonInteractionMock;
|
||||||
import net.tomatentum.marinara.test.mocks.DiscordApiMock;
|
import net.tomatentum.marinara.test.javacord.mocks.DiscordApiMock;
|
||||||
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@ -9,9 +9,9 @@ import org.junit.jupiter.api.TestInstance;
|
|||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
import net.tomatentum.marinara.Marinara;
|
import net.tomatentum.marinara.Marinara;
|
||||||
import net.tomatentum.marinara.test.mocks.ButtonInteractionMock;
|
import net.tomatentum.marinara.test.javacord.mocks.ButtonInteractionMock;
|
||||||
import net.tomatentum.marinara.test.mocks.DiscordApiMock;
|
import net.tomatentum.marinara.test.javacord.mocks.DiscordApiMock;
|
||||||
import net.tomatentum.marinara.test.mocks.ServerMock;
|
import net.tomatentum.marinara.test.javacord.mocks.ServerMock;
|
||||||
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck;
|
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
@ -9,7 +9,7 @@ import org.junit.jupiter.api.TestInstance;
|
|||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
import net.tomatentum.marinara.Marinara;
|
import net.tomatentum.marinara.Marinara;
|
||||||
import net.tomatentum.marinara.test.mocks.SlashCommandInteractionMock;
|
import net.tomatentum.marinara.test.javacord.mocks.SlashCommandInteractionMock;
|
||||||
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
import net.tomatentum.marinara.wrapper.LibraryWrapper;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
import net.tomatentum.marinara.wrapper.javacord.JavacordWrapper;
|
||||||
@TestInstance(Lifecycle.PER_CLASS)
|
@TestInstance(Lifecycle.PER_CLASS)
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import org.javacord.api.interaction.ButtonInteraction;
|
|||||||
|
|
||||||
import net.tomatentum.marinara.interaction.InteractionHandler;
|
import net.tomatentum.marinara.interaction.InteractionHandler;
|
||||||
import net.tomatentum.marinara.interaction.annotation.Button;
|
import net.tomatentum.marinara.interaction.annotation.Button;
|
||||||
import net.tomatentum.marinara.test.TestInteractionCheck.TestCheck;
|
import net.tomatentum.marinara.test.javacord.TestInteractionCheck.TestCheck;
|
||||||
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck.HasPermission;
|
import net.tomatentum.marinara.wrapper.javacord.checks.PermissionCheck.HasPermission;
|
||||||
|
|
||||||
public class TestButton implements InteractionHandler {
|
public class TestButton implements InteractionHandler {
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import net.tomatentum.marinara.interaction.commands.ChoiceValueProvider;
|
import net.tomatentum.marinara.interaction.commands.ChoiceValueProvider;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test;
|
package net.tomatentum.marinara.test.javacord;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package net.tomatentum.marinara.test.mocks;
|
package net.tomatentum.marinara.test.javacord.mocks;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
Loading…
x
Reference in New Issue
Block a user