diff --git a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ReloadCommandTest.java b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ReloadCommandTest.java index 1acfae2..291aad5 100644 --- a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ReloadCommandTest.java +++ b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ReloadCommandTest.java @@ -56,7 +56,7 @@ public void setUp() throws MalformedURLException { MockitoAnnotations.openMocks(this); command = new ReloadCommand(); command.isTest = true; - setCommonVariables(api, user, event); + setCommonVariables(jda, user, event); } @Test diff --git a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ShutdownCommandTest.java b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ShutdownCommandTest.java index 4c61736..7aa35c2 100644 --- a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ShutdownCommandTest.java +++ b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/admin/ShutdownCommandTest.java @@ -53,7 +53,7 @@ public void setUp() { systemWrapper = mock(SystemWrapper.class); command.systemWrapper = systemWrapper; - when(event.getJDA()).thenReturn(api); + when(event.getJDA()).thenReturn(jda); } @Test diff --git a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/PingCommandTest.java b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/PingCommandTest.java index 375b344..5d4ab90 100644 --- a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/PingCommandTest.java +++ b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/PingCommandTest.java @@ -24,7 +24,6 @@ import io.github.yusufsdiscordbot.mystiguardian.commands.miscellaneous.PingCommand; import io.github.yusufsdiscordbot.mystiguardian.utils.MystiGuardianUtils; import io.github.yusufsdiscordbot.mystiguardian.utils.PermChecker; -import java.net.MalformedURLException; import java.util.function.Consumer; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.User; @@ -52,16 +51,16 @@ public class PingCommandTest { private PingCommand command; @BeforeEach - public void setUp() throws MalformedURLException { + public void setUp() { MockitoAnnotations.openMocks(this); command = new PingCommand(); - setCommonVariables(api, user, event); + setCommonVariables(jda, user, event); } @Test - public void shouldSendPingResponse() throws MalformedURLException { - when(api.getGatewayPing()).thenReturn(100L); - when(api.getRestPing()).thenReturn(restAction); + public void shouldSendPingResponse() { + when(jda.getGatewayPing()).thenReturn(100L); + when(jda.getRestPing()).thenReturn(restAction); doAnswer( invocation -> { diff --git a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/UptimeCommandTest.java b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/UptimeCommandTest.java index d83191d..ea7dfd6 100644 --- a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/UptimeCommandTest.java +++ b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/commands/miscellaneous/UptimeCommandTest.java @@ -57,7 +57,7 @@ public void setUp() throws MalformedURLException { MockitoAnnotations.openMocks(this); user = mock(User.class); // Add this line command = new UptimeCommand(); - setCommonVariables(api, user, event); + setCommonVariables(jda, user, event); } @Test diff --git a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/util/MystiGuardianTestUtils.java b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/util/MystiGuardianTestUtils.java index 0da0fde..9339631 100644 --- a/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/util/MystiGuardianTestUtils.java +++ b/OAuth/src/test/java/io/github/yusufsdiscordbot/mystigurdian/util/MystiGuardianTestUtils.java @@ -24,8 +24,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import java.awt.*; -import java.net.MalformedURLException; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.User; @@ -52,8 +50,7 @@ public static String getEmbedDescription(EmbedBuilder embed) { return embedToJson(embed).get("description").asText(); } - public static void setCommonVariables(JDA jda, User user, SlashCommandInteraction event) - throws MalformedURLException { + public static void setCommonVariables(JDA jda, User user, SlashCommandInteraction event) { when(user.getAvatar()) .thenReturn( new ImageProxy( @@ -62,10 +59,6 @@ public static void setCommonVariables(JDA jda, User user, SlashCommandInteractio when(user.getName()).thenReturn("TestUser"); Long mockDiscordId = 123456789L; when(event.getUser().getIdLong()).thenReturn(mockDiscordId); - when(event.getJDA()).thenReturn(api); - } - - public static double randomString(int i) { - return Math.random() * i; + when(event.getJDA()).thenReturn(jda); } }