[AB-165] removing mocking utils and general test improvements

This commit is contained in:
Sheldan
2021-02-28 21:46:45 +01:00
parent 5f6746d742
commit 821971523e
55 changed files with 834 additions and 842 deletions

View File

@@ -59,7 +59,7 @@ public class TrackedEmoteParameterHandlerTest {
public void testHandleWithEmote() {
when(contextMessage.getGuild()).thenReturn(guild);
Emote emote = Mockito.mock(Emote.class);
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(WRONG_FORMATTED_INPUT).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(emote);
when(trackedEmoteService.getFakeTrackedEmote(emote, guild)).thenReturn(trackedEmote);
TrackedEmote parsedEmote = (TrackedEmote) testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
@@ -70,7 +70,8 @@ public class TrackedEmoteParameterHandlerTest {
public void testHandleWithId() {
Long emoteId = 5L;
when(contextMessage.getGuild()).thenReturn(guild);
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(emoteId.toString()).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(input.getValue()).thenReturn(emoteId.toString());
when(trackedEmoteService.getFakeTrackedEmote(emoteId, guild)).thenReturn(trackedEmote);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(null);
TrackedEmote parsedEmote = (TrackedEmote) testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
@@ -80,7 +81,8 @@ public class TrackedEmoteParameterHandlerTest {
@Test(expected = NumberFormatException.class)
public void testWithIllegalInput() {
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(WRONG_FORMATTED_INPUT).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(input.getValue()).thenReturn(WRONG_FORMATTED_INPUT);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(null);
testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
}

View File

@@ -62,7 +62,7 @@ public class TrackedEmoteParameterParameterHandlerTest {
public void testHandleWithEmote() {
when(contextMessage.getGuild()).thenReturn(guild);
Emote emote = Mockito.mock(Emote.class);
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(WRONG_FORMATTED_INPUT).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(emote);
when(trackedEmoteService.getFakeTrackedEmote(emote, guild)).thenReturn(trackedEmote);
TrackEmoteParameter parsedEmote = (TrackEmoteParameter) testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
@@ -74,7 +74,8 @@ public class TrackedEmoteParameterParameterHandlerTest {
public void testHandleWithId() {
Long emoteId = 5L;
when(contextMessage.getGuild()).thenReturn(guild);
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(emoteId.toString()).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(input.getValue()).thenReturn(emoteId.toString());
when(trackedEmoteService.getFakeTrackedEmote(emoteId, guild)).thenReturn(trackedEmote);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(null);
TrackEmoteParameter parsedEmote = (TrackEmoteParameter) testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
@@ -84,7 +85,8 @@ public class TrackedEmoteParameterParameterHandlerTest {
@Test(expected = NumberFormatException.class)
public void testWithIllegalInput() {
UnparsedCommandParameterPiece input = UnparsedCommandParameterPiece.builder().value(WRONG_FORMATTED_INPUT).build();
UnparsedCommandParameterPiece input = Mockito.mock(UnparsedCommandParameterPiece.class);
when(input.getValue()).thenReturn(WRONG_FORMATTED_INPUT);
when(emoteParameterHandler.handle(input, iterators, Emote.class, contextMessage)).thenReturn(null);
testUnit.handle(input, iterators, TrackedEmote.class, contextMessage);
}