Unverified Commit a1b28ea1 authored by Gautier de Saint Martin Lacaze's avatar Gautier de Saint Martin Lacaze
Browse files

Migrate from JUnit 4 to JUnit 5

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