-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Villavicencio
authored and
Daniel Villavicencio
committed
Aug 6, 2024
1 parent
8c81a47
commit c6b6144
Showing
11 changed files
with
93 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/main/java/com/deahtstroke/rivenbot/factory/Factory.java
This file was deleted.
Oops, something went wrong.
6 changes: 1 addition & 5 deletions
6
.../rivenbot/factory/InteractionFactory.java → .../rivenbot/handler/InteractionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 30 additions & 1 deletion
31
src/test/java/com/deahtstroke/rivenbot/handler/InteractionFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
package com.deahtstroke.rivenbot.handler; | ||
|
||
import com.deahtstroke.rivenbot.handler.about.AboutHandler; | ||
import com.deahtstroke.rivenbot.handler.raidstats.RaidStatsCommandHandler; | ||
import com.deahtstroke.rivenbot.handler.weeklydungeon.WeeklyDungeonHandler; | ||
import com.deahtstroke.rivenbot.handler.weeklyraid.WeeklyRaidHandler; | ||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class InteractionFactoryTest { | ||
// TODO: rewrite test suite from scratch | ||
|
||
@Mock | ||
AboutHandler aboutHandler; | ||
|
||
@Mock | ||
RaidStatsCommandHandler raidStatsCommandHandler; | ||
|
||
@Mock | ||
WeeklyDungeonHandler weeklyDungeonHandler; | ||
|
||
@Mock | ||
WeeklyRaidHandler weeklyRaidHandler; | ||
|
||
@Mock | ||
|
||
|
||
List<SlashCommandHandler> slashCommandHandlers = List.of(aboutHandler, raidStatsCommandHandler, | ||
weeklyRaidHandler, weeklyDungeonHandler); | ||
|
||
@InjectMocks | ||
InteractionFactory sut; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ke/rivenbot/handler/AboutHandlerTest.java → ...enbot/handler/about/AboutHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rivenbot/handler/RaidStatHandlerTest.java → ...ats/RaidStatsAutocompleteHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.deahtstroke.rivenbot.handler; | ||
package com.deahtstroke.rivenbot.handler.raidstats; | ||
|
||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class RaidStatHandlerTest { | ||
class RaidStatsAutocompleteHandlerTest { | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
src/test/java/com/deahtstroke/rivenbot/handler/raidstats/RaidStatsCommandHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.deahtstroke.rivenbot.handler.raidstats; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.deahtstroke.rivenbot.dto.discord.Interaction; | ||
import com.deahtstroke.rivenbot.dto.discord.InteractionData; | ||
import com.deahtstroke.rivenbot.dto.discord.Option; | ||
import com.deahtstroke.rivenbot.enums.InteractionResponseType; | ||
import com.deahtstroke.rivenbot.processor.AsyncRaidsProcessor; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import reactor.core.publisher.Mono; | ||
import reactor.test.StepVerifier; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class RaidStatsCommandHandlerTest { | ||
|
||
@Mock | ||
AsyncRaidsProcessor asyncRaidsProcessor; | ||
|
||
@InjectMocks | ||
RaidStatsCommandHandler sut; | ||
|
||
@Test | ||
@DisplayName("Serve should work successfully") | ||
void shouldServeRaidStatsSuccessfully() { | ||
// given: an interaction with a Bungie user | ||
List<Option> options = List.of( | ||
new Option("username", 1, "Deaht#3180", false, Collections.emptyList())); | ||
Interaction interaction = Interaction.builder() | ||
.data(InteractionData.builder() | ||
.options(options) | ||
.build()) | ||
.token("someToken") | ||
.build(); | ||
|
||
when(asyncRaidsProcessor.processRaidsAsync("Deaht", "3180", "someToken")) | ||
.thenReturn(Mono.empty()); | ||
|
||
// when: serve() is invoked | ||
StepVerifier.create(sut.serve(interaction)) | ||
.assertNext(response -> { | ||
assertThat(response.getType()) | ||
.isEqualTo(InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE.getType()); | ||
assertThat(response.getData()).isNotNull(); | ||
}).verifyComplete(); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...bot/handler/WeeklyDungeonHandlerTest.java → ...eklydungeon/WeeklyDungeonHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...venbot/handler/WeeklyRaidHandlerTest.java → ...ler/weeklyraid/WeeklyRaidHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters