Skip to content

Commit

Permalink
Fixed issues after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Zabuzard committed Mar 30, 2022
1 parent b9cd9cf commit 25fff95
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 431 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.togetherjava.tjbot.commands.reminder;

import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -35,14 +35,14 @@ void setUp() {
rawReminders = new RawReminderTestHelper(database, jdaTester);
}

private @NotNull SlashCommandEvent triggerSlashCommand(int timeAmount, @NotNull String timeUnit,
@NotNull String content) {
private @NotNull SlashCommandInteractionEvent triggerSlashCommand(int timeAmount,
@NotNull String timeUnit, @NotNull String content) {
return triggerSlashCommand(timeAmount, timeUnit, content, jdaTester.getMemberSpy());
}

private @NotNull SlashCommandEvent triggerSlashCommand(int timeAmount, @NotNull String timeUnit,
@NotNull String content, @NotNull Member author) {
SlashCommandEvent event = jdaTester.createSlashCommandEvent(command)
private @NotNull SlashCommandInteractionEvent triggerSlashCommand(int timeAmount,
@NotNull String timeUnit, @NotNull String content, @NotNull Member author) {
SlashCommandInteractionEvent event = jdaTester.createSlashCommandInteractionEvent(command)
.setOption(RemindCommand.TIME_AMOUNT_OPTION, timeAmount)
.setOption(RemindCommand.TIME_UNIT_OPTION, timeUnit)
.setOption(RemindCommand.CONTENT_OPTION, content)
Expand Down Expand Up @@ -70,7 +70,7 @@ void throwsWhenGivenUnsupportedUnit() {
void doesNotSupportDatesTooFarInFuture() {
// GIVEN
// WHEN triggering /remind too far in the future
SlashCommandEvent event = triggerSlashCommand(10, "years", "foo");
SlashCommandInteractionEvent event = triggerSlashCommand(10, "years", "foo");

// THEN rejects and responds accordingly, no reminder was created
verify(event).reply(startsWith("The reminder is set too far in the future"));
Expand All @@ -87,7 +87,7 @@ void userIsLimitedIfTooManyPendingReminders() {
}

// WHEN triggering another reminder
SlashCommandEvent event = triggerSlashCommand(5, "minutes", "foo");
SlashCommandInteractionEvent event = triggerSlashCommand(5, "minutes", "foo");

// THEN rejects and responds accordingly, no new reminder was created
verify(event)
Expand All @@ -110,7 +110,7 @@ void userIsNotLimitedIfOtherUserHasTooManyPendingReminders() {
Member secondUser = jdaTester.createMemberSpy(2);

// WHEN the second user triggers another reminder
SlashCommandEvent event = triggerSlashCommand(5, "minutes", "foo", secondUser);
SlashCommandInteractionEvent event = triggerSlashCommand(5, "minutes", "foo", secondUser);

// THEN accepts the reminder and responds accordingly
verify(event).reply("Will remind you about 'foo' in 5 minutes.");
Expand All @@ -125,7 +125,7 @@ void userIsNotLimitedIfOtherUserHasTooManyPendingReminders() {
void canCreateReminders() {
// GIVEN
// WHEN triggering the /remind command
SlashCommandEvent event = triggerSlashCommand(5, "minutes", "foo");
SlashCommandInteractionEvent event = triggerSlashCommand(5, "minutes", "foo");

// THEN accepts the reminder and responds accordingly
verify(event).reply("Will remind you about 'foo' in 5 minutes.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ public JdaTester() {
/**
* Gets the member spy used as universal member by all mocks created by this tester instance.
* <p>
* For example the events created by {@link #createSlashCommandEvent(SlashCommand)} will return
* this spy on several of their methods.
* For example the events created by {@link #createSlashCommandInteractionEvent(SlashCommand)}
* will return this spy on several of their methods.
* <p>
* See {@link #createMemberSpy(long)} to create other members.
*
Expand Down
Loading

0 comments on commit 25fff95

Please sign in to comment.