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