Skip to content

Commit

Permalink
fixed variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Aug 29, 2024
1 parent 076c86f commit 7ce6d10
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand All @@ -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);
}
}

0 comments on commit 7ce6d10

Please sign in to comment.