fix(deps): update dependency org.gitlab4j:gitlab4j-api to v6.0.0-rc.10
This commit is contained in:
1 parent
7c960ddbdc
commit
069002a534
3 files changed
+87
-12
No files matched your search
@@ -90,13 +90,12 @@ public class ReportIssueTask extends ModalTask {
|
||||
gitLabApi.setRequestTimeout(1000, 5000);
|
||||
|
||||
String title = String.format("Bug report: %s", modalTitle.getAsString());
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("Issue reported from user of bot\n\n");
|
||||
description.append("User: ").append(user.getName()).append(String.format("[%s]", user.getId())).append("\n\n");
|
||||
description.append("Last Sentry ID: ").append(Sentry.getLastEventId()).append("\n\n");
|
||||
description.append("Description from user: \n\n").append(modalDescription.getAsString());
|
||||
String description = "Issue reported from user of bot\n\n" +
|
||||
"User: " + user.getName() + String.format("[%s]", user.getId()) + "\n\n" +
|
||||
"Last Sentry ID: " + Sentry.getLastEventId() + "\n\n" +
|
||||
"Description from user: \n\n" + modalDescription.getAsString();
|
||||
|
||||
Issue issue = gitLabApi.getIssuesApi().createIssue(projectId, title, description.toString());
|
||||
Issue issue = gitLabApi.getIssuesApi().createIssue(projectId, title, description);
|
||||
|
||||
context.reply(String.format("Issue was successfully created: %s", issue.getWebUrl()));
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package me.bobert.netneutrality.command.git;
|
||||
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import org.gitlab4j.api.GitLabApi;
|
||||
import org.gitlab4j.api.IssuesApi;
|
||||
import org.gitlab4j.api.models.Issue;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ReportIssueCommandTest {
|
||||
private GitLabApi mockGitLabApi;
|
||||
private IssuesApi mockIssuesApi;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
mockGitLabApi = mock(GitLabApi.class);
|
||||
mockIssuesApi = mock(IssuesApi.class);
|
||||
|
||||
when(mockGitLabApi.getIssuesApi()).thenReturn(mockIssuesApi);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateIssueMocked() throws Exception {
|
||||
int projectId = 123456;
|
||||
String modalTitle = "Bug report: mocked bug report";
|
||||
String modalDescription = "This is a mocked description";
|
||||
String userName = "TestUser";
|
||||
String userId = UUID.randomUUID().toString();
|
||||
String sentryId = UUID.randomUUID().toString();
|
||||
|
||||
String expectedTitle = String.format("Bug report: %s", modalTitle);
|
||||
String expectedDescription = "Issue reported from user of bot\n\n" +
|
||||
"User: " + userName + String.format("[%s]", userId) + "\n\n" +
|
||||
"Last Sentry ID: " + sentryId + "\n\n" +
|
||||
"Description from user: \n\n" + modalDescription;
|
||||
|
||||
Issue mockedIssue = new Issue();
|
||||
mockedIssue.setTitle(expectedTitle);
|
||||
mockedIssue.setDescription(expectedDescription);
|
||||
|
||||
when(mockIssuesApi.createIssue(eq(projectId), eq(expectedTitle), eq(expectedDescription))).thenReturn(mockedIssue);
|
||||
|
||||
Issue created = mockGitLabApi.getIssuesApi().createIssue(projectId, expectedTitle, expectedDescription);
|
||||
assertNotNull(created);
|
||||
assertEquals(expectedTitle, created.getTitle());
|
||||
assertEquals(expectedDescription, created.getDescription());
|
||||
|
||||
verify(mockIssuesApi).createIssue(projectId, expectedTitle, expectedDescription);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user