diff --git a/pom.xml b/pom.xml index 88de950d50172f65a09fe9489174cd391a11ef85..78c91098b9f9056a19edcf6a353103c9eb066365 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 org.gitlab4j @@ -50,13 +52,14 @@ UTF-8 UTF-8 - 2.30.1 - 2.10.3 - 4.0.3 + 2.34 + 2.12.4 + 4.0.4 1.2.2 - 5.6.0 - 3.3.0 + 5.8.2 + 1.15.3 + 4.1.0 1.3 1.19.0 @@ -67,7 +70,7 @@ true true 8090 - + gitlab4j_gitlab4j-api gitlab4j https://sonarcloud.io @@ -121,15 +124,15 @@ - biz.aQute.bnd - bnd-maven-plugin - - - - bnd-process - - - + biz.aQute.bnd + bnd-maven-plugin + + + + bnd-process + + + @@ -179,20 +182,20 @@ - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.7 default-prepare-agent @@ -235,23 +238,24 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + 3.0.0-M5 - org.gitlab4j.api.IntegrationTest target/jacoco.exec + integration + org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M3 + 3.0.0-M5 - org.gitlab4j.api.IntegrationTest + integration - **/IntegrationTestSuite.java + **/*.java @@ -290,7 +294,7 @@ org.codehaus.mojo extra-enforcer-rules - 1.2 + 1.3 @@ -298,7 +302,7 @@ org.codehaus.mojo animal-sniffer-maven-plugin - 1.17 + 1.20 @@ -327,7 +331,8 @@ ${gitlab.skip-docker-start} - gitlab_rails['initial_root_password']="password"; gitlab_rails['lfs_enabled']=false; + gitlab_rails['initial_root_password']="password"; + gitlab_rails['lfs_enabled']=false; ${gitlab.port}:80 @@ -358,12 +363,12 @@ - - + se.bjurr.gitchangelog @@ -382,14 +387,14 @@ - biz.aQute.bnd - bnd-maven-plugin - ${bnd.version} - - biz.aQute.bnd + bnd-maven-plugin + ${bnd.version} + + - + @@ -435,8 +440,8 @@ - org.junit.vintage - junit-vintage-engine + org.junit.jupiter + junit-jupiter ${junit.version} test @@ -447,28 +452,27 @@ test - org.hamcrest - hamcrest-all - ${hamcrest.version} + org.mockito + mockito-junit-jupiter + ${mockito.version} test - com.github.stefanbirkner - system-rules - ${systemRules.version} + org.hamcrest + hamcrest-all + ${hamcrest.version} test - com.googlecode.junit-toolbox - junit-toolbox - 2.4 - test + uk.org.webcompere + system-stubs-jupiter + 1.2.0 - + org.codehaus.mojo.signature java18 diff --git a/src/test/java/org/gitlab4j/api/IntegrationTest.java b/src/test/java/org/gitlab4j/api/IntegrationTest.java deleted file mode 100644 index 19fc3dc4da64370266bd101588d72843ff9423fb..0000000000000000000000000000000000000000 --- a/src/test/java/org/gitlab4j/api/IntegrationTest.java +++ /dev/null @@ -1,22 +0,0 @@ -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. - *

To mark a test class as an integration test add the following lines before the class declaration:

- * - *

- * import org.junit.experimental.categories.Category;
- *
- * @Category(org.gitlab4j.api.IntegrationTest.class)
- * 
- */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IntegrationTest { -} diff --git a/src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java b/src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java index ce6bc29951c8968b82c25a3e59e9c64e8751dbdb..4df69c486b35655dad1ac6fe17ad2529b7c743f7 100644 --- a/src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java +++ b/src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java @@ -1,23 +1,23 @@ 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 pagerSpliterator; @@ -25,7 +25,7 @@ public class PagerSpliteratorTest { @Mock Pager 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()); } diff --git a/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java b/src/test/java/org/gitlab4j/api/SetupIntegrationTestExtension.java similarity index 86% rename from src/test/java/org/gitlab4j/api/IntegrationTestSuite.java rename to src/test/java/org/gitlab4j/api/SetupIntegrationTestExtension.java index df6adb43477dc8b8d60682ff63acb11c47c2c7a6..ef967ed12b1b2d74539265304a2a4b74368a67a7 100644 --- a/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java +++ b/src/test/java/org/gitlab4j/api/SetupIntegrationTestExtension.java @@ -1,12 +1,14 @@ 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. * *

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.

*/ -@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(); diff --git a/src/test/java/org/gitlab4j/api/TestAccessToken.java b/src/test/java/org/gitlab4j/api/TestAccessToken.java index 46b4747154f1714fcc6efb4946abc5458ebbeed8..1b442f0a400f488a3ea260f5dac2668243a13851 100644 --- a/src/test/java/org/gitlab4j/api/TestAccessToken.java +++ b/src/test/java/org/gitlab4j/api/TestAccessToken.java @@ -1,27 +1,29 @@ 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); diff --git a/src/test/java/org/gitlab4j/api/TestAccessTokenUtils.java b/src/test/java/org/gitlab4j/api/TestAccessTokenUtils.java index 7c554ca6fcc73d9965d10bc85f240c9ea839df4c..98c4d353a3b17ed632defb6c52d2fde65687d148 100644 --- a/src/test/java/org/gitlab4j/api/TestAccessTokenUtils.java +++ b/src/test/java/org/gitlab4j/api/TestAccessTokenUtils.java @@ -1,19 +1,20 @@ 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) { diff --git a/src/test/java/org/gitlab4j/api/TestApplicationSettingsApi.java b/src/test/java/org/gitlab4j/api/TestApplicationSettingsApi.java index 2c42e208a5f3dc8c94387091650ea8046810427d..82871a1400322cc4de0e3aa921fa5e4604c7db81 100644 --- a/src/test/java/org/gitlab4j/api/TestApplicationSettingsApi.java +++ b/src/test/java/org/gitlab4j/api/TestApplicationSettingsApi.java @@ -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; *

* 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); } diff --git a/src/test/java/org/gitlab4j/api/TestApplicationsApi.java b/src/test/java/org/gitlab4j/api/TestApplicationsApi.java index 5f37830d5b787d5f3a0b374a13317463d93a5e3e..8e3e26bb9a9a200d32693d8616ade567399959ba 100644 --- a/src/test/java/org/gitlab4j/api/TestApplicationsApi.java +++ b/src/test/java/org/gitlab4j/api/TestApplicationsApi.java @@ -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; *

* 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 diff --git a/src/test/java/org/gitlab4j/api/TestAvatarUpload.java b/src/test/java/org/gitlab4j/api/TestAvatarUpload.java index 11c6f24d0b5c78b954f0d5d0c7901bd121e39173..9490051462e72d323f74f8fba40adb065c571425 100644 --- a/src/test/java/org/gitlab4j/api/TestAvatarUpload.java +++ b/src/test/java/org/gitlab4j/api/TestAvatarUpload.java @@ -1,33 +1,34 @@ 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); diff --git a/src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java b/src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java index df3759b0cf39f1e0914d2aeea8e589eea176d2f1..e463151865036d22e0f1adb6848c42a3200de59f 100644 --- a/src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java +++ b/src/test/java/org/gitlab4j/api/TestCommitDiscussionsApi.java @@ -1,11 +1,11 @@ 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> 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); diff --git a/src/test/java/org/gitlab4j/api/TestCommitsApi.java b/src/test/java/org/gitlab4j/api/TestCommitsApi.java index f4f5379fa90bd6e9678b32da8d65ab6512f94463..0b1fc5624c639df6aee3cfa238b4b6ec27e58a2b 100644 --- a/src/test/java/org/gitlab4j/api/TestCommitsApi.java +++ b/src/test/java/org/gitlab4j/api/TestCommitsApi.java @@ -1,12 +1,12 @@ 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 commits = gitLabApi.getCommitsApi().getCommits(testProject.getId()); assertNotNull(commits); assertTrue(commits.size() > 0); - + List 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 commitRefs = gitLabApi.getCommitsApi().getCommitRefs(testProject.getId(), commits.get(0).getId()); assertNotNull(commitRefs); - + Stream 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 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 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 repoFileBranchCherryPicked = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, branch.getName()); diff --git a/src/test/java/org/gitlab4j/api/TestDeployKeysApi.java b/src/test/java/org/gitlab4j/api/TestDeployKeysApi.java index 965f0363f6565bc5189bce19ca7235af19c9fa14..4c7b4f31a46da1385f10bb07866bcd29f43b96ea 100644 --- a/src/test/java/org/gitlab4j/api/TestDeployKeysApi.java +++ b/src/test/java/org/gitlab4j/api/TestDeployKeysApi.java @@ -1,22 +1,24 @@ 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); } diff --git a/src/test/java/org/gitlab4j/api/TestDeployTokensApi.java b/src/test/java/org/gitlab4j/api/TestDeployTokensApi.java index 73d1e15e12ea462909a4daab77951d288fee270f..9cfc02fa655fd34ee1c1c972dcafe2b9f25c470f 100644 --- a/src/test/java/org/gitlab4j/api/TestDeployTokensApi.java +++ b/src/test/java/org/gitlab4j/api/TestDeployTokensApi.java @@ -1,8 +1,9 @@ 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 deployTokens = gitLabApi.getDeployTokensApi().getGroupDeployTokens(testGroup); diff --git a/src/test/java/org/gitlab4j/api/TestDeploymentsApi.java b/src/test/java/org/gitlab4j/api/TestDeploymentsApi.java index fc048fdce809a7f5ae9ca891e71302fd93613398..5191b9bc617c2cf0ca1a134555eab78d382ae8d5 100644 --- a/src/test/java/org/gitlab4j/api/TestDeploymentsApi.java +++ b/src/test/java/org/gitlab4j/api/TestDeploymentsApi.java @@ -1,10 +1,10 @@ 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 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 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 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 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 projectDeploymentsStream = gitLabApi.getDeploymentsApi().getProjectDeploymentsStream(testProject); diff --git a/src/test/java/org/gitlab4j/api/TestDuration.java b/src/test/java/org/gitlab4j/api/TestDuration.java index 68498c1d2cd7b088235d1664819f190f46524f70..071306892bf4c7aed1c0809958b2de40c92cc75f 100644 --- a/src/test/java/org/gitlab4j/api/TestDuration.java +++ b/src/test/java/org/gitlab4j/api/TestDuration.java @@ -1,11 +1,11 @@ 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 { diff --git a/src/test/java/org/gitlab4j/api/TestEmailChecker.java b/src/test/java/org/gitlab4j/api/TestEmailChecker.java index 6ffe2e230d6094b42b043bc700c688a44af60151..73abef6af88b2c7498ff1e57aecd18fd9edcd058 100644 --- a/src/test/java/org/gitlab4j/api/TestEmailChecker.java +++ b/src/test/java/org/gitlab4j/api/TestEmailChecker.java @@ -1,10 +1,10 @@ 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 { diff --git a/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java b/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java index 6082a2bf46c5c54cb328b15aeb7a9d81a7b71d2f..f94eb1921e4afc4c25efa4cdda72fba66553c2e4 100644 --- a/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java +++ b/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java @@ -1,10 +1,10 @@ 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; *

* 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() { diff --git a/src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java b/src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java index 0f9e0330b3e4ef959e1f3e8354cc1f744c4509f9..f8127ead070e31b3e6f5e1caf9e1ac48d5252be8 100644 --- a/src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java +++ b/src/test/java/org/gitlab4j/api/TestEpicDiscussionsApi.java @@ -1,11 +1,11 @@ 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> 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); diff --git a/src/test/java/org/gitlab4j/api/TestEventsApi.java b/src/test/java/org/gitlab4j/api/TestEventsApi.java index 72f7ea146fe2e84f973609b606a147c5b11d096d..5b398206e30a2f77e7c4bff167aa9b961e22661c 100644 --- a/src/test/java/org/gitlab4j/api/TestEventsApi.java +++ b/src/test/java/org/gitlab4j/api/TestEventsApi.java @@ -1,8 +1,8 @@ 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); } diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApi.java b/src/test/java/org/gitlab4j/api/TestGitLabApi.java index 58548c122acd72cc9c3084860c0b06606018444f..8effd5c2faa5d532344cb70dfee4ebeb331cf993 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApi.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApi.java @@ -1,27 +1,28 @@ 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 diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java index 93e774e5e513341b73ddd72ebc3d1d9eb1a3d7a8..77a3c424ab008190171443591f9b4842ccdb555c 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java @@ -28,7 +28,7 @@ import static org.gitlab4j.api.JsonUtils.readTreeFromResource; import static org.gitlab4j.api.JsonUtils.unmarshalResource; import static org.gitlab4j.api.JsonUtils.unmarshalResourceList; import static org.gitlab4j.api.JsonUtils.unmarshalResourceMap; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import java.util.Map; @@ -112,7 +112,7 @@ import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.SlackService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java b/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java index 14f2ea6bad58744dcd717eba6df0face9d3799fb..535c15a2862b547131de17356d68d58a91257d99 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java @@ -4,11 +4,11 @@ package org.gitlab4j.api; import static org.gitlab4j.api.JsonUtils.compareJson; import static org.gitlab4j.api.JsonUtils.readTreeFromResource; import static org.gitlab4j.api.JsonUtils.unmarshalResource; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -25,7 +25,8 @@ import org.gitlab4j.api.systemhooks.SystemHookListener; import org.gitlab4j.api.systemhooks.SystemHookManager; import org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent; import org.gitlab4j.api.utils.JacksonJson; -import org.gitlab4j.api.webhook.*; +import org.gitlab4j.api.webhook.BuildEvent; +import org.gitlab4j.api.webhook.ChangeContainer; import org.gitlab4j.api.webhook.Event; import org.gitlab4j.api.webhook.IssueEvent; import org.gitlab4j.api.webhook.JobEvent; @@ -35,9 +36,9 @@ import org.gitlab4j.api.webhook.PipelineEvent; import org.gitlab4j.api.webhook.PushEvent; import org.gitlab4j.api.webhook.TagPushEvent; import org.gitlab4j.api.webhook.WikiPageEvent; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializationFeature; @@ -52,14 +53,14 @@ public class TestGitLabApiEvents { super(); } - @BeforeClass + @BeforeAll public static void setup() throws Exception { jacksonJson = new JacksonJson(); jacksonJson.getObjectMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); savedLevel = GitLabApi.getLogger().getLevel(); } - @AfterClass + @AfterAll public static void teardown() { GitLabApi.getLogger().setLevel(savedLevel); } diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiException.java b/src/test/java/org/gitlab4j/api/TestGitLabApiException.java index 38b6879a148f07efe9af18de5ae1dfc858986f83..bbf17d63e2867087324cf7db810325a17498173d 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiException.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiException.java @@ -1,11 +1,11 @@ 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.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Map; @@ -14,11 +14,12 @@ import javax.ws.rs.core.Response.Status; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Visibility; -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 @@ -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 TestGitLabApiException extends AbstractIntegrationTest { private static final String TEST_PROJECT_NAME_DUPLICATE = "test-gitlab4j-create-project-duplicate"; @@ -45,7 +47,7 @@ public class TestGitLabApiException extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server gitLabApi = baseTestSetup(); @@ -53,7 +55,7 @@ public class TestGitLabApiException extends AbstractIntegrationTest { deleteAllTestProjects(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestProjects(); } @@ -67,9 +69,9 @@ public class TestGitLabApiException extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestGitLabLogin.java b/src/test/java/org/gitlab4j/api/TestGitLabLogin.java index 20f90e8af58be26bfc1c982bc75e96b9aaae487d..2faa6d9b4a34f51cfa2f0025d31360311616fccb 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabLogin.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabLogin.java @@ -1,26 +1,28 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.gitlab4j.api.models.Version; import org.gitlab4j.api.utils.SecretString; -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_LOGIN_USERNAME * TEST_LOGIN_PASSWORD * 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 TestGitLabLogin implements PropertyConstants { // The following needs to be set to your test repository @@ -35,7 +37,7 @@ public class TestGitLabLogin implements PropertyConstants { super(); } - @BeforeClass + @BeforeAll public static void setup() { problems = ""; @@ -61,7 +63,7 @@ public class TestGitLabLogin implements PropertyConstants { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(problems != null && problems.isEmpty()); } diff --git a/src/test/java/org/gitlab4j/api/TestGroupApi.java b/src/test/java/org/gitlab4j/api/TestGroupApi.java index 40b9e9846831d19b5042961764f927a72b59be5a..0b1f023da3d0ea1665bebce31252df19c760206a 100644 --- a/src/test/java/org/gitlab4j/api/TestGroupApi.java +++ b/src/test/java/org/gitlab4j/api/TestGroupApi.java @@ -1,11 +1,10 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; -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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Optional; @@ -19,11 +18,12 @@ import org.gitlab4j.api.models.Group; import org.gitlab4j.api.models.GroupParams; import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.User; -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 @@ -37,7 +37,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 TestGroupApi extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -53,7 +54,7 @@ public class TestGroupApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -84,7 +85,7 @@ public class TestGroupApi extends AbstractIntegrationTest { removeGroupMembers(); } - @AfterClass + @AfterAll public static void teardown() { removeGroupMembers(); } @@ -113,11 +114,11 @@ public class TestGroupApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); - assumeNotNull(testGroup); - assumeNotNull(testUser); + assumeTrue(gitLabApi != null); + assumeTrue(testGroup != null); + assumeTrue(testUser != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestGroupCustomAttributes.java b/src/test/java/org/gitlab4j/api/TestGroupCustomAttributes.java index c636f1beee7f3cb678eb8af024aef76318b29f5d..08c61b2fb4cdd950ede348d53c43d2c1cfec2785 100644 --- a/src/test/java/org/gitlab4j/api/TestGroupCustomAttributes.java +++ b/src/test/java/org/gitlab4j/api/TestGroupCustomAttributes.java @@ -23,11 +23,11 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Optional; @@ -35,11 +35,12 @@ import java.util.stream.Stream; import org.gitlab4j.api.models.CustomAttribute; import org.gitlab4j.api.models.Group; -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 @@ -51,7 +52,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 TestGroupCustomAttributes extends AbstractIntegrationTest { private static final String TEST_CUSTOM_ATTRIBUTE_KEY = "GitLab4JCustomAttributeTestKey"; @@ -64,7 +66,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Group instance @@ -74,7 +76,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { deleteAllTestCustomAttributes(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestCustomAttributes(); } @@ -95,9 +97,9 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } private CustomAttribute createCustomAttribute(String key, String value) throws GitLabApiException { @@ -116,7 +118,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { @Test public void testUpdate() throws GitLabApiException { - assumeNotNull(testGroup); + assumeTrue(testGroup != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestUpdate"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE; @@ -134,7 +136,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { @Test public void testGetCustomAttribute() throws GitLabApiException { - assumeNotNull(testGroup); + assumeTrue(testGroup != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestGet"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test get)"; @@ -151,7 +153,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { @Test public void testListCustomAttributes() throws GitLabApiException { - assumeNotNull(testGroup); + assumeTrue(testGroup != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestList"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test list)"; @@ -171,7 +173,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest { @Test public void testDeleteCustomAttribute() throws GitLabApiException { - assumeNotNull(testGroup); + assumeTrue(testGroup != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestDelete"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test delete)"; diff --git a/src/test/java/org/gitlab4j/api/TestHealthCheckApi.java b/src/test/java/org/gitlab4j/api/TestHealthCheckApi.java index 05cce424d7f1ccebcf792c7454c61a3a51e37476..c4e57586a0768dcd6f08fea2661507e9c75de5d6 100644 --- a/src/test/java/org/gitlab4j/api/TestHealthCheckApi.java +++ b/src/test/java/org/gitlab4j/api/TestHealthCheckApi.java @@ -1,14 +1,15 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.gitlab4j.api.models.HealthCheckInfo; import org.gitlab4j.api.utils.AccessTokenUtils; -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 @@ -19,7 +20,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 TestHealthCheckApi implements PropertyConstants { // The following needs to be set to your test repository @@ -33,7 +35,7 @@ public class TestHealthCheckApi implements PropertyConstants { super(); } - @BeforeClass + @BeforeAll public static void setup() throws GitLabApiException { String problems = ""; @@ -59,7 +61,7 @@ public class TestHealthCheckApi implements PropertyConstants { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(gitLabApi != null); } diff --git a/src/test/java/org/gitlab4j/api/TestISO8601.java b/src/test/java/org/gitlab4j/api/TestISO8601.java index 00a175d780f19c75e261b0f0825d07e1b53062ad..315876f82fc304835e13f6695882d356e5323d6d 100644 --- a/src/test/java/org/gitlab4j/api/TestISO8601.java +++ b/src/test/java/org/gitlab4j/api/TestISO8601.java @@ -1,12 +1,12 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.text.ParseException; import java.util.Date; import org.gitlab4j.api.utils.ISO8601; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestISO8601 { diff --git a/src/test/java/org/gitlab4j/api/TestIgnoreCertificateErrors.java b/src/test/java/org/gitlab4j/api/TestIgnoreCertificateErrors.java index 172b8d81c23baf9f774a06e718208873371c583d..4ced681f69855b775e888d5742736d982c7266bd 100644 --- a/src/test/java/org/gitlab4j/api/TestIgnoreCertificateErrors.java +++ b/src/test/java/org/gitlab4j/api/TestIgnoreCertificateErrors.java @@ -1,16 +1,17 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +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 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 @@ -21,7 +22,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 TestIgnoreCertificateErrors implements PropertyConstants { // The following needs to be set to your test repository @@ -34,7 +36,7 @@ public class TestIgnoreCertificateErrors implements PropertyConstants { super(); } - @BeforeClass + @BeforeAll public static void setup() { String problems = ""; @@ -54,7 +56,7 @@ public class TestIgnoreCertificateErrors implements PropertyConstants { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(setupOk); } diff --git a/src/test/java/org/gitlab4j/api/TestImportExportApi.java b/src/test/java/org/gitlab4j/api/TestImportExportApi.java index e3e1f54d0ff82c9f7669ce1d0fc11d75268e3aa5..99353a5da0490dce58cda5a544bdb1a87226b2ca 100644 --- a/src/test/java/org/gitlab4j/api/TestImportExportApi.java +++ b/src/test/java/org/gitlab4j/api/TestImportExportApi.java @@ -23,11 +23,11 @@ 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.assumeNotNull; +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.io.File; import java.util.Optional; @@ -35,13 +35,14 @@ import java.util.Optional; import org.gitlab4j.api.models.ExportStatus; import org.gitlab4j.api.models.ImportStatus; import org.gitlab4j.api.models.Project; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -53,8 +54,9 @@ import org.junit.runners.MethodSorters; * * 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 TestImportExportApi extends AbstractIntegrationTest { private static final String TEST_IMPORT_PROJECT_NAME = "test-import-project"; @@ -65,7 +67,7 @@ public class TestImportExportApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -75,7 +77,7 @@ public class TestImportExportApi extends AbstractIntegrationTest { deleteAllTestProjects(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestProjects(); } @@ -91,16 +93,16 @@ public class TestImportExportApi extends AbstractIntegrationTest { } catch (GitLabApiException ignore) {} } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test public void testExportDownloadAndImport() throws GitLabApiException { // Arrange - assumeNotNull(testProject); + assumeTrue(testProject != null); // Act gitLabApi.getImportExportApi().scheduleExport(testProject); diff --git a/src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java b/src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java index b2117ec10f0efbcc25f7adfb42f468c78df11077..e8598cad7e95624c4196409113f22d329ccaab75 100644 --- a/src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java +++ b/src/test/java/org/gitlab4j/api/TestIssueDiscussionsApi.java @@ -1,11 +1,11 @@ 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 TestIssueDiscussionsApi implements Constants { @Captor private ArgumentCaptor> attributeCaptor; private MockResponse response; - @Before + @BeforeEach public void setUp() throws Exception { - initMocks(this); + openMocks(this); response = new MockResponse(Discussion.class, null, "issue-discussions.json"); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); diff --git a/src/test/java/org/gitlab4j/api/TestIssuesApi.java b/src/test/java/org/gitlab4j/api/TestIssuesApi.java index faa8a79852a79936cd62221cf484cf7a1b79781a..04966dc7a8b7a595e24bb91b74b51ae2726edf83 100644 --- a/src/test/java/org/gitlab4j/api/TestIssuesApi.java +++ b/src/test/java/org/gitlab4j/api/TestIssuesApi.java @@ -23,11 +23,11 @@ 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.Arrays; import java.util.Date; @@ -44,11 +44,12 @@ import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.IssueFilter; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.TimeStats; -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 @@ -60,7 +61,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 TestIssuesApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -76,7 +78,7 @@ public class TestIssuesApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -91,12 +93,12 @@ public class TestIssuesApi extends AbstractIntegrationTest { deleteAllTestIssues(); } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestIssues(); } @@ -157,7 +159,7 @@ public class TestIssuesApi extends AbstractIntegrationTest { @Test public void testGetGroupIssues() throws GitLabApiException { - assumeNotNull(testGroup); + assumeTrue(testGroup != null); List issues = gitLabApi.getIssuesApi().getGroupIssues(testGroup); assertNotNull(issues); } diff --git a/src/test/java/org/gitlab4j/api/TestJobApi.java b/src/test/java/org/gitlab4j/api/TestJobApi.java index f7411fe0ddf25b2e30a466e81d274547cdb87edb..d25372e897ff3c686659007f4012440cba54160d 100644 --- a/src/test/java/org/gitlab4j/api/TestJobApi.java +++ b/src/test/java/org/gitlab4j/api/TestJobApi.java @@ -23,18 +23,19 @@ 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 java.util.List; import org.gitlab4j.api.models.Job; 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 ~/test-gitlab4j.properties @@ -46,7 +47,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 TestJobApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -56,20 +58,20 @@ public class TestJobApi 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(); testProject = getTestProject(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(testProject); + assumeTrue(testProject != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestLabelsApi.java b/src/test/java/org/gitlab4j/api/TestLabelsApi.java index bbf7243bbe0d092347e5f27e44e492061f1d2747..2eb1632e49dc9f8e67188e08be72c05d154b00d8 100644 --- a/src/test/java/org/gitlab4j/api/TestLabelsApi.java +++ b/src/test/java/org/gitlab4j/api/TestLabelsApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Optional; @@ -13,13 +13,15 @@ import java.util.stream.Stream; import org.gitlab4j.api.models.Group; import org.gitlab4j.api.models.Label; 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; - -@Category(IntegrationTest.class) +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; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestLabelsApi extends AbstractIntegrationTest { private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY); @@ -36,7 +38,7 @@ public class TestLabelsApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void testSetup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -60,7 +62,7 @@ public class TestLabelsApi extends AbstractIntegrationTest { deleteTestLabels(); } - @AfterClass + @AfterAll public static void tearDown() { deleteTestLabels(); } @@ -86,7 +88,7 @@ public class TestLabelsApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(testProject != null); } diff --git a/src/test/java/org/gitlab4j/api/TestMarkdownApi.java b/src/test/java/org/gitlab4j/api/TestMarkdownApi.java index dc4cf661bb839ab36d2e7866c64dcd650002c137..77ec685696aff8864fadf890ac007861ec713fb8 100644 --- a/src/test/java/org/gitlab4j/api/TestMarkdownApi.java +++ b/src/test/java/org/gitlab4j/api/TestMarkdownApi.java @@ -1,15 +1,17 @@ package org.gitlab4j.api; -import org.gitlab4j.api.models.Markdown; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import static org.junit.Assert.*; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeTrue; -@Category(IntegrationTest.class) +import org.gitlab4j.api.models.Markdown; +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; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestMarkdownApi extends AbstractIntegrationTest { private static final String EXPECTED_HTML_FOR_SPECIAL = "

Hello world! 🎉 xml <profiles> <version>${maven-surefire-plugin.version}</version> </profiles>

"; @@ -30,12 +32,12 @@ public class TestMarkdownApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { gitLabApi = baseTestSetup(); } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(gitLabApi != null); } diff --git a/src/test/java/org/gitlab4j/api/TestMergeRequestApi.java b/src/test/java/org/gitlab4j/api/TestMergeRequestApi.java index ebd4691666d267db92c3c42507020c6ddba20f0d..78414f16f0dc29ac5ff46a440c6be6002c0b96c9 100644 --- a/src/test/java/org/gitlab4j/api/TestMergeRequestApi.java +++ b/src/test/java/org/gitlab4j/api/TestMergeRequestApi.java @@ -1,12 +1,12 @@ package org.gitlab4j.api; import static java.util.stream.Collectors.toList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeNotNull; +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.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; @@ -21,13 +21,14 @@ import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.User; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -41,8 +42,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestMergeRequestApi extends AbstractIntegrationTest { private static final String TEST_BRANCH_NAME = "feature/gitlab4j-merge-request-test"; @@ -59,7 +61,7 @@ public class TestMergeRequestApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -70,7 +72,7 @@ public class TestMergeRequestApi extends AbstractIntegrationTest { teardown(); } - @AfterClass + @AfterAll public static void teardown() { if (testProject == null) { @@ -101,9 +103,9 @@ public class TestMergeRequestApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(testProject); + assumeTrue(testProject != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java b/src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java index ab4fe4247ab02027aff493e829b1ce8fc119568f..1874692c48a49a12118a2dd1406b0b414573f7f5 100644 --- a/src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java +++ b/src/test/java/org/gitlab4j/api/TestMergeRequestDiscussionsApi.java @@ -1,11 +1,11 @@ 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 TestMergeRequestDiscussionsApi implements Constants { @Captor private ArgumentCaptor> attributeCaptor; private MockResponse response; - @Before + @BeforeEach public void setUp() throws Exception { - initMocks(this); + openMocks(this); response = new MockResponse(Discussion.class, null, "merge-request-discussions.json"); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); diff --git a/src/test/java/org/gitlab4j/api/TestNamespaceApi.java b/src/test/java/org/gitlab4j/api/TestNamespaceApi.java index dd2bfb33aa39542d64453c9026594948236d1ff5..2ce7ef41685cac113d7f8787f1cf7c3b0878f0b2 100644 --- a/src/test/java/org/gitlab4j/api/TestNamespaceApi.java +++ b/src/test/java/org/gitlab4j/api/TestNamespaceApi.java @@ -1,31 +1,33 @@ 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.assumeNotNull; +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; import org.gitlab4j.api.models.Namespace; -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_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 TestNamespaceApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -34,15 +36,15 @@ public class TestNamespaceApi 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 @@ -51,7 +53,7 @@ public class TestNamespaceApi extends AbstractIntegrationTest { assertNotNull(namespaces); Optional matchingNamespace = namespaces.stream(). filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst(); - assertTrue(TEST_NAMESPACE + " not found!", matchingNamespace.isPresent()); + assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!"); } @Test @@ -76,7 +78,7 @@ public class TestNamespaceApi extends AbstractIntegrationTest { assertNotNull(namespaces); Optional matchingNamespace = namespaces.stream(). filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst(); - assertTrue(TEST_NAMESPACE + " not found!", matchingNamespace.isPresent()); + assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!"); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestNotesApi.java b/src/test/java/org/gitlab4j/api/TestNotesApi.java index 6e9da837105809a9800d64adc5a0fa036d90a2c9..e1c0b19f915e2ffa97fd486d82ae6376bbb3bf94 100644 --- a/src/test/java/org/gitlab4j/api/TestNotesApi.java +++ b/src/test/java/org/gitlab4j/api/TestNotesApi.java @@ -1,7 +1,7 @@ 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 java.util.List; @@ -10,12 +10,13 @@ import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.MergeRequest; import org.gitlab4j.api.models.Note; import org.gitlab4j.api.models.Project; -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 @@ -27,8 +28,9 @@ import org.junit.runners.MethodSorters; * * 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 TestNotesApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -37,15 +39,15 @@ public class TestNotesApi 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 diff --git a/src/test/java/org/gitlab4j/api/TestNotificationSettingsApi.java b/src/test/java/org/gitlab4j/api/TestNotificationSettingsApi.java index 6d3ec4b7c785752305ce7d063be66ab7e8e652db..9685a8ce375b61051807b7e723839451525f1777 100644 --- a/src/test/java/org/gitlab4j/api/TestNotificationSettingsApi.java +++ b/src/test/java/org/gitlab4j/api/TestNotificationSettingsApi.java @@ -1,22 +1,23 @@ 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.Assume.assumeFalse; -import static org.junit.Assume.assumeNotNull; +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.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import org.gitlab4j.api.models.Group; import org.gitlab4j.api.models.NotificationSettings; import org.gitlab4j.api.models.Project; -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 @@ -29,8 +30,9 @@ import org.junit.runners.MethodSorters; * * 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 TestNotificationSettingsApi extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -42,15 +44,15 @@ public class TestNotificationSettingsApi 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 diff --git a/src/test/java/org/gitlab4j/api/TestOauth2LoginStreamingOutput.java b/src/test/java/org/gitlab4j/api/TestOauth2LoginStreamingOutput.java index 98d0136af749e30a8f3742d4c03f9e281c2263cf..f3594228ebb7cd099c460248a7fab27bb5290b46 100644 --- a/src/test/java/org/gitlab4j/api/TestOauth2LoginStreamingOutput.java +++ b/src/test/java/org/gitlab4j/api/TestOauth2LoginStreamingOutput.java @@ -1,12 +1,12 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import org.gitlab4j.api.utils.Oauth2LoginStreamingOutput; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/org/gitlab4j/api/TestPackageApi.java b/src/test/java/org/gitlab4j/api/TestPackageApi.java index 1ccf1178d1564ffbd7a3eba4e81993324d7c5fcd..4e6e233c0bbb87a10a26450c7772c69cee254ad5 100644 --- a/src/test/java/org/gitlab4j/api/TestPackageApi.java +++ b/src/test/java/org/gitlab4j/api/TestPackageApi.java @@ -2,16 +2,23 @@ package org.gitlab4j.api; import org.gitlab4j.api.models.*; import org.gitlab4j.api.models.Package; -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.Disabled; +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; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.*; -import static org.junit.Assert.*; -import static org.junit.Assume.assumeNotNull; -@Category(IntegrationTest.class) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestPackageApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -21,18 +28,19 @@ public class TestPackageApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { gitLabApi = baseTestSetup(); testProject = getTestProject(); } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); - assumeNotNull(testProject); + assumeTrue(gitLabApi != null); + assumeTrue(testProject != null); } + @Disabled("need creation of a package through CI") @Test public void getPackagesStream() throws GitLabApiException { PackagesApi packagesApi = gitLabApi.getPackagesApi(); diff --git a/src/test/java/org/gitlab4j/api/TestPager.java b/src/test/java/org/gitlab4j/api/TestPager.java index 9ccb724c73ed2b64ce16a20a57c63bd7a63018a1..08998ab2670ee4963f1eb0a49e43b7438cbf31d0 100644 --- a/src/test/java/org/gitlab4j/api/TestPager.java +++ b/src/test/java/org/gitlab4j/api/TestPager.java @@ -1,9 +1,9 @@ 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.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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; @@ -11,12 +11,13 @@ import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.Project; -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 @@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestPager extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -40,15 +42,15 @@ public class TestPager 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 diff --git a/src/test/java/org/gitlab4j/api/TestPipelineApi.java b/src/test/java/org/gitlab4j/api/TestPipelineApi.java index e4e95271775952d8628fe9c16516ccc0d1a35999..cf29e94be0ba7e7410f30c54756bf2e212a84564 100644 --- a/src/test/java/org/gitlab4j/api/TestPipelineApi.java +++ b/src/test/java/org/gitlab4j/api/TestPipelineApi.java @@ -1,11 +1,11 @@ package org.gitlab4j.api; import static java.util.stream.Collectors.toList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -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.assertFalse; +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.util.ArrayList; import java.util.HashMap; @@ -20,13 +20,15 @@ import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.Trigger; import org.gitlab4j.api.models.Variable; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +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; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestPipelineApi extends AbstractIntegrationTest { private static final String SCHEDULE_DESCRIPTION = "Test pipeline schedule - DELETE AFTER TEST"; @@ -80,7 +82,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { } } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance gitLabApi = baseTestSetup(); @@ -104,14 +106,14 @@ public class TestPipelineApi extends AbstractIntegrationTest { } } - @AfterClass + @AfterAll public static void teardown() { deleteTestResources(); } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test @@ -219,7 +221,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { assertNotNull(testProject); // Skip this test if no .gitlab-ci.yml file is in the test project - assumeNotNull(gitlabCiYml); + assumeTrue(gitlabCiYml != null); String triggerDescription = TRIGGER_DESCRIPTION + " - test triggerPipeline() - " + HelperUtils.getRandomInt(1000); Trigger createdTrigger = gitLabApi.getPipelineApi().createPipelineTrigger(testProject, triggerDescription); @@ -241,7 +243,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { public void testCreatePipelineNoVariables() throws GitLabApiException { // Skip this test if no .gitlab-ci.yml file is in the test project - assumeNotNull(gitlabCiYml); + assumeTrue(gitlabCiYml != null); // Act Pipeline pipeline = gitLabApi.getPipelineApi().createPipeline(testProject, "master"); @@ -256,7 +258,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { public void testCreatePipelineWithVariables() throws GitLabApiException { // Skip this test if no .gitlab-ci.yml file is in the test project - assumeNotNull(gitlabCiYml); + assumeTrue(gitlabCiYml != null); // Arrange List variableList = new ArrayList<>(); @@ -276,7 +278,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { public void testCreatePipelineWithMapVariables() throws GitLabApiException { // Skip this test if no .gitlab-ci.yml file is in the test project - assumeNotNull(gitlabCiYml); + assumeTrue(gitlabCiYml != null); // Arrange Map variableMap = new HashMap<>(); @@ -296,7 +298,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { public void testPipelineVariables() throws GitLabApiException { // Skip this test if no .gitlab-ci.yml file is in the test project - assumeNotNull(gitlabCiYml); + assumeTrue(gitlabCiYml != null); // Arrange Map variableMap = new HashMap<>(); diff --git a/src/test/java/org/gitlab4j/api/TestProjectApi.java b/src/test/java/org/gitlab4j/api/TestProjectApi.java index ee47fe1fcc479dbb251feae2d19140f89c68a362..43dfcc3a5a84a041ddfc086428d61ed842a32148 100644 --- a/src/test/java/org/gitlab4j/api/TestProjectApi.java +++ b/src/test/java/org/gitlab4j/api/TestProjectApi.java @@ -23,13 +23,12 @@ 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.assertNull; -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.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +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.Arrays; import java.util.List; @@ -49,13 +48,14 @@ import org.gitlab4j.api.models.ProjectFilter; import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.models.Visibility; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -70,8 +70,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestProjectApi extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -96,7 +97,7 @@ public class TestProjectApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -107,7 +108,7 @@ public class TestProjectApi extends AbstractIntegrationTest { deleteAllTransientTestData(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTransientTestData(); } @@ -186,9 +187,9 @@ public class TestProjectApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test @@ -402,7 +403,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testListStarredProjects() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); try { gitLabApi.getProjectApi().starProject(testProject); @@ -425,7 +426,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testListStarredProjectsWithParams() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); try { gitLabApi.getProjectApi().starProject(testProject); @@ -560,7 +561,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testCreateProjectInNamespace() throws GitLabApiException { - assumeNotNull(currentUser); + assumeTrue(currentUser != null); Project namespaceProject = null; try { @@ -602,7 +603,7 @@ public class TestProjectApi extends AbstractIntegrationTest { assumeTrue(TEST_GROUP != null && TEST_GROUP_PROJECT != null); assumeTrue(TEST_GROUP.trim().length() > 0 && TEST_GROUP_PROJECT.trim().length() > 0); - assumeNotNull(testProject); + assumeTrue(testProject != null); List groups = gitLabApi.getGroupApi().getGroups(TEST_GROUP); assertNotNull(groups); @@ -647,7 +648,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testStarAndUnstarProject() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); try { gitLabApi.getProjectApi().unstarProject(testProject); @@ -686,7 +687,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testVariables() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String value = "ABCDEFG12345678" + HelperUtils.getRandomInt(); @@ -736,7 +737,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testFileVariable() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String value = "/tmp/test.txt"; @@ -758,7 +759,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testGetMembers() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); // Act List members = gitLabApi.getProjectApi().getMembers(testProject); @@ -770,7 +771,7 @@ public class TestProjectApi extends AbstractIntegrationTest { @Test public void testAllMemberOperations() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); // Act List members = gitLabApi.getProjectApi().getAllMembers(testProject); diff --git a/src/test/java/org/gitlab4j/api/TestProjectApiSnippets.java b/src/test/java/org/gitlab4j/api/TestProjectApiSnippets.java index b5a5d31f66859e66a448bdb0955982a658e778d3..133728cf83baed928ebeb8733384b91865c26fa4 100644 --- a/src/test/java/org/gitlab4j/api/TestProjectApiSnippets.java +++ b/src/test/java/org/gitlab4j/api/TestProjectApiSnippets.java @@ -23,21 +23,22 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -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.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.Visibility; -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 @@ -49,7 +50,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 TestProjectApiSnippets extends AbstractIntegrationTest { private static final String TEST_SNIPPET_TITLE_PREFIX = "Test Snippet: "; @@ -60,7 +62,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -70,7 +72,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { deleteAllTestSnippets(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestSnippets(); } @@ -91,9 +93,9 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } private Snippet createSnippet(String title, String filename, String description, @@ -118,7 +120,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { @Test public void testUpdate() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String title = TEST_SNIPPET_TITLE_PREFIX + "Test createSnippet()"; String filename = "test-update-snippet.js"; @@ -137,7 +139,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { @Test public void testListSnippets() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()"; String filename = "test-list-snippets.js"; @@ -162,7 +164,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { @Test public void testDeleteSnippet() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()"; String filename = "test-delete-snippet.js"; @@ -187,7 +189,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { @Test public void testSnippetContent() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String title = TEST_SNIPPET_TITLE_PREFIX + "Test getRawSnippetContent()"; String filename = "test-raw-snippet.js"; diff --git a/src/test/java/org/gitlab4j/api/TestProjectCustomAttributes.java b/src/test/java/org/gitlab4j/api/TestProjectCustomAttributes.java index 92da204c7ba0157a3219cb9b9360903a1c1938e8..70e58a20c744a319dfbd87888414c3101bdafb5b 100644 --- a/src/test/java/org/gitlab4j/api/TestProjectCustomAttributes.java +++ b/src/test/java/org/gitlab4j/api/TestProjectCustomAttributes.java @@ -23,11 +23,11 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Optional; @@ -35,11 +35,12 @@ import java.util.stream.Stream; import org.gitlab4j.api.models.CustomAttribute; 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 ~/test-gitlab4j.properties @@ -51,7 +52,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 TestProjectCustomAttributes extends AbstractIntegrationTest { private static final String TEST_CUSTOM_ATTRIBUTE_KEY = "GitLab4JCustomAttributeTestKey"; @@ -64,7 +66,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -74,7 +76,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { deleteAllTestCustomAttributes(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestCustomAttributes(); } @@ -95,9 +97,9 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } private CustomAttribute createCustomAttribute(String key, String value) throws GitLabApiException { @@ -116,7 +118,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { @Test public void testUpdate() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestUpdate"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE; @@ -134,7 +136,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { @Test public void testGetCustomAttribute() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestGet"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test get)"; @@ -151,7 +153,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { @Test public void testListCustomAttributes() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestList"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test list)"; @@ -171,7 +173,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { @Test public void testDeleteCustomAttribute() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestDelete"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test delete)"; diff --git a/src/test/java/org/gitlab4j/api/TestProtectedBranchesApi.java b/src/test/java/org/gitlab4j/api/TestProtectedBranchesApi.java index 6288a5d010b96b18076de58e1f3620b53f6a8ca3..842fad9a7a3ec2ed32c35a4acd5ea163d2ed7139 100644 --- a/src/test/java/org/gitlab4j/api/TestProtectedBranchesApi.java +++ b/src/test/java/org/gitlab4j/api/TestProtectedBranchesApi.java @@ -1,22 +1,23 @@ 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.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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.ProtectedBranch; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestProtectedBranchesApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -41,14 +43,14 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { private static final String TEST_BRANCH_NAME = "feature/test_branch"; private static final String TEST_PROTECT_BRANCH_NAME = "feature/protect_branch"; - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance gitLabApi = baseTestSetup(); testProject = getTestProject(); } - @AfterClass + @AfterAll public static void teardown() { if (testProject != null) { try { @@ -65,9 +67,9 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); Branch protectedBranch; try { @@ -90,7 +92,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { @Test public void testGetProtectedBranches() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); List branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject); assertNotNull(branches); assertTrue(branches.stream() @@ -100,7 +102,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { @Test public void testUnprotectBranch() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); gitLabApi.getProtectedBranchesApi().unprotectBranch(testProject, TEST_PROTECT_BRANCH_NAME); List branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject); assertNotNull(branches); @@ -111,7 +113,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { @Test public void testProtectBranch() throws GitLabApiException { - assumeNotNull(testProject); + assumeTrue(testProject != null); ProtectedBranch branch = gitLabApi.getProtectedBranchesApi().protectBranch(testProject, TEST_BRANCH_NAME); assertNotNull(branch); diff --git a/src/test/java/org/gitlab4j/api/TestReleasesApi.java b/src/test/java/org/gitlab4j/api/TestReleasesApi.java index dc8ca1d0d17c2361fa6ac7d95f0bdb29ab96470a..e343ecd1f5f4858e70df4ab805e87edad505c0ed 100644 --- a/src/test/java/org/gitlab4j/api/TestReleasesApi.java +++ b/src/test/java/org/gitlab4j/api/TestReleasesApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Collections; import java.util.Date; @@ -15,13 +15,15 @@ import org.gitlab4j.api.models.Milestone; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Release; import org.gitlab4j.api.models.ReleaseParams; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +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; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestReleasesApi extends AbstractIntegrationTest { private static final String TEST_TAG_NAME = "test-release/1.0.0"; @@ -37,7 +39,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void testSetup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -47,7 +49,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { deleteTestResources(); } - @AfterClass + @AfterAll public static void tearDown() { deleteTestResources(); } @@ -74,7 +76,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(testProject != null); } diff --git a/src/test/java/org/gitlab4j/api/TestRepositoryApi.java b/src/test/java/org/gitlab4j/api/TestRepositoryApi.java index 4e85784949f84adfdd6bf9815834688699d7107f..9587c15ae55080e331e6d0d6d0e6ed4c662e2d75 100644 --- a/src/test/java/org/gitlab4j/api/TestRepositoryApi.java +++ b/src/test/java/org/gitlab4j/api/TestRepositoryApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.File; import java.io.IOException; @@ -19,13 +19,14 @@ import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.CompareResults; import org.gitlab4j.api.models.Project; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -39,8 +40,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestRepositoryApi extends AbstractIntegrationTest { private static final String TEST_BRANCH_NAME = "feature/test_branch"; @@ -54,7 +56,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -63,7 +65,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest { teardown(); } - @AfterClass + @AfterAll public static void teardown() { if (gitLabApi != null) { @@ -92,9 +94,9 @@ public class TestRepositoryApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestRepositoryFileApi.java b/src/test/java/org/gitlab4j/api/TestRepositoryFileApi.java index 0367ffb2230f554274703bc51ab7663a611f2839..d2f07b48512643c8b12a649f782a4e0c8dcf22fe 100644 --- a/src/test/java/org/gitlab4j/api/TestRepositoryFileApi.java +++ b/src/test/java/org/gitlab4j/api/TestRepositoryFileApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.File; import java.io.IOException; @@ -17,13 +17,14 @@ import java.util.Optional; import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.RepositoryFile; -import org.junit.AfterClass; -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.AfterAll; +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 @@ -37,8 +38,9 @@ import org.junit.runners.MethodSorters; * * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) public class TestRepositoryFileApi extends AbstractIntegrationTest { private static final String TEST_CONTENT = "This is some content to test file content 1234567890 !@#$%^&()."; @@ -52,7 +54,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server @@ -61,7 +63,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { teardown(); } - @AfterClass + @AfterAll public static void teardown() { if (gitLabApi != null) { @@ -83,9 +85,9 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestRequestResponseLogging.java b/src/test/java/org/gitlab4j/api/TestRequestResponseLogging.java index edbb66810270acc523842d6cef2a90f02f69d1d6..35048100caeb30ad6a66d6004e471fa926c4b2b0 100644 --- a/src/test/java/org/gitlab4j/api/TestRequestResponseLogging.java +++ b/src/test/java/org/gitlab4j/api/TestRequestResponseLogging.java @@ -23,15 +23,16 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.logging.FileHandler; @@ -40,12 +41,15 @@ import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import java.util.logging.StreamHandler; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.contrib.java.lang.system.SystemErrRule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; + +import uk.org.webcompere.systemstubs.jupiter.SystemStub; +import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension; +import uk.org.webcompere.systemstubs.stream.SystemErr; /** * In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties @@ -55,15 +59,16 @@ import org.junit.rules.TemporaryFolder; *

* If any of the above are NULL, all tests in this class will be skipped. */ -@Category(IntegrationTest.class) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@ExtendWith(SystemStubsExtension.class) public class TestRequestResponseLogging implements PropertyConstants { - @ClassRule - public final static SystemErrRule systemErrorRule = new SystemErrRule().enableLog(); - - @ClassRule - public final static TemporaryFolder tempFolder = new TemporaryFolder(); + @SystemStub + private SystemErr systemErr; + @TempDir + static Path tempDir; // The following needs to be set to your test repository private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY); @@ -78,7 +83,7 @@ public class TestRequestResponseLogging implements PropertyConstants { private static StreamHandler loggingHandler; private static File tempLoggingFile; - @BeforeClass + @BeforeAll public static void setup() throws Exception { String problems = ""; @@ -93,7 +98,7 @@ public class TestRequestResponseLogging implements PropertyConstants { if (problems.isEmpty()) { - tempLoggingFile = tempFolder.newFile("test-loging.log"); + tempLoggingFile = Files.createFile(tempDir.resolve("test-loging.log")).toFile(); loggingHandler = new FileHandler(tempLoggingFile.getAbsolutePath()); loggingHandler.setFormatter(new SimpleFormatter()); @@ -126,10 +131,10 @@ public class TestRequestResponseLogging implements PropertyConstants { String log = readLogFile(); System.out.println(log); - assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); - assertTrue("Request/response PRIVATE-TOKEN value was incorrectly present.", log.contains("PRIVATE-TOKEN: ********")); - assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); - assertTrue("Request/response entity was missing.", log.contains("...more...")); + assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing."); + assertTrue(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was incorrectly present."); + assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing."); + assertTrue(log.contains("...more..."), "Request/response entity was missing."); } @Test @@ -141,10 +146,10 @@ public class TestRequestResponseLogging implements PropertyConstants { String log = readLogFile(); System.out.println(log); - assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); - assertTrue("Request/response PRIVATE-TOKEN value was incorrectly present.", log.contains("PRIVATE-TOKEN: ********")); - assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); - assertFalse("Request/response entity was incorrectly present.", log.contains("...more...")); + assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing."); + assertTrue(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was incorrectly present."); + assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing."); + assertFalse(log.contains("...more..."), "Request/response entity was incorrectly present."); } @Test @@ -156,23 +161,23 @@ public class TestRequestResponseLogging implements PropertyConstants { String log = readLogFile(); System.out.println(log); - assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); - assertFalse("Request/response PRIVATE-TOKEN value was missing.", log.contains("PRIVATE-TOKEN: ********")); - assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); - assertTrue("Request/response entity was incorrectly present.", log.contains("...more...")); + assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing."); + assertFalse(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was missing."); + assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing."); + assertTrue(log.contains("...more..."), "Request/response entity was incorrectly present."); } @Test public void shouldNotLogRequests() throws GitLabApiException { assumeTrue(gitLabApiWithoutLogging != null); - systemErrorRule.clearLog(); + systemErr.clear(); gitLabApiWithoutLogging.getProjectApi().getProjects(1, 1); - String log = systemErrorRule.getLog(); + String log = systemErr.getText(); - assertFalse("Request/response log information was incorrectly present.", log.contains("PRIVATE-TOKEN:")); - assertFalse("Request/response log information was incorrectly present.", log.contains("/api/v4/projects")); - assertFalse("Request/response entity was incorrectly present.", log.contains("...more...")); + assertFalse(log.contains("PRIVATE-TOKEN:"), "Request/response log information was incorrectly present."); + assertFalse(log.contains("/api/v4/projects"), "Request/response log information was incorrectly present."); + assertFalse(log.contains("...more..."), "Request/response entity was incorrectly present."); } private static String readLogFile() throws IOException { diff --git a/src/test/java/org/gitlab4j/api/TestResourceStateEventsApi.java b/src/test/java/org/gitlab4j/api/TestResourceStateEventsApi.java index ff54604101824496598bc37e136f74bf729000d2..f7882087abb9de8366ce393f22f1b78cc227645e 100644 --- a/src/test/java/org/gitlab4j/api/TestResourceStateEventsApi.java +++ b/src/test/java/org/gitlab4j/api/TestResourceStateEventsApi.java @@ -3,18 +3,21 @@ package org.gitlab4j.api; import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.IssueEvent; import org.gitlab4j.api.models.Project; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -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.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.List; import static org.gitlab4j.api.TestIssuesApi.deleteAllTestIssues; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@Category(IntegrationTest.class) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestResourceStateEventsApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -27,18 +30,18 @@ public class TestResourceStateEventsApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { gitLabApi = baseTestSetup(); testProject = getTestProject(); } - @AfterClass + @AfterAll public static void teardown() { deleteAllTestIssues(); } - @Ignore("should be enabled when CI tests will be run against GitLab 13.2+") + @Disabled("should be enabled when CI tests will be run against GitLab 13.2+") @Test public void testGetCloseReopenIssueEvents() throws GitLabApiException { Long projectId = testProject.getId(); diff --git a/src/test/java/org/gitlab4j/api/TestRunnersApi.java b/src/test/java/org/gitlab4j/api/TestRunnersApi.java index 26adacb8d797fb836ba965b82f25faacf3152f8e..afb30231c22c7626b9ca18415ed03b9047e91125 100644 --- a/src/test/java/org/gitlab4j/api/TestRunnersApi.java +++ b/src/test/java/org/gitlab4j/api/TestRunnersApi.java @@ -23,10 +23,10 @@ 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.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.Assumptions.assumeTrue; import java.util.Arrays; import java.util.List; @@ -35,12 +35,13 @@ import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Runner; import org.gitlab4j.api.models.Runner.RunnerStatus; import org.gitlab4j.api.models.Runner.RunnerType; -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 @@ -53,8 +54,9 @@ import org.junit.runners.MethodSorters; *

* NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order */ -@Category(IntegrationTest.class) -@FixMethodOrder(MethodSorters.JVM) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) +@TestMethodOrder(MethodOrderer.MethodName.class) // FIXME check if it works properly public class TestRunnersApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -63,7 +65,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() throws GitLabApiException { // Must setup the connection to the GitLab test server @@ -97,7 +99,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { false, null)); } - @Before + @BeforeEach public void beforeMethod() throws GitLabApiException { assumeTrue(gitLabApi != null); @@ -113,7 +115,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { // Arrange Runner runner = createRunner(); - assertNotNull("Failed to create test runner.", runner); + assertNotNull(runner, "Failed to create test runner."); List runners = gitLabApi.getRunnersApi().getAllRunners(); assertEquals(1, runners.size()); @@ -125,7 +127,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { for (int i = 0; i < 3; i++) { Runner runner = createRunner(); - assertNotNull("Failed to create test runner.", runner); + assertNotNull(runner, "Failed to create test runner."); } List allRunners = gitLabApi.getRunnersApi().getAllRunners(); @@ -143,7 +145,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { public void shouldHavePausedRunner() throws GitLabApiException { Runner runner = createRunner(); - assertNotNull("Failed to create test runner.", runner); + assertNotNull(runner, "Failed to create test runner."); List runners = gitLabApi.getRunnersApi().getAllRunners(RunnerType.GROUP_TYPE, RunnerStatus.PAUSED); assertTrue(runners.isEmpty()); diff --git a/src/test/java/org/gitlab4j/api/TestSearchApi.java b/src/test/java/org/gitlab4j/api/TestSearchApi.java index a2de045264e80f06f8769efe0537873e4050642f..13bad240f41ed36dfc411e7f609575695b020c5c 100644 --- a/src/test/java/org/gitlab4j/api/TestSearchApi.java +++ b/src/test/java/org/gitlab4j/api/TestSearchApi.java @@ -1,7 +1,7 @@ package org.gitlab4j.api; -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 java.util.List; @@ -17,12 +17,14 @@ import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.SearchBlob; import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.User; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestSearchApi extends AbstractIntegrationTest { private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY); @@ -35,7 +37,7 @@ public class TestSearchApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void testSetup() { // Must setup the connection to the GitLab test server and get the test Project @@ -55,14 +57,14 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGlobalProjectSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, TEST_PROJECT_NAME); assertNotNull(results); assertTrue(results.get(0).getClass() == Project.class); } @Test public void testGlobalIssuesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.ISSUES, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.ISSUES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Issue.class); @@ -71,7 +73,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGlobalMergeRequestsSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == MergeRequest.class); @@ -80,7 +82,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGlobalMilestonesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.MILESTONES, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.MILESTONES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Milestone.class); @@ -89,16 +91,16 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGlobalSnippetTitlesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_TITLES, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_TITLES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Snippet.class); } } - @Ignore + @Disabled public void testGlobalSnippetBlobsSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_BLOBS, TEST_PROJECT_NAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_BLOBS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Snippet.class); @@ -107,21 +109,21 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGlobalUsersSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().globalSearch(SearchScope.USERS, TEST_LOGIN_USERNAME); + List results = gitLabApi.getSearchApi().globalSearch(SearchScope.USERS, TEST_LOGIN_USERNAME); assertNotNull(results); assertTrue(results.get(0).getClass() == User.class); } @Test public void testGroupProjectSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.PROJECTS, TEST_GROUP_PROJECT_NAME); + List results = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.PROJECTS, TEST_GROUP_PROJECT_NAME); assertNotNull(results); assertTrue(results.get(0).getClass() == Project.class); } @Test public void testGroupIssuesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.ISSUES, TEST_GROUP_PROJECT_NAME); + List results = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.ISSUES, TEST_GROUP_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Issue.class); @@ -130,7 +132,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGrouplMergeRequestsSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.MERGE_REQUESTS, TEST_GROUP_PROJECT_NAME); + List results = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.MERGE_REQUESTS, TEST_GROUP_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == MergeRequest.class); @@ -139,7 +141,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGroupMilestonesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.MILESTONES, TEST_GROUP_PROJECT_NAME); + List results = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.MILESTONES, TEST_GROUP_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { assertTrue(results.get(0).getClass() == Milestone.class); @@ -148,14 +150,14 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testGrouplUsersSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.USERS, TEST_LOGIN_USERNAME); + List results = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.USERS, TEST_LOGIN_USERNAME); assertNotNull(results); assertTrue(results.get(0).getClass() == User.class); } @Test public void testProjectIssuesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.ISSUES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -165,7 +167,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testProjectlMergeRequestsSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -175,7 +177,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testProjectMilestonesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.MILESTONES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -185,7 +187,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testProjectNotesSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.NOTES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -195,7 +197,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testProjectWikiBlobsSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.WIKI_BLOBS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -205,7 +207,7 @@ public class TestSearchApi extends AbstractIntegrationTest { @Test public void testProjectlUsersSearch() throws GitLabApiException { - List results = (List) gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.USERS, TEST_LOGIN_USERNAME); assertNotNull(results); assertTrue(results.get(0).getClass() == User.class); diff --git a/src/test/java/org/gitlab4j/api/TestServicesApi.java b/src/test/java/org/gitlab4j/api/TestServicesApi.java index 089a4f6a848467a28af09b876c0187ee81ee9735..b0cec62580ac319ff27dc2503a007b6cfad02091 100644 --- a/src/test/java/org/gitlab4j/api/TestServicesApi.java +++ b/src/test/java/org/gitlab4j/api/TestServicesApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.services.BugzillaService; @@ -15,12 +15,13 @@ import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.MattermostService; import org.gitlab4j.api.services.NotificationService.BranchesToBeNotified; import org.gitlab4j.api.services.SlackService; -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 @@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; * * 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 TestServicesApi extends AbstractIntegrationTest { private static final String TEST_ENDPOINT = "https://foobar.com/gitlab_service/webhooks/"; @@ -43,7 +45,7 @@ public class TestServicesApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project @@ -63,9 +65,9 @@ public class TestServicesApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(testProject); + assumeTrue(testProject != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java b/src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java index 6ad070d6641264e5137cd3a8aa923f2dfdb45d72..159496674dde6369c5ed3ec4a9f5fbe582edf851 100644 --- a/src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java +++ b/src/test/java/org/gitlab4j/api/TestSnippetDiscussionsApi.java @@ -1,11 +1,11 @@ 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 TestSnippetDiscussionsApi implements Constants { @Captor private ArgumentCaptor> attributeCaptor; private MockResponse response; - @Before + @BeforeEach public void setUp() throws Exception { - initMocks(this); + openMocks(this); response = new MockResponse(Discussion.class, null, "snippet-discussions.json"); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); diff --git a/src/test/java/org/gitlab4j/api/TestSnippetsApi.java b/src/test/java/org/gitlab4j/api/TestSnippetsApi.java index 07fa022d7b76d2e1b190f7bb4fbd7d073a4fb7c3..ff2bc3e6e2d12d45053f67c7610eacfb5ab24479 100644 --- a/src/test/java/org/gitlab4j/api/TestSnippetsApi.java +++ b/src/test/java/org/gitlab4j/api/TestSnippetsApi.java @@ -1,21 +1,23 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertFalse; +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.models.Snippet; import org.gitlab4j.api.models.Visibility; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +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; + +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestSnippetsApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -25,15 +27,15 @@ public class TestSnippetsApi extends AbstractIntegrationTest { private static final String TEST_SNIPPET_CONTENT_2 = "test-snippet-content-2"; private static final String TEST_SNIPPET_DESCRIPTION_1 = "test-snippet-description-1"; - @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 diff --git a/src/test/java/org/gitlab4j/api/TestStreams.java b/src/test/java/org/gitlab4j/api/TestStreams.java index e645e02cabadd09adbbb03cbdc6232a1fd8d8c4c..f7c184030c5d7586b691b971aa50a16cae2a1fa8 100644 --- a/src/test/java/org/gitlab4j/api/TestStreams.java +++ b/src/test/java/org/gitlab4j/api/TestStreams.java @@ -3,13 +3,13 @@ package org.gitlab4j.api; import static java.util.Comparator.comparing; import static java.util.stream.Collectors.toList; import static org.gitlab4j.api.JsonUtils.compareJson; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -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.Assumptions.assumeTrue; 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.Stream; @@ -17,9 +17,9 @@ import java.util.stream.Stream; import javax.ws.rs.core.MultivaluedMap; import org.gitlab4j.api.models.User; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -34,7 +34,7 @@ public class TestStreams implements Constants { static private List sortedUsers; - @BeforeClass + @BeforeAll public static void setupClass() throws Exception { // Get a list of users sorted by username, we use this as thye source of truth for the asserts @@ -42,9 +42,9 @@ public class TestStreams implements Constants { sortedUsers.sort(comparing(User::getUsername)); } - @Before + @BeforeEach public void setup() throws Exception { - initMocks(this); + openMocks(this); response = new MockResponse(User.class, null, "user-list.json"); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); diff --git a/src/test/java/org/gitlab4j/api/TestSystemHooksApi.java b/src/test/java/org/gitlab4j/api/TestSystemHooksApi.java index 69b931f4e114d32d5892ee2a0784fe2a86280ceb..5a1c5cd24ef219c7b18a103ead510e61b056af42 100644 --- a/src/test/java/org/gitlab4j/api/TestSystemHooksApi.java +++ b/src/test/java/org/gitlab4j/api/TestSystemHooksApi.java @@ -1,20 +1,21 @@ 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.assertTrue; -import static org.junit.Assume.assumeNotNull; +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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import org.gitlab4j.api.models.SystemHook; -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 @@ -24,8 +25,9 @@ import org.junit.runners.MethodSorters; * * 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 TestSystemHooksApi extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -39,7 +41,7 @@ public class TestSystemHooksApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { if (TEST_HOOK_URL == null || TEST_HOOK_URL.trim().isEmpty()) { @@ -50,9 +52,9 @@ public class TestSystemHooksApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestTagsApi.java b/src/test/java/org/gitlab4j/api/TestTagsApi.java index 0c598af360ea334d6a5e8eb9e099d3809fb1be1a..d24d58d0b0a8927198ff79971d0a1770d6392cb7 100644 --- a/src/test/java/org/gitlab4j/api/TestTagsApi.java +++ b/src/test/java/org/gitlab4j/api/TestTagsApi.java @@ -1,10 +1,10 @@ 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.assertTrue; -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.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Optional; @@ -15,13 +15,12 @@ import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.ProtectedTag; import org.gitlab4j.api.models.Release; import org.gitlab4j.api.models.Tag; -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.Test; -@Category(IntegrationTest.class) +@org.junit.jupiter.api.Tag("integration") public class TestTagsApi extends AbstractIntegrationTest { private static final String TEST_TAG_NAME_1 = "test-tag-1"; @@ -36,7 +35,7 @@ public class TestTagsApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void testSetup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -52,7 +51,7 @@ public class TestTagsApi extends AbstractIntegrationTest { } } - @AfterClass + @AfterAll public static void tearDown() { deleteTestTags(); } @@ -82,7 +81,7 @@ public class TestTagsApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { assumeTrue(testProject != null); } diff --git a/src/test/java/org/gitlab4j/api/TestTodosApi.java b/src/test/java/org/gitlab4j/api/TestTodosApi.java index 3d20d40beaa173bcb3c5265ada91d9bd59c97be2..80b53af3558ecf919f7468042311ea64f9b4c991 100644 --- a/src/test/java/org/gitlab4j/api/TestTodosApi.java +++ b/src/test/java/org/gitlab4j/api/TestTodosApi.java @@ -1,21 +1,24 @@ package org.gitlab4j.api; +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.Assumptions.assumeTrue; + +import java.util.List; +import java.util.Random; + import org.gitlab4j.api.Constants.TodoState; import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Todo; import org.gitlab4j.api.models.User; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.util.List; -import java.util.Random; - -import static org.junit.Assert.*; -import static org.junit.Assume.assumeNotNull; +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 @@ -25,7 +28,8 @@ import static org.junit.Assume.assumeNotNull; *

* 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 TestTodosApi extends AbstractIntegrationTest { private static GitLabApi gitLabApi; @@ -39,7 +43,7 @@ public class TestTodosApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -49,7 +53,7 @@ public class TestTodosApi extends AbstractIntegrationTest { deleteAllTestIssues(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestIssues(); } @@ -72,9 +76,9 @@ public class TestTodosApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } private static String getUniqueTitle() { diff --git a/src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java b/src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java index f22e8d82f9182b518ebb4c45829ba932db3106a5..2757f7337146bad75c4385fcac0e24c48b67ed05 100644 --- a/src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java +++ b/src/test/java/org/gitlab4j/api/TestUnitMergeRequestApi.java @@ -2,18 +2,18 @@ package org.gitlab4j.api; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasEntry; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; 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.Collections; import javax.ws.rs.core.MultivaluedMap; import org.gitlab4j.api.models.MergeRequest; -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; @@ -26,9 +26,9 @@ public class TestUnitMergeRequestApi { @Captor private ArgumentCaptor> attributeCaptor; private MockResponse mockedResponse; - @Before + @BeforeEach public void setUp() throws Exception { - initMocks(this); + openMocks(this); mockedResponse = new MockResponse(MergeRequest.class, "merge-request.json", null); when(mockGitLabApi.getApiClient()).thenReturn(mockedGitLabApiClient); diff --git a/src/test/java/org/gitlab4j/api/TestUpload.java b/src/test/java/org/gitlab4j/api/TestUpload.java index c55d5fc27b9759744e47bb9469f818479f333ed1..f901b384dcde568572543a8ca6d252a2b48ed0d5 100644 --- a/src/test/java/org/gitlab4j/api/TestUpload.java +++ b/src/test/java/org/gitlab4j/api/TestUpload.java @@ -3,9 +3,8 @@ package org.gitlab4j.api; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; -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.io.File; import java.io.FileInputStream; @@ -13,12 +12,13 @@ import java.io.FileNotFoundException; import java.util.Map; import org.gitlab4j.api.models.FileUpload; import org.gitlab4j.api.models.Project; -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 @@ -30,8 +30,10 @@ import org.junit.runners.MethodSorters; * * 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 TestUpload extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -45,15 +47,15 @@ public class TestUpload 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(); } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test diff --git a/src/test/java/org/gitlab4j/api/TestUserApi.java b/src/test/java/org/gitlab4j/api/TestUserApi.java index 87638142e371455dea4758470f4b4b32126057a0..76e727a217fe024ec3c8e10d6e2c8f64905eb3a8 100644 --- a/src/test/java/org/gitlab4j/api/TestUserApi.java +++ b/src/test/java/org/gitlab4j/api/TestUserApi.java @@ -2,14 +2,13 @@ package org.gitlab4j.api; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; -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.assertNull; -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.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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.text.ParseException; import java.util.Date; @@ -29,10 +28,11 @@ import org.gitlab4j.api.models.SshKey; import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.Version; 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 @@ -52,7 +52,8 @@ import org.junit.experimental.categories.Category; * If this is null the SSH key tests will be skipped. * */ -@Category(IntegrationTest.class) +@Tag("integration") +@ExtendWith(SetupIntegrationTestExtension.class) public class TestUserApi extends AbstractIntegrationTest { // The following needs to be set to your test repository @@ -132,7 +133,7 @@ public class TestUserApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { String problems = ""; @@ -193,9 +194,9 @@ public class TestUserApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(gitLabApi); + assumeTrue(gitLabApi != null); } @Test @@ -223,7 +224,7 @@ public class TestUserApi extends AbstractIntegrationTest { @Test public void testBlockUnblockUser() throws GitLabApiException { - assumeNotNull(blockUser); + assumeTrue(blockUser != null); assertNotEquals("blocked", blockUser.getState()); gitLabApi.getUserApi().blockUser(blockUser.getId()); @@ -251,9 +252,9 @@ public class TestUserApi extends AbstractIntegrationTest { @Test public void testExternalUid() throws GitLabApiException { - assumeNotNull(TEST_EXTERNAL_USERNAME); - assumeNotNull(TEST_EXTERNAL_PROVIDER); - assumeNotNull(TEST_EXTERNAL_UID); + assumeTrue(TEST_EXTERNAL_USERNAME != null); + assumeTrue(TEST_EXTERNAL_PROVIDER != null); + assumeTrue(TEST_EXTERNAL_UID != null); User externalUser = null; try { @@ -423,18 +424,18 @@ public class TestUserApi extends AbstractIntegrationTest { assumeTrue(TEST_SSH_KEY != null); SshKey sshKey = gitLabApi.getUserApi().addSshKey("Test-Key", TEST_SSH_KEY); assertNotNull(sshKey); - assertTrue(TEST_SSH_KEY, sshKey.getKey().startsWith(TEST_SSH_KEY)); + assertTrue(sshKey.getKey().startsWith(TEST_SSH_KEY), TEST_SSH_KEY); gitLabApi.getUserApi().deleteSshKey(sshKey.getId()); User user = gitLabApi.getUserApi().getCurrentUser(); sshKey = gitLabApi.getUserApi().addSshKey(user.getId(), "Test-Key1", TEST_SSH_KEY); assertNotNull(sshKey); - assertTrue(TEST_SSH_KEY, sshKey.getKey().startsWith(TEST_SSH_KEY)); + assertTrue(sshKey.getKey().startsWith(TEST_SSH_KEY), TEST_SSH_KEY); assertEquals(user.getId(), sshKey.getUserId()); Optional optional = gitLabApi.getUserApi().getOptionalSshKey(sshKey.getId()); assertNotNull(optional.isPresent()); - assertTrue(TEST_SSH_KEY, sshKey.getKey().startsWith(TEST_SSH_KEY)); + assertTrue(sshKey.getKey().startsWith(TEST_SSH_KEY), TEST_SSH_KEY); gitLabApi.getUserApi().deleteSshKey(sshKey.getId()); } diff --git a/src/test/java/org/gitlab4j/api/TestWikisApi.java b/src/test/java/org/gitlab4j/api/TestWikisApi.java index edb6a0f9736e3cc64680dcd8ad7e651bdb7d4fa0..45a05e84ac66d27e120400fd9932fefa660555f4 100644 --- a/src/test/java/org/gitlab4j/api/TestWikisApi.java +++ b/src/test/java/org/gitlab4j/api/TestWikisApi.java @@ -23,10 +23,10 @@ package org.gitlab4j.api; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -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.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.File; import java.util.List; @@ -34,11 +34,12 @@ import java.util.List; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.WikiAttachment; import org.gitlab4j.api.models.WikiPage; -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 @@ -50,7 +51,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 TestWikisApi extends AbstractIntegrationTest { private static final String TEST_WIKI_TITLE_PREFIX = "Test Wiki: "; @@ -62,7 +64,7 @@ public class TestWikisApi extends AbstractIntegrationTest { super(); } - @BeforeClass + @BeforeAll public static void setup() { // Must setup the connection to the GitLab test server and get the test Project instance @@ -73,7 +75,7 @@ public class TestWikisApi extends AbstractIntegrationTest { deleteAllTestWikiPages(); } - @AfterClass + @AfterAll public static void teardown() throws GitLabApiException { deleteAllTestWikiPages(); } @@ -94,9 +96,9 @@ public class TestWikisApi extends AbstractIntegrationTest { } } - @Before + @BeforeEach public void beforeMethod() { - assumeNotNull(testProject); + assumeTrue(testProject != null); } private WikiPage createWikiPage(String title, String content) throws GitLabApiException { diff --git a/src/test/java/org/gitlab4j/api/models/MembershipSourceTypeTest.java b/src/test/java/org/gitlab4j/api/models/MembershipSourceTypeTest.java index 09ba86b25905dc3937d4d93c8c23ea9b2b704165..ade778c0526023ea81f22006b353b19735bd5ec5 100644 --- a/src/test/java/org/gitlab4j/api/models/MembershipSourceTypeTest.java +++ b/src/test/java/org/gitlab4j/api/models/MembershipSourceTypeTest.java @@ -1,21 +1,20 @@ package org.gitlab4j.api.models; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; public class MembershipSourceTypeTest { @Test public void forValue() { final MembershipSourceType namespace = MembershipSourceType.forValue("Namespace"); - Assert.assertEquals(MembershipSourceType.NAMESPACE, namespace); - Assert.assertEquals("Namespace", namespace.toValue()); - Assert.assertEquals("Namespace", namespace.toString()); + assertEquals(MembershipSourceType.NAMESPACE, namespace); + assertEquals("Namespace", namespace.toValue()); + assertEquals("Namespace", namespace.toString()); final MembershipSourceType project = MembershipSourceType.forValue("Project"); - Assert.assertEquals(MembershipSourceType.PROJECT, project); - Assert.assertEquals("Project", project.toValue()); - Assert.assertEquals("Project", project.toString()); + assertEquals(MembershipSourceType.PROJECT, project); + assertEquals("Project", project.toValue()); + assertEquals("Project", project.toString()); } }