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
@@ -17,6 +17,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<mockito.version>5.18.0</mockito.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -28,6 +29,16 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.5.3</version>
|
||||
<configuration>
|
||||
<argLine>
|
||||
-javaagent:"${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar"
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-maven-plugin</artifactId>
|
||||
@@ -201,12 +212,7 @@
|
||||
<dependency>
|
||||
<groupId>org.gitlab4j</groupId>
|
||||
<artifactId>gitlab4j-api</artifactId>
|
||||
<version>6.0.0-rc.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gitlab4j</groupId>
|
||||
<artifactId>gitlab4j-models</artifactId>
|
||||
<version>6.0.0-rc.9</version>
|
||||
<version>6.0.0-rc.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -268,6 +274,13 @@
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -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