Unverified Commit ece38ecd authored by Gautier de Saint Martin Lacaze's avatar Gautier de Saint Martin Lacaze Committed by GitHub
Browse files

Merge pull request #750 from gitlab4j/issue-691

Migrate from JUnit 4 to JUnit 5
parents 73817d15 a1b28ea1
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gitlab4j</groupId>
......@@ -50,13 +52,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jersey.version>2.30.1</jersey.version>
<jackson.version>2.10.3</jackson.version>
<servlet.version>4.0.3</servlet.version>
<jersey.version>2.34</jersey.version>
<jackson.version>2.12.4</jackson.version>
<servlet.version>4.0.4</servlet.version>
<activation.version>1.2.2</activation.version>
<junit.version>5.6.0</junit.version>
<mockito.version>3.3.0</mockito.version>
<junit.version>5.8.2</junit.version>
<testcontainers.version>1.15.3</testcontainers.version>
<mockito.version>4.1.0</mockito.version>
<hamcrest.version>1.3</hamcrest.version>
<systemRules.version>1.19.0</systemRules.version>
......@@ -67,7 +70,7 @@
<gitlab.autoremove-container>true</gitlab.autoremove-container>
<gitlab.skip-docker-start>true</gitlab.skip-docker-start>
<gitlab.port>8090</gitlab.port>
<sonar.projectKey>gitlab4j_gitlab4j-api</sonar.projectKey>
<sonar.organization>gitlab4j</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
......@@ -121,15 +124,15 @@
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
......@@ -179,20 +182,20 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.7</version>
<executions>
<execution>
<id>default-prepare-agent</id>
......@@ -235,23 +238,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<version>3.0.0-M5</version>
<configuration>
<excludedGroups>org.gitlab4j.api.IntegrationTest</excludedGroups>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
<excludedGroups>integration</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<version>3.0.0-M5</version>
<configuration>
<groups>org.gitlab4j.api.IntegrationTest</groups>
<groups>integration</groups>
<includes>
<include>**/IntegrationTestSuite.java</include>
<include>**/*.java</include>
</includes>
</configuration>
<executions>
......@@ -290,7 +294,7 @@
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.2</version>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
......@@ -298,7 +302,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.17</version>
<version>1.20</version>
<executions>
<execution>
<goals>
......@@ -327,7 +331,8 @@
<run>
<skip>${gitlab.skip-docker-start}</skip>
<env>
<GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password"; gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG>
<GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password";
gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG>
</env>
<ports>
<port>${gitlab.port}:80</port>
......@@ -358,12 +363,12 @@
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- The se.bjurr.gitchangelog:git-changelog-maven-plugin needs to be in -->
<!-- The se.bjurr.gitchangelog:git-changelog-maven-plugin needs to be
in -->
<!-- this section (pluginManagement) for it to work correctly. -->
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
......@@ -382,14 +387,14 @@
</executions>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<bnd><![CDATA[
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<bnd><![CDATA[
Export-Package: org.gitlab4j.api.*
]]></bnd>
</configuration>
</configuration>
</plugin>
</plugins>
</pluginManagement>
......@@ -435,8 +440,8 @@
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
......@@ -447,28 +452,27 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>${systemRules.version}</version>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.junit-toolbox</groupId>
<artifactId>junit-toolbox</artifactId>
<version>2.4</version>
<scope>test</scope>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!-- Needed for animal-sniffer -->
<!-- Needed for animal-sniffer -->
<dependency>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
......
package org.gitlab4j.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This interface is used as a category for JUnit allowing integration tests to be skipped
* while running unit tests.
* <p>To mark a test class as an integration test add the following lines before the class declaration:</p>
*
* <pre><code>
* import org.junit.experimental.categories.Category;
*
* @Category(org.gitlab4j.api.IntegrationTest.class)
* </code></pre>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface IntegrationTest {
}
package org.gitlab4j.api;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.stream.StreamSupport;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PagerSpliteratorTest {
PagerSpliterator<Integer> pagerSpliterator;
......@@ -25,7 +25,7 @@ public class PagerSpliteratorTest {
@Mock
Pager<Integer> pager;
@Before
@BeforeEach
public void setUp() {
pagerSpliterator = new PagerSpliterator<>(pager);
}
......@@ -46,7 +46,7 @@ public class PagerSpliteratorTest {
assertFalse(success);
}
@Test
public void shouldReturnFalseIfNextPagerItemMissing() {
when(pager.hasNext()).thenReturn(true);
......@@ -61,7 +61,7 @@ public class PagerSpliteratorTest {
public void shouldThrowNullPointerExceptionWhenActionIsMissing() {
try {
pagerSpliterator.tryAdvance(null);
Assert.fail("Missing NullPointerException");
fail("Missing NullPointerException");
} catch (Throwable e) {
assertEquals(NullPointerException.class, e.getClass());
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Project;
......@@ -15,26 +17,18 @@ import org.gitlab4j.api.models.User;
import org.gitlab4j.api.models.Visibility;
import org.gitlab4j.api.utils.AccessTokenUtils;
import org.gitlab4j.api.utils.AccessTokenUtils.Scope;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Categories.IncludeCategory;
import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
/**
* This test suite implementation will check for the users, projects, groups, and repo files needed for testing
* This extension for integration tests will check for the users, projects, groups, and repo files needed for testing
* and create them if they do not exist. It will also create temporary personal access tokens needed for testing.
*
* <p>NOTE: This class relies on a minimal amount of the GitLab4J-API library to set things up,
* so if there are any failures the test suite will fail. Consider it the first integration tests
* that are being performed.</p>
*/
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/Test*.class"})
@IncludeCategory(IntegrationTest.class)
public class IntegrationTestSuite implements PropertyConstants {
public class SetupIntegrationTestExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource, PropertyConstants {
private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY);
private static final String TEST_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY);
......@@ -55,38 +49,47 @@ public class IntegrationTestSuite implements PropertyConstants {
private static boolean createdAccessToken = false;
private static String problems = "";
@BeforeClass
public static void suiteSetup() throws GitLabApiException {
private static boolean alreadySetup = false;
final static Lock lock = new ReentrantLock();
System.out.println("********************************************************");
System.out.println("* Test Suite Setup *");
System.out.println("********************************************************");
@Override
public void beforeAll(ExtensionContext context) throws Exception {
lock.lock();
if (!alreadySetup) {
if (TEST_LOGIN_USERNAME == null || TEST_LOGIN_USERNAME.trim().isEmpty()) {
problems += "TEST_LOGIN_USERNAME cannot be empty\n";
}
System.out.println("********************************************************");
System.out.println("* Integration Tests Setup *");
System.out.println("********************************************************");
if (TEST_LOGIN_PASSWORD == null || TEST_LOGIN_PASSWORD.trim().isEmpty()) {
problems += "TEST_LOGIN_PASSWORD cannot be empty\n";
}
if (TEST_LOGIN_USERNAME == null || TEST_LOGIN_USERNAME.trim().isEmpty()) {
problems += "TEST_LOGIN_USERNAME cannot be empty\n";
}
if (TEST_HOST_URL == null || TEST_HOST_URL.trim().isEmpty()) {
problems += "TEST_HOST_URL cannot be empty\n";
}
if (TEST_LOGIN_PASSWORD == null || TEST_LOGIN_PASSWORD.trim().isEmpty()) {
problems += "TEST_LOGIN_PASSWORD cannot be empty\n";
}
if (!problems.isEmpty()) {
fail(problems);
}
if (TEST_HOST_URL == null || TEST_HOST_URL.trim().isEmpty()) {
problems += "TEST_HOST_URL cannot be empty\n";
}
seedData();
createAccessTokens();
}
if (!problems.isEmpty()) {
fail(problems);
}
seedData();
createAccessTokens();
@AfterClass
public static void suiteTeardown() throws GitLabApiException {
alreadySetup = true;
}
lock.unlock();
}
@Override
public void close() throws Throwable {
System.out.println("********************************************************");
System.out.println("* Test Suite Teardown *");
System.out.println("* Integration Tests Teardown *");
System.out.println("********************************************************");
revokeAccessTokens();
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.Constants.TokenType;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Version;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_HOST_URL
* TEST_ACCESS_TOKEN
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestAccessToken extends AbstractIntegrationTest {
// TEST_ACCESS_TOKEN must be defined to run this test
......@@ -32,7 +34,7 @@ public class TestAccessToken extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void testSetup() {
// Must setup the connection to the GitLab test server
......@@ -43,9 +45,9 @@ public class TestAccessToken extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......@@ -61,7 +63,7 @@ public class TestAccessToken extends AbstractIntegrationTest {
@Test
public void testAccessToken() throws GitLabApiException {
assumeNotNull(TEST_ACCESS_TOKEN);
assumeTrue(TEST_ACCESS_TOKEN != null);
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TokenType.ACCESS, TEST_ACCESS_TOKEN);
Version version = gitLabApi.getVersion();
assertNotNull(version);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Arrays;
import org.gitlab4j.api.utils.AccessTokenUtils;
import org.gitlab4j.api.utils.AccessTokenUtils.Scope;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -24,7 +25,8 @@ import org.junit.experimental.categories.Category;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestAccessTokenUtils {
// The following needs to be set to your test repository
......@@ -38,7 +40,7 @@ public class TestAccessTokenUtils {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
problems = "";
......@@ -60,7 +62,7 @@ public class TestAccessTokenUtils {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(problems.isEmpty());
}
......@@ -93,7 +95,7 @@ public class TestAccessTokenUtils {
try {
AccessTokenUtils.createPersonalAccessToken(
TEST_HOST_URL, TEST_LOGIN_USERNAME, "INVALID PASSWORD",
TEST_HOST_URL, TEST_LOGIN_USERNAME, "INVALID PASSWORD",
"Testing Token Creation", Arrays.asList(Scope.API, Scope.SUDO));
fail("Expected a failure, but personal access token was created.");
} catch (GitLabApiException glae) {
......
......@@ -23,17 +23,18 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
import static org.gitlab4j.api.models.Setting.LOCAL_MARKDOWN_VERSION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.models.ApplicationSettings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -43,7 +44,8 @@ import org.junit.experimental.categories.Category;
* <p>
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestApplicationSettingsApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -54,7 +56,7 @@ public class TestApplicationSettingsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
......@@ -68,7 +70,7 @@ public class TestApplicationSettingsApi extends AbstractIntegrationTest {
}
}
@AfterClass
@AfterAll
public static void teardown() {
if (fetchedApplicationSettings) {
......@@ -79,7 +81,7 @@ public class TestApplicationSettingsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(fetchedApplicationSettings);
}
......
......@@ -23,19 +23,20 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import org.gitlab4j.api.Constants.ApplicationScope;
import org.gitlab4j.api.models.Application;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -45,7 +46,8 @@ import org.junit.experimental.categories.Category;
* <p>
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestApplicationsApi extends AbstractIntegrationTest {
private static final String TEST_APPLICATION_NAME = "Test Application for GitLab4J-API";
......@@ -59,7 +61,7 @@ public class TestApplicationsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
......@@ -76,9 +78,9 @@ public class TestApplicationsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File;
import java.util.Map;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.User;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_NAMESPACE
* TEST_PROJECT_NAME
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestAvatarUpload extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -39,7 +40,7 @@ public class TestAvatarUpload extends AbstractIntegrationTest {
TEST_PROXY_USERNAME = HelperUtils.getProperty("TEST_PROXY_USERNAME");
TEST_PROXY_PASSWORD = HelperUtils.getProperty("TEST_PROXY_PASSWORD");
}
private static final String AVATAR_FILENAME = "avatar.png";
private static GitLabApi gitLabApi;
......@@ -49,7 +50,7 @@ public class TestAvatarUpload extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance
gitLabApi = baseTestSetup();
......@@ -59,7 +60,7 @@ public class TestAvatarUpload extends AbstractIntegrationTest {
@Test
public void testSetProjectAvatar() throws GitLabApiException {
assumeNotNull(testProject);
assumeTrue(testProject != null);
File avatarFile = new File("src/test/resources/org/gitlab4j/api", AVATAR_FILENAME);
Project updatedProject = gitLabApi.getProjectApi().setProjectAvatar(testProject.getId(), avatarFile);
......@@ -70,7 +71,7 @@ public class TestAvatarUpload extends AbstractIntegrationTest {
@Test
public void testSetProjectAvatarWithProxy() throws GitLabApiException {
assumeNotNull(testProject);
assumeTrue(testProject != null);
assumeTrue(TEST_PROXY_URI != null && TEST_PROXY_USERNAME != null && TEST_PROXY_PASSWORD != null);
assumeTrue(TEST_PROXY_URI.length() > 0 && TEST_PROXY_USERNAME.length() > 0 && TEST_PROXY_PASSWORD.length() > 0);
......@@ -89,7 +90,7 @@ public class TestAvatarUpload extends AbstractIntegrationTest {
@Test
public void testSetUserAvatar() throws GitLabApiException {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
User user = gitLabApi.getUserApi().getCurrentUser();
assertNotNull(user);
......
package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List;
import java.util.stream.Collectors;
......@@ -14,8 +14,8 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.Discussion;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
......@@ -29,9 +29,9 @@ public class TestCommitDiscussionsApi implements Constants {
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private MockResponse response;
@Before
@BeforeEach
public void setUp() throws Exception {
initMocks(this);
openMocks(this);
response = new MockResponse(Discussion.class, null, "commit-discussions.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.text.ParseException;
import java.util.Arrays;
......@@ -16,8 +16,8 @@ import java.util.Optional;
import java.util.stream.Stream;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Comment;
import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CommitAction;
......@@ -28,25 +28,27 @@ import org.gitlab4j.api.models.Diff;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.utils.ISO8601;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_NAMESPACE
* TEST_PROJECT_NAME
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestCommitsApi extends AbstractIntegrationTest {
private static final String TEST_CREATE_COMMIT_FILEPATH = "gitlab4j-create-commit-test-file.txt";
......@@ -57,7 +59,7 @@ public class TestCommitsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance
gitLabApi = baseTestSetup();
......@@ -73,24 +75,24 @@ public class TestCommitsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
@Test
public void testDiff() throws GitLabApiException {
assertNotNull(testProject);
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject.getId());
assertNotNull(commits);
assertTrue(commits.size() > 0);
List<Diff> diffs = gitLabApi.getCommitsApi().getDiff(testProject.getId(), commits.get(0).getId());
assertNotNull(diffs);
assertTrue(diffs.size() > 0);
diffs = gitLabApi.getCommitsApi().getDiff(TEST_NAMESPACE + "/" + TEST_PROJECT_NAME, commits.get(0).getId());
assertNotNull(diffs);
assertTrue(diffs.size() > 0);
......@@ -160,7 +162,7 @@ public class TestCommitsApi extends AbstractIntegrationTest {
List<CommitRef> commitRefs = gitLabApi.getCommitsApi().getCommitRefs(testProject.getId(), commits.get(0).getId());
assertNotNull(commitRefs);
Stream<CommitRef> commitRefsStream = gitLabApi.getCommitsApi().getCommitRefsStream(testProject.getId(), commits.get(0).getId());
assertNotNull(commitRefsStream);
}
......@@ -378,15 +380,15 @@ public class TestCommitsApi extends AbstractIntegrationTest {
repoFile = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master");
assertFalse(repoFile.isPresent());
}
@Test
public void testCherryPickCommit() throws GitLabApiException {
// Make sure the branch to cherry pick does not exist
if(gitLabApi.getRepositoryApi().getOptionalBranch(testProject, "cherry-pick-branch").isPresent()) {
gitLabApi.getRepositoryApi().deleteBranch(testProject, "cherry-pick-branch");
}
// Make sure the file to create does not exist.
String filePath = TEST_CREATE_COMMIT_FILEPATH + ".test";
if (gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master").isPresent()) {
......@@ -395,12 +397,12 @@ public class TestCommitsApi extends AbstractIntegrationTest {
// Act
Branch branch = gitLabApi.getRepositoryApi().createBranch(testProject, "cherry-pick-branch", "master");
// Assert
assertNotNull(branch);
Optional<RepositoryFile> repoFileBranch = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, branch.getName());
assertFalse(repoFileBranch.isPresent());
// Arrange
CommitAction commitAction = new CommitAction()
.withAction(Action.CREATE)
......@@ -415,10 +417,10 @@ public class TestCommitsApi extends AbstractIntegrationTest {
assertNotNull(commit);
Optional<RepositoryFile> repoFile = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master");
assertTrue(repoFile.isPresent());
// Act
Commit cherryPickedCommit = gitLabApi.getCommitsApi().cherryPickCommit(testProject, commit.getId(), "cherry-pick-branch");
// Assert
assertNotNull(cherryPickedCommit);
Optional<RepositoryFile> repoFileBranchCherryPicked = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, branch.getName());
......
package org.gitlab4j.api;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
* TEST_USERNAME
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestDeployKeysApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -28,7 +30,7 @@ public class TestDeployKeysApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -39,7 +41,7 @@ public class TestDeployKeysApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
......@@ -16,23 +17,24 @@ import org.gitlab4j.api.Constants.DeployTokenScope;
import org.gitlab4j.api.models.DeployToken;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Project;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
* TEST_USERNAME
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestDeployTokensApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -46,7 +48,7 @@ public class TestDeployTokensApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -72,7 +74,7 @@ public class TestDeployTokensApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
assumeTrue(testGroup != null);
......@@ -96,9 +98,9 @@ public class TestDeployTokensApi extends AbstractIntegrationTest {
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/211963
Collections.singletonList(DeployTokenScope.READ_REGISTRY));
assertNotNull(test);
Assert.assertEquals(test.getName(), name);
Assert.assertNotNull(test.getToken());
Assert.assertNotEquals(test.getToken(), "");
assertEquals(test.getName(), name);
assertNotNull(test.getToken());
assertNotEquals(test.getToken(), "");
gitLabApi.getDeployTokensApi().deleteProjectDeployToken(testProject, test.getId());
assertEquals(initialSize, gitLabApi.getDeployTokensApi().getProjectDeployTokens(testProject).size());
......@@ -122,9 +124,9 @@ public class TestDeployTokensApi extends AbstractIntegrationTest {
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/211963
Arrays.asList(DeployTokenScope.READ_REPOSITORY, DeployTokenScope.READ_REGISTRY));
assertNotNull(test);
Assert.assertEquals(test.getName(), name);
Assert.assertNotNull(test.getToken());
Assert.assertNotEquals(test.getToken(), "");
assertEquals(test.getName(), name);
assertNotNull(test.getToken());
assertNotEquals(test.getToken(), "");
gitLabApi.getDeployTokensApi().deleteGroupDeployToken(testGroup, test.getId());
List<DeployToken> deployTokens = gitLabApi.getDeployTokensApi().getGroupDeployTokens(testGroup);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -15,10 +15,11 @@ import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.Deployment;
import org.gitlab4j.api.models.DeploymentFilter;
import org.gitlab4j.api.models.Project;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in
......@@ -29,7 +30,8 @@ import org.junit.experimental.categories.Category;
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestDeploymentsApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -42,7 +44,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -54,7 +56,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
assumeTrue(testProject != null);
......@@ -68,7 +70,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
String environment = "environment-" + HelperUtils.getRandomInt(1000);
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject);
assertTrue("Commits list should not be empty.", commits.size() > 0);
assertTrue(commits.size() > 0, "Commits list should not be empty.");
Deployment deployment = gitLabApi.getDeploymentsApi().addDeployment(testProject,
environment,
......@@ -92,7 +94,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
String environment = "environment-" + HelperUtils.getRandomInt(1000);
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject);
assertTrue("Commits list should not be empty.", commits.size() > 0);
assertTrue(commits.size() > 0, "Commits list should not be empty.");
Deployment deployment = gitLabApi.getDeploymentsApi().addDeployment(testProject,
environment,
......@@ -126,7 +128,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject);
assertTrue("Commits list should not be empty.", commits.size() > 0);
assertTrue(commits.size() > 0, "Commits list should not be empty.");
Deployment deployment = gitLabApi.getDeploymentsApi().addDeployment(testProject,
environment,
......@@ -175,7 +177,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(testProject);
assertTrue("Commits list should not be empty.", commits.size() > 0);
assertTrue(commits.size() > 0, "Commits list should not be empty.");
for (int i = 0; i < 20; i++) {
gitLabApi.getDeploymentsApi().addDeployment(testProject,
......@@ -217,7 +219,7 @@ public class TestDeploymentsApi extends AbstractIntegrationTest {
filteredPager = gitLabApi.getDeploymentsApi().getProjectDeployments(testProject, deploymentFilter);
if (filteredPager.hasNext()) {
filteredPager.next();
assertTrue("Should be no deployments for environment `none`", filteredPager.current().size() == 0);
assertTrue(filteredPager.current().size() == 0, "Should be no deployments for environment `none`");
}
Stream<Deployment> projectDeploymentsStream = gitLabApi.getDeploymentsApi().getProjectDeploymentsStream(testProject);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.gitlab4j.api.models.Duration;
import org.gitlab4j.api.utils.DurationUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestDuration {
......
package org.gitlab4j.api;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.gitlab4j.api.utils.EmailChecker;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestEmailChecker {
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -13,11 +13,12 @@ import java.util.stream.Stream;
import org.gitlab4j.api.models.Environment;
import org.gitlab4j.api.models.Project;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in
......@@ -28,7 +29,8 @@ import org.junit.experimental.categories.Category;
* <p>
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestEnvironmentsApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -42,7 +44,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project
......@@ -53,7 +55,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
deleteAllTestAssets();
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
deleteAllTestAssets();
}
......@@ -79,9 +81,9 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
private static String getUniqueName() {
......
package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List;
import java.util.stream.Collectors;
......@@ -14,8 +14,8 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.Discussion;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
......@@ -28,9 +28,9 @@ public class TestEpicDiscussionsApi implements Constants {
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private MockResponse response;
@Before
@BeforeEach
public void setUp() throws Exception {
initMocks(this);
openMocks(this);
response = new MockResponse(Discussion.class, null, "epic-discussions.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.text.ParseException;
import java.util.Date;
......@@ -12,22 +12,25 @@ import org.gitlab4j.api.models.Event;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.User;
import org.gitlab4j.api.utils.ISO8601;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_NAMESPACE
* TEST_PROJECT_NAME
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestEventsApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -38,7 +41,7 @@ public class TestEventsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance
......@@ -54,7 +57,7 @@ public class TestEventsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Map;
import org.gitlab4j.api.models.Version;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestGitLabApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -35,15 +36,15 @@ public class TestGitLabApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment