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

Merge pull request #750 from gitlab4j/issue-691

Migrate from JUnit 4 to JUnit 5
parents 73817d15 a1b28ea1
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.gitlab4j.api.utils.Oauth2LoginStreamingOutput; import org.gitlab4j.api.utils.Oauth2LoginStreamingOutput;
import org.junit.Test; import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
......
...@@ -2,16 +2,23 @@ package org.gitlab4j.api; ...@@ -2,16 +2,23 @@ package org.gitlab4j.api;
import org.gitlab4j.api.models.*; import org.gitlab4j.api.models.*;
import org.gitlab4j.api.models.Package; import org.gitlab4j.api.models.Package;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Disabled;
import org.junit.experimental.categories.Category; 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 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 { public class TestPackageApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -21,18 +28,19 @@ public class TestPackageApi extends AbstractIntegrationTest { ...@@ -21,18 +28,19 @@ public class TestPackageApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
testProject = getTestProject(); testProject = getTestProject();
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
assumeNotNull(testProject); assumeTrue(testProject != null);
} }
@Disabled("need creation of a package through CI")
@Test @Test
public void getPackagesStream() throws GitLabApiException { public void getPackagesStream() throws GitLabApiException {
PackagesApi packagesApi = gitLabApi.getPackagesApi(); PackagesApi packagesApi = gitLabApi.getPackagesApi();
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
...@@ -11,12 +11,13 @@ import org.gitlab4j.api.models.Branch; ...@@ -11,12 +11,13 @@ import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.Member;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties * In order for these tests to run you must set the following properties in test-gitlab4j.properties
...@@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; ...@@ -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 * NOTE: &FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestPager extends AbstractIntegrationTest { public class TestPager extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -40,15 +42,15 @@ public class TestPager extends AbstractIntegrationTest { ...@@ -40,15 +42,15 @@ public class TestPager extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -20,13 +20,15 @@ import org.gitlab4j.api.models.Project; ...@@ -20,13 +20,15 @@ import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.models.Trigger; import org.gitlab4j.api.models.Trigger;
import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.models.Variable;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestPipelineApi extends AbstractIntegrationTest { public class TestPipelineApi extends AbstractIntegrationTest {
private static final String SCHEDULE_DESCRIPTION = "Test pipeline schedule - DELETE AFTER TEST"; private static final String SCHEDULE_DESCRIPTION = "Test pipeline schedule - DELETE AFTER TEST";
...@@ -80,7 +82,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -80,7 +82,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
} }
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance // Must setup the connection to the GitLab test server and get the test Project instance
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
...@@ -104,14 +106,14 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -104,14 +106,14 @@ public class TestPipelineApi extends AbstractIntegrationTest {
} }
} }
@AfterClass @AfterAll
public static void teardown() { public static void teardown() {
deleteTestResources(); deleteTestResources();
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
...@@ -219,7 +221,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -219,7 +221,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
assertNotNull(testProject); assertNotNull(testProject);
// Skip this test if no .gitlab-ci.yml file is in the test project // 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); String triggerDescription = TRIGGER_DESCRIPTION + " - test triggerPipeline() - " + HelperUtils.getRandomInt(1000);
Trigger createdTrigger = gitLabApi.getPipelineApi().createPipelineTrigger(testProject, triggerDescription); Trigger createdTrigger = gitLabApi.getPipelineApi().createPipelineTrigger(testProject, triggerDescription);
...@@ -241,7 +243,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -241,7 +243,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
public void testCreatePipelineNoVariables() throws GitLabApiException { public void testCreatePipelineNoVariables() throws GitLabApiException {
// Skip this test if no .gitlab-ci.yml file is in the test project // Skip this test if no .gitlab-ci.yml file is in the test project
assumeNotNull(gitlabCiYml); assumeTrue(gitlabCiYml != null);
// Act // Act
Pipeline pipeline = gitLabApi.getPipelineApi().createPipeline(testProject, "master"); Pipeline pipeline = gitLabApi.getPipelineApi().createPipeline(testProject, "master");
...@@ -256,7 +258,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -256,7 +258,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
public void testCreatePipelineWithVariables() throws GitLabApiException { public void testCreatePipelineWithVariables() throws GitLabApiException {
// Skip this test if no .gitlab-ci.yml file is in the test project // Skip this test if no .gitlab-ci.yml file is in the test project
assumeNotNull(gitlabCiYml); assumeTrue(gitlabCiYml != null);
// Arrange // Arrange
List<Variable> variableList = new ArrayList<>(); List<Variable> variableList = new ArrayList<>();
...@@ -276,7 +278,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -276,7 +278,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
public void testCreatePipelineWithMapVariables() throws GitLabApiException { public void testCreatePipelineWithMapVariables() throws GitLabApiException {
// Skip this test if no .gitlab-ci.yml file is in the test project // Skip this test if no .gitlab-ci.yml file is in the test project
assumeNotNull(gitlabCiYml); assumeTrue(gitlabCiYml != null);
// Arrange // Arrange
Map<String, String> variableMap = new HashMap<>(); Map<String, String> variableMap = new HashMap<>();
...@@ -296,7 +298,7 @@ public class TestPipelineApi extends AbstractIntegrationTest { ...@@ -296,7 +298,7 @@ public class TestPipelineApi extends AbstractIntegrationTest {
public void testPipelineVariables() throws GitLabApiException { public void testPipelineVariables() throws GitLabApiException {
// Skip this test if no .gitlab-ci.yml file is in the test project // Skip this test if no .gitlab-ci.yml file is in the test project
assumeNotNull(gitlabCiYml); assumeTrue(gitlabCiYml != null);
// Arrange // Arrange
Map<String, String> variableMap = new HashMap<>(); Map<String, String> variableMap = new HashMap<>();
......
...@@ -23,13 +23,12 @@ ...@@ -23,13 +23,12 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.Assume.assumeTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -49,13 +48,14 @@ import org.gitlab4j.api.models.ProjectFilter; ...@@ -49,13 +48,14 @@ import org.gitlab4j.api.models.ProjectFilter;
import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.User;
import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.models.Variable;
import org.gitlab4j.api.models.Visibility; import org.gitlab4j.api.models.Visibility;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties * In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
...@@ -70,8 +70,9 @@ import org.junit.runners.MethodSorters; ...@@ -70,8 +70,9 @@ import org.junit.runners.MethodSorters;
* *
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order * NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestProjectApi extends AbstractIntegrationTest { public class TestProjectApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository // The following needs to be set to your test repository
...@@ -96,7 +97,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -96,7 +97,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
...@@ -107,7 +108,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -107,7 +108,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
deleteAllTransientTestData(); deleteAllTransientTestData();
} }
@AfterClass @AfterAll
public static void teardown() throws GitLabApiException { public static void teardown() throws GitLabApiException {
deleteAllTransientTestData(); deleteAllTransientTestData();
} }
...@@ -186,9 +187,9 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -186,9 +187,9 @@ public class TestProjectApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
...@@ -402,7 +403,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -402,7 +403,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testListStarredProjects() throws GitLabApiException { public void testListStarredProjects() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
try { try {
gitLabApi.getProjectApi().starProject(testProject); gitLabApi.getProjectApi().starProject(testProject);
...@@ -425,7 +426,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -425,7 +426,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testListStarredProjectsWithParams() throws GitLabApiException { public void testListStarredProjectsWithParams() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
try { try {
gitLabApi.getProjectApi().starProject(testProject); gitLabApi.getProjectApi().starProject(testProject);
...@@ -560,7 +561,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -560,7 +561,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testCreateProjectInNamespace() throws GitLabApiException { public void testCreateProjectInNamespace() throws GitLabApiException {
assumeNotNull(currentUser); assumeTrue(currentUser != null);
Project namespaceProject = null; Project namespaceProject = null;
try { try {
...@@ -602,7 +603,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -602,7 +603,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
assumeTrue(TEST_GROUP != null && TEST_GROUP_PROJECT != null); assumeTrue(TEST_GROUP != null && TEST_GROUP_PROJECT != null);
assumeTrue(TEST_GROUP.trim().length() > 0 && TEST_GROUP_PROJECT.trim().length() > 0); assumeTrue(TEST_GROUP.trim().length() > 0 && TEST_GROUP_PROJECT.trim().length() > 0);
assumeNotNull(testProject); assumeTrue(testProject != null);
List<Group> groups = gitLabApi.getGroupApi().getGroups(TEST_GROUP); List<Group> groups = gitLabApi.getGroupApi().getGroups(TEST_GROUP);
assertNotNull(groups); assertNotNull(groups);
...@@ -647,7 +648,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -647,7 +648,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testStarAndUnstarProject() throws GitLabApiException { public void testStarAndUnstarProject() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
try { try {
gitLabApi.getProjectApi().unstarProject(testProject); gitLabApi.getProjectApi().unstarProject(testProject);
...@@ -686,7 +687,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -686,7 +687,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testVariables() throws GitLabApiException { public void testVariables() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt();
String value = "ABCDEFG12345678" + HelperUtils.getRandomInt(); String value = "ABCDEFG12345678" + HelperUtils.getRandomInt();
...@@ -736,7 +737,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -736,7 +737,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testFileVariable() throws GitLabApiException { public void testFileVariable() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt();
String value = "/tmp/test.txt"; String value = "/tmp/test.txt";
...@@ -758,7 +759,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -758,7 +759,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testGetMembers() throws GitLabApiException { public void testGetMembers() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
// Act // Act
List<Member> members = gitLabApi.getProjectApi().getMembers(testProject); List<Member> members = gitLabApi.getProjectApi().getMembers(testProject);
...@@ -770,7 +771,7 @@ public class TestProjectApi extends AbstractIntegrationTest { ...@@ -770,7 +771,7 @@ public class TestProjectApi extends AbstractIntegrationTest {
@Test @Test
public void testAllMemberOperations() throws GitLabApiException { public void testAllMemberOperations() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
// Act // Act
List<Member> members = gitLabApi.getProjectApi().getAllMembers(testProject); List<Member> members = gitLabApi.getProjectApi().getAllMembers(testProject);
......
...@@ -23,21 +23,22 @@ ...@@ -23,21 +23,22 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.Visibility; import org.gitlab4j.api.models.Visibility;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties * In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
...@@ -49,7 +50,8 @@ import org.junit.experimental.categories.Category; ...@@ -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. * 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 { public class TestProjectApiSnippets extends AbstractIntegrationTest {
private static final String TEST_SNIPPET_TITLE_PREFIX = "Test Snippet: "; private static final String TEST_SNIPPET_TITLE_PREFIX = "Test Snippet: ";
...@@ -60,7 +62,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -60,7 +62,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance // Must setup the connection to the GitLab test server and get the test Project instance
...@@ -70,7 +72,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -70,7 +72,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
deleteAllTestSnippets(); deleteAllTestSnippets();
} }
@AfterClass @AfterAll
public static void teardown() throws GitLabApiException { public static void teardown() throws GitLabApiException {
deleteAllTestSnippets(); deleteAllTestSnippets();
} }
...@@ -91,9 +93,9 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -91,9 +93,9 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
private Snippet createSnippet(String title, String filename, String description, private Snippet createSnippet(String title, String filename, String description,
...@@ -118,7 +120,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -118,7 +120,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
@Test @Test
public void testUpdate() throws GitLabApiException { public void testUpdate() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String title = TEST_SNIPPET_TITLE_PREFIX + "Test createSnippet()"; String title = TEST_SNIPPET_TITLE_PREFIX + "Test createSnippet()";
String filename = "test-update-snippet.js"; String filename = "test-update-snippet.js";
...@@ -137,7 +139,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -137,7 +139,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
@Test @Test
public void testListSnippets() throws GitLabApiException { public void testListSnippets() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()"; String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()";
String filename = "test-list-snippets.js"; String filename = "test-list-snippets.js";
...@@ -162,7 +164,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -162,7 +164,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
@Test @Test
public void testDeleteSnippet() throws GitLabApiException { public void testDeleteSnippet() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()"; String title = TEST_SNIPPET_TITLE_PREFIX + "Test listSnippets()";
String filename = "test-delete-snippet.js"; String filename = "test-delete-snippet.js";
...@@ -187,7 +189,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest { ...@@ -187,7 +189,7 @@ public class TestProjectApiSnippets extends AbstractIntegrationTest {
@Test @Test
public void testSnippetContent() throws GitLabApiException { public void testSnippetContent() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String title = TEST_SNIPPET_TITLE_PREFIX + "Test getRawSnippetContent()"; String title = TEST_SNIPPET_TITLE_PREFIX + "Test getRawSnippetContent()";
String filename = "test-raw-snippet.js"; String filename = "test-raw-snippet.js";
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -35,11 +35,12 @@ import java.util.stream.Stream; ...@@ -35,11 +35,12 @@ import java.util.stream.Stream;
import org.gitlab4j.api.models.CustomAttribute; import org.gitlab4j.api.models.CustomAttribute;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties * 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; ...@@ -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. * 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 { public class TestProjectCustomAttributes extends AbstractIntegrationTest {
private static final String TEST_CUSTOM_ATTRIBUTE_KEY = "GitLab4JCustomAttributeTestKey"; private static final String TEST_CUSTOM_ATTRIBUTE_KEY = "GitLab4JCustomAttributeTestKey";
...@@ -64,7 +66,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -64,7 +66,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance // Must setup the connection to the GitLab test server and get the test Project instance
...@@ -74,7 +76,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -74,7 +76,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
deleteAllTestCustomAttributes(); deleteAllTestCustomAttributes();
} }
@AfterClass @AfterAll
public static void teardown() throws GitLabApiException { public static void teardown() throws GitLabApiException {
deleteAllTestCustomAttributes(); deleteAllTestCustomAttributes();
} }
...@@ -95,9 +97,9 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -95,9 +97,9 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
private CustomAttribute createCustomAttribute(String key, String value) throws GitLabApiException { private CustomAttribute createCustomAttribute(String key, String value) throws GitLabApiException {
...@@ -116,7 +118,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -116,7 +118,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
@Test @Test
public void testUpdate() throws GitLabApiException { public void testUpdate() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestUpdate"; String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestUpdate";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE; String value = TEST_CUSTOM_ATTRIBUTE_VALUE;
...@@ -134,7 +136,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -134,7 +136,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
@Test @Test
public void testGetCustomAttribute() throws GitLabApiException { public void testGetCustomAttribute() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestGet"; String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestGet";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test get)"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test get)";
...@@ -151,7 +153,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -151,7 +153,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
@Test @Test
public void testListCustomAttributes() throws GitLabApiException { public void testListCustomAttributes() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestList"; String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestList";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test list)"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test list)";
...@@ -171,7 +173,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest { ...@@ -171,7 +173,7 @@ public class TestProjectCustomAttributes extends AbstractIntegrationTest {
@Test @Test
public void testDeleteCustomAttribute() throws GitLabApiException { public void testDeleteCustomAttribute() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestDelete"; String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestDelete";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test delete)"; String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test delete)";
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.ProtectedBranch; import org.gitlab4j.api.models.ProtectedBranch;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties * In order for these tests to run you must set the following properties in test-gitlab4j.properties
...@@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; ...@@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters;
* *
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. * NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestProtectedBranchesApi extends AbstractIntegrationTest { public class TestProtectedBranchesApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -41,14 +43,14 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { ...@@ -41,14 +43,14 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest {
private static final String TEST_BRANCH_NAME = "feature/test_branch"; private static final String TEST_BRANCH_NAME = "feature/test_branch";
private static final String TEST_PROTECT_BRANCH_NAME = "feature/protect_branch"; private static final String TEST_PROTECT_BRANCH_NAME = "feature/protect_branch";
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance // Must setup the connection to the GitLab test server and get the test Project instance
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
testProject = getTestProject(); testProject = getTestProject();
} }
@AfterClass @AfterAll
public static void teardown() { public static void teardown() {
if (testProject != null) { if (testProject != null) {
try { try {
...@@ -65,9 +67,9 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { ...@@ -65,9 +67,9 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() throws GitLabApiException { public void beforeMethod() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
Branch protectedBranch; Branch protectedBranch;
try { try {
...@@ -90,7 +92,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { ...@@ -90,7 +92,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest {
@Test @Test
public void testGetProtectedBranches() throws GitLabApiException { public void testGetProtectedBranches() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject); List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject);
assertNotNull(branches); assertNotNull(branches);
assertTrue(branches.stream() assertTrue(branches.stream()
...@@ -100,7 +102,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { ...@@ -100,7 +102,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest {
@Test @Test
public void testUnprotectBranch() throws GitLabApiException { public void testUnprotectBranch() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
gitLabApi.getProtectedBranchesApi().unprotectBranch(testProject, TEST_PROTECT_BRANCH_NAME); gitLabApi.getProtectedBranchesApi().unprotectBranch(testProject, TEST_PROTECT_BRANCH_NAME);
List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject); List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(testProject);
assertNotNull(branches); assertNotNull(branches);
...@@ -111,7 +113,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest { ...@@ -111,7 +113,7 @@ public class TestProtectedBranchesApi extends AbstractIntegrationTest {
@Test @Test
public void testProtectBranch() throws GitLabApiException { public void testProtectBranch() throws GitLabApiException {
assumeNotNull(testProject); assumeTrue(testProject != null);
ProtectedBranch branch = gitLabApi.getProtectedBranchesApi().protectBranch(testProject, TEST_BRANCH_NAME); ProtectedBranch branch = gitLabApi.getProtectedBranchesApi().protectBranch(testProject, TEST_BRANCH_NAME);
assertNotNull(branch); assertNotNull(branch);
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
...@@ -15,13 +15,15 @@ import org.gitlab4j.api.models.Milestone; ...@@ -15,13 +15,15 @@ import org.gitlab4j.api.models.Milestone;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Release; import org.gitlab4j.api.models.Release;
import org.gitlab4j.api.models.ReleaseParams; import org.gitlab4j.api.models.ReleaseParams;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestReleasesApi extends AbstractIntegrationTest { public class TestReleasesApi extends AbstractIntegrationTest {
private static final String TEST_TAG_NAME = "test-release/1.0.0"; private static final String TEST_TAG_NAME = "test-release/1.0.0";
...@@ -37,7 +39,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { ...@@ -37,7 +39,7 @@ public class TestReleasesApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void testSetup() { public static void testSetup() {
// Must setup the connection to the GitLab test server and get the test Project instance // Must setup the connection to the GitLab test server and get the test Project instance
...@@ -47,7 +49,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { ...@@ -47,7 +49,7 @@ public class TestReleasesApi extends AbstractIntegrationTest {
deleteTestResources(); deleteTestResources();
} }
@AfterClass @AfterAll
public static void tearDown() { public static void tearDown() {
deleteTestResources(); deleteTestResources();
} }
...@@ -74,7 +76,7 @@ public class TestReleasesApi extends AbstractIntegrationTest { ...@@ -74,7 +76,7 @@ public class TestReleasesApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeTrue(testProject != null); assumeTrue(testProject != null);
} }
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -19,13 +19,14 @@ import org.gitlab4j.api.models.Branch; ...@@ -19,13 +19,14 @@ import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CompareResults; import org.gitlab4j.api.models.CompareResults;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties * In order for these tests to run you must set the following properties in test-gitlab4j.properties
...@@ -39,8 +40,9 @@ import org.junit.runners.MethodSorters; ...@@ -39,8 +40,9 @@ import org.junit.runners.MethodSorters;
* *
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. * NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestRepositoryApi extends AbstractIntegrationTest { public class TestRepositoryApi extends AbstractIntegrationTest {
private static final String TEST_BRANCH_NAME = "feature/test_branch"; private static final String TEST_BRANCH_NAME = "feature/test_branch";
...@@ -54,7 +56,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest { ...@@ -54,7 +56,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
...@@ -63,7 +65,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest { ...@@ -63,7 +65,7 @@ public class TestRepositoryApi extends AbstractIntegrationTest {
teardown(); teardown();
} }
@AfterClass @AfterAll
public static void teardown() { public static void teardown() {
if (gitLabApi != null) { if (gitLabApi != null) {
...@@ -92,9 +94,9 @@ public class TestRepositoryApi extends AbstractIntegrationTest { ...@@ -92,9 +94,9 @@ public class TestRepositoryApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -17,13 +17,14 @@ import java.util.Optional; ...@@ -17,13 +17,14 @@ import java.util.Optional;
import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.RepositoryFile;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties * In order for these tests to run you must set the following properties in test-gitlab4j.properties
...@@ -37,8 +38,9 @@ import org.junit.runners.MethodSorters; ...@@ -37,8 +38,9 @@ import org.junit.runners.MethodSorters;
* *
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first. * NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestRepositoryFileApi extends AbstractIntegrationTest { public class TestRepositoryFileApi extends AbstractIntegrationTest {
private static final String TEST_CONTENT = "This is some content to test file content 1234567890 !@#$%^&()."; private static final String TEST_CONTENT = "This is some content to test file content 1234567890 !@#$%^&().";
...@@ -52,7 +54,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { ...@@ -52,7 +54,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
...@@ -61,7 +63,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { ...@@ -61,7 +63,7 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest {
teardown(); teardown();
} }
@AfterClass @AfterAll
public static void teardown() { public static void teardown() {
if (gitLabApi != null) { if (gitLabApi != null) {
...@@ -83,9 +85,9 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest { ...@@ -83,9 +85,9 @@ public class TestRepositoryFileApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
......
...@@ -23,15 +23,16 @@ ...@@ -23,15 +23,16 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
...@@ -40,12 +41,15 @@ import java.util.logging.Logger; ...@@ -40,12 +41,15 @@ import java.util.logging.Logger;
import java.util.logging.SimpleFormatter; import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler; import java.util.logging.StreamHandler;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.ClassRule; import org.junit.jupiter.api.Tag;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.contrib.java.lang.system.SystemErrRule; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.io.TempDir;
import org.junit.rules.TemporaryFolder;
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 * 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; ...@@ -55,15 +59,16 @@ import org.junit.rules.TemporaryFolder;
* <p> * <p>
* If any of the above are NULL, all tests in this class will be skipped. * If any of the above are NULL, all tests in this class will be skipped.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@ExtendWith(SystemStubsExtension.class)
public class TestRequestResponseLogging implements PropertyConstants { public class TestRequestResponseLogging implements PropertyConstants {
@ClassRule @SystemStub
public final static SystemErrRule systemErrorRule = new SystemErrRule().enableLog(); private SystemErr systemErr;
@ClassRule
public final static TemporaryFolder tempFolder = new TemporaryFolder();
@TempDir
static Path tempDir;
// The following needs to be set to your test repository // The following needs to be set to your test repository
private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY); private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY);
...@@ -78,7 +83,7 @@ public class TestRequestResponseLogging implements PropertyConstants { ...@@ -78,7 +83,7 @@ public class TestRequestResponseLogging implements PropertyConstants {
private static StreamHandler loggingHandler; private static StreamHandler loggingHandler;
private static File tempLoggingFile; private static File tempLoggingFile;
@BeforeClass @BeforeAll
public static void setup() throws Exception { public static void setup() throws Exception {
String problems = ""; String problems = "";
...@@ -93,7 +98,7 @@ public class TestRequestResponseLogging implements PropertyConstants { ...@@ -93,7 +98,7 @@ public class TestRequestResponseLogging implements PropertyConstants {
if (problems.isEmpty()) { if (problems.isEmpty()) {
tempLoggingFile = tempFolder.newFile("test-loging.log"); tempLoggingFile = Files.createFile(tempDir.resolve("test-loging.log")).toFile();
loggingHandler = new FileHandler(tempLoggingFile.getAbsolutePath()); loggingHandler = new FileHandler(tempLoggingFile.getAbsolutePath());
loggingHandler.setFormatter(new SimpleFormatter()); loggingHandler.setFormatter(new SimpleFormatter());
...@@ -126,10 +131,10 @@ public class TestRequestResponseLogging implements PropertyConstants { ...@@ -126,10 +131,10 @@ public class TestRequestResponseLogging implements PropertyConstants {
String log = readLogFile(); String log = readLogFile();
System.out.println(log); System.out.println(log);
assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing.");
assertTrue("Request/response PRIVATE-TOKEN value was incorrectly present.", log.contains("PRIVATE-TOKEN: ********")); assertTrue(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was incorrectly present.");
assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing.");
assertTrue("Request/response entity was missing.", log.contains("...more...")); assertTrue(log.contains("...more..."), "Request/response entity was missing.");
} }
@Test @Test
...@@ -141,10 +146,10 @@ public class TestRequestResponseLogging implements PropertyConstants { ...@@ -141,10 +146,10 @@ public class TestRequestResponseLogging implements PropertyConstants {
String log = readLogFile(); String log = readLogFile();
System.out.println(log); System.out.println(log);
assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing.");
assertTrue("Request/response PRIVATE-TOKEN value was incorrectly present.", log.contains("PRIVATE-TOKEN: ********")); assertTrue(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was incorrectly present.");
assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing.");
assertFalse("Request/response entity was incorrectly present.", log.contains("...more...")); assertFalse(log.contains("...more..."), "Request/response entity was incorrectly present.");
} }
@Test @Test
...@@ -156,23 +161,23 @@ public class TestRequestResponseLogging implements PropertyConstants { ...@@ -156,23 +161,23 @@ public class TestRequestResponseLogging implements PropertyConstants {
String log = readLogFile(); String log = readLogFile();
System.out.println(log); System.out.println(log);
assertTrue("Request/response log information was missing.", log.contains("PRIVATE-TOKEN:")); assertTrue(log.contains("PRIVATE-TOKEN:"), "Request/response log information was missing.");
assertFalse("Request/response PRIVATE-TOKEN value was missing.", log.contains("PRIVATE-TOKEN: ********")); assertFalse(log.contains("PRIVATE-TOKEN: ********"), "Request/response PRIVATE-TOKEN value was missing.");
assertTrue("Request/response log information was missing.", log.contains("/api/v4/projects")); assertTrue(log.contains("/api/v4/projects"), "Request/response log information was missing.");
assertTrue("Request/response entity was incorrectly present.", log.contains("...more...")); assertTrue(log.contains("...more..."), "Request/response entity was incorrectly present.");
} }
@Test @Test
public void shouldNotLogRequests() throws GitLabApiException { public void shouldNotLogRequests() throws GitLabApiException {
assumeTrue(gitLabApiWithoutLogging != null); assumeTrue(gitLabApiWithoutLogging != null);
systemErrorRule.clearLog(); systemErr.clear();
gitLabApiWithoutLogging.getProjectApi().getProjects(1, 1); 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(log.contains("PRIVATE-TOKEN:"), "Request/response log information was incorrectly present.");
assertFalse("Request/response log information was incorrectly present.", log.contains("/api/v4/projects")); assertFalse(log.contains("/api/v4/projects"), "Request/response log information was incorrectly present.");
assertFalse("Request/response entity was incorrectly present.", log.contains("...more...")); assertFalse(log.contains("...more..."), "Request/response entity was incorrectly present.");
} }
private static String readLogFile() throws IOException { private static String readLogFile() throws IOException {
......
...@@ -3,18 +3,21 @@ package org.gitlab4j.api; ...@@ -3,18 +3,21 @@ package org.gitlab4j.api;
import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.IssueEvent; import org.gitlab4j.api.models.IssueEvent;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import java.util.List; import java.util.List;
import static org.gitlab4j.api.TestIssuesApi.deleteAllTestIssues; 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 { public class TestResourceStateEventsApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -27,18 +30,18 @@ public class TestResourceStateEventsApi extends AbstractIntegrationTest { ...@@ -27,18 +30,18 @@ public class TestResourceStateEventsApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
testProject = getTestProject(); testProject = getTestProject();
} }
@AfterClass @AfterAll
public static void teardown() { public static void teardown() {
deleteAllTestIssues(); 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 @Test
public void testGetCloseReopenIssueEvents() throws GitLabApiException { public void testGetCloseReopenIssueEvents() throws GitLabApiException {
Long projectId = testProject.getId(); Long projectId = testProject.getId();
......
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -35,12 +35,13 @@ import org.gitlab4j.api.models.Project; ...@@ -35,12 +35,13 @@ import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Runner; import org.gitlab4j.api.models.Runner;
import org.gitlab4j.api.models.Runner.RunnerStatus; import org.gitlab4j.api.models.Runner.RunnerStatus;
import org.gitlab4j.api.models.Runner.RunnerType; import org.gitlab4j.api.models.Runner.RunnerType;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties * In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
...@@ -53,8 +54,9 @@ import org.junit.runners.MethodSorters; ...@@ -53,8 +54,9 @@ import org.junit.runners.MethodSorters;
* <p> * <p>
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order * NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that the tests are in the correct order
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.JVM) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class) // FIXME check if it works properly
public class TestRunnersApi extends AbstractIntegrationTest { public class TestRunnersApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -63,7 +65,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { ...@@ -63,7 +65,7 @@ public class TestRunnersApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() throws GitLabApiException { public static void setup() throws GitLabApiException {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
...@@ -97,7 +99,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { ...@@ -97,7 +99,7 @@ public class TestRunnersApi extends AbstractIntegrationTest {
false, null)); false, null));
} }
@Before @BeforeEach
public void beforeMethod() throws GitLabApiException { public void beforeMethod() throws GitLabApiException {
assumeTrue(gitLabApi != null); assumeTrue(gitLabApi != null);
...@@ -113,7 +115,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { ...@@ -113,7 +115,7 @@ public class TestRunnersApi extends AbstractIntegrationTest {
// Arrange // Arrange
Runner runner = createRunner(); Runner runner = createRunner();
assertNotNull("Failed to create test runner.", runner); assertNotNull(runner, "Failed to create test runner.");
List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners(); List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners();
assertEquals(1, runners.size()); assertEquals(1, runners.size());
...@@ -125,7 +127,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { ...@@ -125,7 +127,7 @@ public class TestRunnersApi extends AbstractIntegrationTest {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Runner runner = createRunner(); Runner runner = createRunner();
assertNotNull("Failed to create test runner.", runner); assertNotNull(runner, "Failed to create test runner.");
} }
List<Runner> allRunners = gitLabApi.getRunnersApi().getAllRunners(); List<Runner> allRunners = gitLabApi.getRunnersApi().getAllRunners();
...@@ -143,7 +145,7 @@ public class TestRunnersApi extends AbstractIntegrationTest { ...@@ -143,7 +145,7 @@ public class TestRunnersApi extends AbstractIntegrationTest {
public void shouldHavePausedRunner() throws GitLabApiException { public void shouldHavePausedRunner() throws GitLabApiException {
Runner runner = createRunner(); Runner runner = createRunner();
assertNotNull("Failed to create test runner.", runner); assertNotNull(runner, "Failed to create test runner.");
List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners(RunnerType.GROUP_TYPE, RunnerStatus.PAUSED); List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners(RunnerType.GROUP_TYPE, RunnerStatus.PAUSED);
assertTrue(runners.isEmpty()); assertTrue(runners.isEmpty());
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List; import java.util.List;
...@@ -17,12 +17,14 @@ import org.gitlab4j.api.models.Project; ...@@ -17,12 +17,14 @@ import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.SearchBlob; import org.gitlab4j.api.models.SearchBlob;
import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.User;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestSearchApi extends AbstractIntegrationTest { public class TestSearchApi extends AbstractIntegrationTest {
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY); private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
...@@ -35,7 +37,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -35,7 +37,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void testSetup() { public static void testSetup() {
// Must setup the connection to the GitLab test server and get the test Project // Must setup the connection to the GitLab test server and get the test Project
...@@ -55,14 +57,14 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -55,14 +57,14 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGlobalProjectSearch() throws GitLabApiException { 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); assertNotNull(results);
assertTrue(results.get(0).getClass() == Project.class); assertTrue(results.get(0).getClass() == Project.class);
} }
@Test @Test
public void testGlobalIssuesSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Issue.class); assertTrue(results.get(0).getClass() == Issue.class);
...@@ -71,7 +73,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -71,7 +73,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGlobalMergeRequestsSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == MergeRequest.class); assertTrue(results.get(0).getClass() == MergeRequest.class);
...@@ -80,7 +82,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -80,7 +82,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGlobalMilestonesSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Milestone.class); assertTrue(results.get(0).getClass() == Milestone.class);
...@@ -89,16 +91,16 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -89,16 +91,16 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGlobalSnippetTitlesSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Snippet.class); assertTrue(results.get(0).getClass() == Snippet.class);
} }
} }
@Ignore @Disabled
public void testGlobalSnippetBlobsSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Snippet.class); assertTrue(results.get(0).getClass() == Snippet.class);
...@@ -107,21 +109,21 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -107,21 +109,21 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGlobalUsersSearch() throws GitLabApiException { 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); assertNotNull(results);
assertTrue(results.get(0).getClass() == User.class); assertTrue(results.get(0).getClass() == User.class);
} }
@Test @Test
public void testGroupProjectSearch() throws GitLabApiException { 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); assertNotNull(results);
assertTrue(results.get(0).getClass() == Project.class); assertTrue(results.get(0).getClass() == Project.class);
} }
@Test @Test
public void testGroupIssuesSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Issue.class); assertTrue(results.get(0).getClass() == Issue.class);
...@@ -130,7 +132,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -130,7 +132,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGrouplMergeRequestsSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == MergeRequest.class); assertTrue(results.get(0).getClass() == MergeRequest.class);
...@@ -139,7 +141,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -139,7 +141,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGroupMilestonesSearch() throws GitLabApiException { 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); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Milestone.class); assertTrue(results.get(0).getClass() == Milestone.class);
...@@ -148,14 +150,14 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -148,14 +150,14 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testGrouplUsersSearch() throws GitLabApiException { 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); assertNotNull(results);
assertTrue(results.get(0).getClass() == User.class); assertTrue(results.get(0).getClass() == User.class);
} }
@Test @Test
public void testProjectIssuesSearch() throws GitLabApiException { public void testProjectIssuesSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.ISSUES, TEST_PROJECT_NAME); testProject, ProjectSearchScope.ISSUES, TEST_PROJECT_NAME);
assertNotNull(results); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
...@@ -165,7 +167,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -165,7 +167,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testProjectlMergeRequestsSearch() throws GitLabApiException { public void testProjectlMergeRequestsSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME); testProject, ProjectSearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME);
assertNotNull(results); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
...@@ -175,7 +177,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -175,7 +177,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testProjectMilestonesSearch() throws GitLabApiException { public void testProjectMilestonesSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.MILESTONES, TEST_PROJECT_NAME); testProject, ProjectSearchScope.MILESTONES, TEST_PROJECT_NAME);
assertNotNull(results); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
...@@ -185,7 +187,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -185,7 +187,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testProjectNotesSearch() throws GitLabApiException { public void testProjectNotesSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.NOTES, TEST_PROJECT_NAME); testProject, ProjectSearchScope.NOTES, TEST_PROJECT_NAME);
assertNotNull(results); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
...@@ -195,7 +197,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -195,7 +197,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testProjectWikiBlobsSearch() throws GitLabApiException { public void testProjectWikiBlobsSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.WIKI_BLOBS, TEST_PROJECT_NAME); testProject, ProjectSearchScope.WIKI_BLOBS, TEST_PROJECT_NAME);
assertNotNull(results); assertNotNull(results);
if (results.size() > 0) { if (results.size() > 0) {
...@@ -205,7 +207,7 @@ public class TestSearchApi extends AbstractIntegrationTest { ...@@ -205,7 +207,7 @@ public class TestSearchApi extends AbstractIntegrationTest {
@Test @Test
public void testProjectlUsersSearch() throws GitLabApiException { public void testProjectlUsersSearch() throws GitLabApiException {
List<?> results = (List<?>) gitLabApi.getSearchApi().projectSearch( List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.USERS, TEST_LOGIN_USERNAME); testProject, ProjectSearchScope.USERS, TEST_LOGIN_USERNAME);
assertNotNull(results); assertNotNull(results);
assertTrue(results.get(0).getClass() == User.class); assertTrue(results.get(0).getClass() == User.class);
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.services.BugzillaService; import org.gitlab4j.api.services.BugzillaService;
...@@ -15,12 +15,13 @@ import org.gitlab4j.api.services.JiraService; ...@@ -15,12 +15,13 @@ import org.gitlab4j.api.services.JiraService;
import org.gitlab4j.api.services.MattermostService; import org.gitlab4j.api.services.MattermostService;
import org.gitlab4j.api.services.NotificationService.BranchesToBeNotified; import org.gitlab4j.api.services.NotificationService.BranchesToBeNotified;
import org.gitlab4j.api.services.SlackService; import org.gitlab4j.api.services.SlackService;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in * In order for these tests to run you must set the following properties in
...@@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters; ...@@ -30,8 +31,9 @@ import org.junit.runners.MethodSorters;
* *
* If any of the above are NULL, all tests in this class will be skipped. * If any of the above are NULL, all tests in this class will be skipped.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestServicesApi extends AbstractIntegrationTest { public class TestServicesApi extends AbstractIntegrationTest {
private static final String TEST_ENDPOINT = "https://foobar.com/gitlab_service/webhooks/"; private static final String TEST_ENDPOINT = "https://foobar.com/gitlab_service/webhooks/";
...@@ -43,7 +45,7 @@ public class TestServicesApi extends AbstractIntegrationTest { ...@@ -43,7 +45,7 @@ public class TestServicesApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project // Must setup the connection to the GitLab test server and get the test Project
...@@ -63,9 +65,9 @@ public class TestServicesApi extends AbstractIntegrationTest { ...@@ -63,9 +65,9 @@ public class TestServicesApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(testProject); assumeTrue(testProject != null);
} }
@Test @Test
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson; import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks; import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -14,8 +14,8 @@ import java.util.stream.Stream; ...@@ -14,8 +14,8 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.Discussion; import org.gitlab4j.api.models.Discussion;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
...@@ -28,9 +28,9 @@ public class TestSnippetDiscussionsApi implements Constants { ...@@ -28,9 +28,9 @@ public class TestSnippetDiscussionsApi implements Constants {
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor; @Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private MockResponse response; private MockResponse response;
@Before @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
initMocks(this); openMocks(this);
response = new MockResponse(Discussion.class, null, "snippet-discussions.json"); response = new MockResponse(Discussion.class, null, "snippet-discussions.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.Visibility; import org.gitlab4j.api.models.Visibility;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestSnippetsApi extends AbstractIntegrationTest { public class TestSnippetsApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi; private static GitLabApi gitLabApi;
...@@ -25,15 +27,15 @@ public class TestSnippetsApi extends AbstractIntegrationTest { ...@@ -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_CONTENT_2 = "test-snippet-content-2";
private static final String TEST_SNIPPET_DESCRIPTION_1 = "test-snippet-description-1"; private static final String TEST_SNIPPET_DESCRIPTION_1 = "test-snippet-description-1";
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
// Must setup the connection to the GitLab test server // Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup(); gitLabApi = baseTestSetup();
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
......
...@@ -3,13 +3,13 @@ package org.gitlab4j.api; ...@@ -3,13 +3,13 @@ package org.gitlab4j.api;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static org.gitlab4j.api.JsonUtils.compareJson; import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks; import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -17,9 +17,9 @@ import java.util.stream.Stream; ...@@ -17,9 +17,9 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.User;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
...@@ -34,7 +34,7 @@ public class TestStreams implements Constants { ...@@ -34,7 +34,7 @@ public class TestStreams implements Constants {
static private List<User> sortedUsers; static private List<User> sortedUsers;
@BeforeClass @BeforeAll
public static void setupClass() throws Exception { 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 // 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 { ...@@ -42,9 +42,9 @@ public class TestStreams implements Constants {
sortedUsers.sort(comparing(User::getUsername)); sortedUsers.sort(comparing(User::getUsername));
} }
@Before @BeforeEach
public void setup() throws Exception { public void setup() throws Exception {
initMocks(this); openMocks(this);
response = new MockResponse(User.class, null, "user-list.json"); response = new MockResponse(User.class, null, "user-list.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient); when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true); when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
package org.gitlab4j.api; package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List; import java.util.List;
import org.gitlab4j.api.models.SystemHook; import org.gitlab4j.api.models.SystemHook;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer;
import org.junit.Test; import org.junit.jupiter.api.Tag;
import org.junit.experimental.categories.Category; import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/** /**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties * In order for these tests to run you must set the following properties in test-gitlab4j.properties
...@@ -24,8 +25,9 @@ import org.junit.runners.MethodSorters; ...@@ -24,8 +25,9 @@ import org.junit.runners.MethodSorters;
* *
* If any of the above are NULL, all tests in this class will be skipped. * If any of the above are NULL, all tests in this class will be skipped.
*/ */
@Category(IntegrationTest.class) @Tag("integration")
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestSystemHooksApi extends AbstractIntegrationTest { public class TestSystemHooksApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository // The following needs to be set to your test repository
...@@ -39,7 +41,7 @@ public class TestSystemHooksApi extends AbstractIntegrationTest { ...@@ -39,7 +41,7 @@ public class TestSystemHooksApi extends AbstractIntegrationTest {
super(); super();
} }
@BeforeClass @BeforeAll
public static void setup() { public static void setup() {
if (TEST_HOOK_URL == null || TEST_HOOK_URL.trim().isEmpty()) { if (TEST_HOOK_URL == null || TEST_HOOK_URL.trim().isEmpty()) {
...@@ -50,9 +52,9 @@ public class TestSystemHooksApi extends AbstractIntegrationTest { ...@@ -50,9 +52,9 @@ public class TestSystemHooksApi extends AbstractIntegrationTest {
} }
} }
@Before @BeforeEach
public void beforeMethod() { public void beforeMethod() {
assumeNotNull(gitLabApi); assumeTrue(gitLabApi != null);
} }
@Test @Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment