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

Migrate from JUnit 4 to JUnit 5

parent 73817d15
......@@ -28,7 +28,7 @@ import static org.gitlab4j.api.JsonUtils.readTreeFromResource;
import static org.gitlab4j.api.JsonUtils.unmarshalResource;
import static org.gitlab4j.api.JsonUtils.unmarshalResourceList;
import static org.gitlab4j.api.JsonUtils.unmarshalResourceMap;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
......@@ -112,7 +112,7 @@ import org.gitlab4j.api.models.User;
import org.gitlab4j.api.models.Variable;
import org.gitlab4j.api.services.JiraService;
import org.gitlab4j.api.services.SlackService;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode;
......
......@@ -4,11 +4,11 @@ package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.gitlab4j.api.JsonUtils.readTreeFromResource;
import static org.gitlab4j.api.JsonUtils.unmarshalResource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
......@@ -25,7 +25,8 @@ import org.gitlab4j.api.systemhooks.SystemHookListener;
import org.gitlab4j.api.systemhooks.SystemHookManager;
import org.gitlab4j.api.systemhooks.TeamMemberSystemHookEvent;
import org.gitlab4j.api.utils.JacksonJson;
import org.gitlab4j.api.webhook.*;
import org.gitlab4j.api.webhook.BuildEvent;
import org.gitlab4j.api.webhook.ChangeContainer;
import org.gitlab4j.api.webhook.Event;
import org.gitlab4j.api.webhook.IssueEvent;
import org.gitlab4j.api.webhook.JobEvent;
......@@ -35,9 +36,9 @@ import org.gitlab4j.api.webhook.PipelineEvent;
import org.gitlab4j.api.webhook.PushEvent;
import org.gitlab4j.api.webhook.TagPushEvent;
import org.gitlab4j.api.webhook.WikiPageEvent;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializationFeature;
......@@ -52,14 +53,14 @@ public class TestGitLabApiEvents {
super();
}
@BeforeClass
@BeforeAll
public static void setup() throws Exception {
jacksonJson = new JacksonJson();
jacksonJson.getObjectMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
savedLevel = GitLabApi.getLogger().getLevel();
}
@AfterClass
@AfterAll
public static void teardown() {
GitLabApi.getLogger().setLevel(savedLevel);
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Map;
......@@ -14,11 +14,12 @@ import javax.ws.rs.core.Response.Status;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Visibility;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
......@@ -29,7 +30,8 @@ import org.junit.experimental.categories.Category;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestGitLabApiException extends AbstractIntegrationTest {
private static final String TEST_PROJECT_NAME_DUPLICATE = "test-gitlab4j-create-project-duplicate";
......@@ -45,7 +47,7 @@ public class TestGitLabApiException extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
......@@ -53,7 +55,7 @@ public class TestGitLabApiException extends AbstractIntegrationTest {
deleteAllTestProjects();
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
deleteAllTestProjects();
}
......@@ -67,9 +69,9 @@ public class TestGitLabApiException extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.models.Version;
import org.gitlab4j.api.utils.SecretString;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_HOST_URL
* TEST_LOGIN_USERNAME
* TEST_LOGIN_PASSWORD
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestGitLabLogin implements PropertyConstants {
// The following needs to be set to your test repository
......@@ -35,7 +37,7 @@ public class TestGitLabLogin implements PropertyConstants {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
problems = "";
......@@ -61,7 +63,7 @@ public class TestGitLabLogin implements PropertyConstants {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(problems != null && problems.isEmpty());
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -19,11 +18,12 @@ import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.GroupParams;
import org.gitlab4j.api.models.Member;
import org.gitlab4j.api.models.User;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -37,7 +37,8 @@ import org.junit.experimental.categories.Category;
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestGroupApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -53,7 +54,7 @@ public class TestGroupApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -84,7 +85,7 @@ public class TestGroupApi extends AbstractIntegrationTest {
removeGroupMembers();
}
@AfterClass
@AfterAll
public static void teardown() {
removeGroupMembers();
}
......@@ -113,11 +114,11 @@ public class TestGroupApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeNotNull(testGroup);
assumeNotNull(testUser);
assumeTrue(gitLabApi != null);
assumeTrue(testGroup != null);
assumeTrue(testUser != null);
}
@Test
......
......@@ -23,11 +23,11 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -35,11 +35,12 @@ import java.util.stream.Stream;
import org.gitlab4j.api.models.CustomAttribute;
import org.gitlab4j.api.models.Group;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
......@@ -51,7 +52,8 @@ import org.junit.experimental.categories.Category;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestGroupCustomAttributes extends AbstractIntegrationTest {
private static final String TEST_CUSTOM_ATTRIBUTE_KEY = "GitLab4JCustomAttributeTestKey";
......@@ -64,7 +66,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Group instance
......@@ -74,7 +76,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
deleteAllTestCustomAttributes();
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
deleteAllTestCustomAttributes();
}
......@@ -95,9 +97,9 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
private CustomAttribute createCustomAttribute(String key, String value) throws GitLabApiException {
......@@ -116,7 +118,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
@Test
public void testUpdate() throws GitLabApiException {
assumeNotNull(testGroup);
assumeTrue(testGroup != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestUpdate";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE;
......@@ -134,7 +136,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
@Test
public void testGetCustomAttribute() throws GitLabApiException {
assumeNotNull(testGroup);
assumeTrue(testGroup != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestGet";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test get)";
......@@ -151,7 +153,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
@Test
public void testListCustomAttributes() throws GitLabApiException {
assumeNotNull(testGroup);
assumeTrue(testGroup != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestList";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test list)";
......@@ -171,7 +173,7 @@ public class TestGroupCustomAttributes extends AbstractIntegrationTest {
@Test
public void testDeleteCustomAttribute() throws GitLabApiException {
assumeNotNull(testGroup);
assumeTrue(testGroup != null);
String key = TEST_CUSTOM_ATTRIBUTE_KEY + "TestDelete";
String value = TEST_CUSTOM_ATTRIBUTE_VALUE + " (test delete)";
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.models.HealthCheckInfo;
import org.gitlab4j.api.utils.AccessTokenUtils;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -19,7 +20,8 @@ import org.junit.experimental.categories.Category;
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestHealthCheckApi implements PropertyConstants {
// The following needs to be set to your test repository
......@@ -33,7 +35,7 @@ public class TestHealthCheckApi implements PropertyConstants {
super();
}
@BeforeClass
@BeforeAll
public static void setup() throws GitLabApiException {
String problems = "";
......@@ -59,7 +61,7 @@ public class TestHealthCheckApi implements PropertyConstants {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.text.ParseException;
import java.util.Date;
import org.gitlab4j.api.utils.ISO8601;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestISO8601 {
......
package org.gitlab4j.api;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Version;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -21,7 +22,8 @@ import org.junit.experimental.categories.Category;
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestIgnoreCertificateErrors implements PropertyConstants {
// The following needs to be set to your test repository
......@@ -34,7 +36,7 @@ public class TestIgnoreCertificateErrors implements PropertyConstants {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
String problems = "";
......@@ -54,7 +56,7 @@ public class TestIgnoreCertificateErrors implements PropertyConstants {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(setupOk);
}
......
......@@ -23,11 +23,11 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File;
import java.util.Optional;
......@@ -35,13 +35,14 @@ import java.util.Optional;
import org.gitlab4j.api.models.ExportStatus;
import org.gitlab4j.api.models.ImportStatus;
import org.gitlab4j.api.models.Project;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
......@@ -53,8 +54,9 @@ import org.junit.runners.MethodSorters;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestImportExportApi extends AbstractIntegrationTest {
private static final String TEST_IMPORT_PROJECT_NAME = "test-import-project";
......@@ -65,7 +67,7 @@ public class TestImportExportApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -75,7 +77,7 @@ public class TestImportExportApi extends AbstractIntegrationTest {
deleteAllTestProjects();
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
deleteAllTestProjects();
}
......@@ -91,16 +93,16 @@ public class TestImportExportApi extends AbstractIntegrationTest {
} catch (GitLabApiException ignore) {}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
public void testExportDownloadAndImport() throws GitLabApiException {
// Arrange
assumeNotNull(testProject);
assumeTrue(testProject != null);
// Act
gitLabApi.getImportExportApi().scheduleExport(testProject);
......
package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List;
import java.util.stream.Collectors;
......@@ -14,8 +14,8 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.Discussion;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
......@@ -28,9 +28,9 @@ public class TestIssueDiscussionsApi implements Constants {
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private MockResponse response;
@Before
@BeforeEach
public void setUp() throws Exception {
initMocks(this);
openMocks(this);
response = new MockResponse(Discussion.class, null, "issue-discussions.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
......@@ -23,11 +23,11 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Arrays;
import java.util.Date;
......@@ -44,11 +44,12 @@ import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.IssueFilter;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.TimeStats;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
......@@ -60,7 +61,8 @@ import org.junit.experimental.categories.Category;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestIssuesApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -76,7 +78,7 @@ public class TestIssuesApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance
......@@ -91,12 +93,12 @@ public class TestIssuesApi extends AbstractIntegrationTest {
deleteAllTestIssues();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
deleteAllTestIssues();
}
......@@ -157,7 +159,7 @@ public class TestIssuesApi extends AbstractIntegrationTest {
@Test
public void testGetGroupIssues() throws GitLabApiException {
assumeNotNull(testGroup);
assumeTrue(testGroup != null);
List<Issue> issues = gitLabApi.getIssuesApi().getGroupIssues(testGroup);
assertNotNull(issues);
}
......
......@@ -23,18 +23,19 @@
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import org.gitlab4j.api.models.Job;
import org.gitlab4j.api.models.Project;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in ~/test-gitlab4j.properties
......@@ -46,7 +47,8 @@ import org.junit.experimental.categories.Category;
* <p>
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestJobApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -56,20 +58,20 @@ public class TestJobApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server and get the test Project instance
gitLabApi = baseTestSetup();
testProject = getTestProject();
}
@AfterClass
@AfterAll
public static void teardown() throws GitLabApiException {
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(testProject);
assumeTrue(testProject != null);
}
@Test
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -13,13 +13,15 @@ import java.util.stream.Stream;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Label;
import org.gitlab4j.api.models.Project;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category(IntegrationTest.class)
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestLabelsApi extends AbstractIntegrationTest {
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
......@@ -36,7 +38,7 @@ public class TestLabelsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void testSetup() {
// Must setup the connection to the GitLab test server and get the test Project instance
......@@ -60,7 +62,7 @@ public class TestLabelsApi extends AbstractIntegrationTest {
deleteTestLabels();
}
@AfterClass
@AfterAll
public static void tearDown() {
deleteTestLabels();
}
......@@ -86,7 +88,7 @@ public class TestLabelsApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(testProject != null);
}
......
package org.gitlab4j.api;
import org.gitlab4j.api.models.Markdown;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@Category(IntegrationTest.class)
import org.gitlab4j.api.models.Markdown;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestMarkdownApi extends AbstractIntegrationTest {
private static final String EXPECTED_HTML_FOR_SPECIAL = "<p data-sourcepos=\"1:1-1:104\" dir=\"auto\">Hello world! <gl-emoji title=\"party popper\" data-name=\"tada\" data-unicode-version=\"6.0\">🎉</gl-emoji> <code>xml &lt;profiles&gt; &lt;version&gt;${maven-surefire-plugin.version}&lt;/version&gt; &lt;/profiles&gt;</code></p>";
......@@ -30,12 +32,12 @@ public class TestMarkdownApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
gitLabApi = baseTestSetup();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
......
package org.gitlab4j.api;
import static java.util.stream.Collectors.toList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
......@@ -21,13 +21,14 @@ import org.gitlab4j.api.models.Pipeline;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.models.User;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -41,8 +42,9 @@ import org.junit.runners.MethodSorters;
*
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestMergeRequestApi extends AbstractIntegrationTest {
private static final String TEST_BRANCH_NAME = "feature/gitlab4j-merge-request-test";
......@@ -59,7 +61,7 @@ public class TestMergeRequestApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
......@@ -70,7 +72,7 @@ public class TestMergeRequestApi extends AbstractIntegrationTest {
teardown();
}
@AfterClass
@AfterAll
public static void teardown() {
if (testProject == null) {
......@@ -101,9 +103,9 @@ public class TestMergeRequestApi extends AbstractIntegrationTest {
}
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(testProject);
assumeTrue(testProject != null);
}
@Test
......
package org.gitlab4j.api;
import static org.gitlab4j.api.JsonUtils.compareJson;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.MockitoAnnotations.openMocks;
import java.util.List;
import java.util.stream.Collectors;
......@@ -14,8 +14,8 @@ import java.util.stream.Stream;
import javax.ws.rs.core.MultivaluedMap;
import org.gitlab4j.api.models.Discussion;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
......@@ -28,9 +28,9 @@ public class TestMergeRequestDiscussionsApi implements Constants {
@Captor private ArgumentCaptor<MultivaluedMap<String, String>> attributeCaptor;
private MockResponse response;
@Before
@BeforeEach
public void setUp() throws Exception {
initMocks(this);
openMocks(this);
response = new MockResponse(Discussion.class, null, "merge-request-discussions.json");
when(gitLabApi.getApiClient()).thenReturn(gitLabApiClient);
when(gitLabApiClient.validateSecretToken(any())).thenReturn(true);
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import java.util.Optional;
import org.gitlab4j.api.models.Namespace;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
*
* TEST_NAMESPACE
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Category(IntegrationTest.class)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
public class TestNamespaceApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -34,15 +36,15 @@ public class TestNamespaceApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......@@ -51,7 +53,7 @@ public class TestNamespaceApi extends AbstractIntegrationTest {
assertNotNull(namespaces);
Optional<Namespace> matchingNamespace = namespaces.stream().
filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst();
assertTrue(TEST_NAMESPACE + " not found!", matchingNamespace.isPresent());
assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!");
}
@Test
......@@ -76,7 +78,7 @@ public class TestNamespaceApi extends AbstractIntegrationTest {
assertNotNull(namespaces);
Optional<Namespace> matchingNamespace = namespaces.stream().
filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst();
assertTrue(TEST_NAMESPACE + " not found!", matchingNamespace.isPresent());
assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!");
}
@Test
......
package org.gitlab4j.api;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
......@@ -10,12 +10,13 @@ import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.Note;
import org.gitlab4j.api.models.Project;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -27,8 +28,9 @@ import org.junit.runners.MethodSorters;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestNotesApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
......@@ -37,15 +39,15 @@ public class TestNotesApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......
package org.gitlab4j.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.List;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.NotificationSettings;
import org.gitlab4j.api.models.Project;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
......@@ -29,8 +30,9 @@ import org.junit.runners.MethodSorters;
*
* If any of the above are NULL, all tests in this class will be skipped.
*/
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestNotificationSettingsApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
......@@ -42,15 +44,15 @@ public class TestNotificationSettingsApi extends AbstractIntegrationTest {
super();
}
@BeforeClass
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@Before
@BeforeEach
public void beforeMethod() {
assumeNotNull(gitLabApi);
assumeTrue(gitLabApi != null);
}
@Test
......
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