forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestNamespaceApi.java
112 lines (95 loc) · 3.9 KB
/
TestNamespaceApi.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.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.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.
*
*/
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@org.junit.jupiter.api.Disabled("Integration tests are disabled, see https://github.com/gitlab4j/gitlab4j-api/issues/1165")
public class TestNamespaceApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
public TestNamespaceApi() {
super();
}
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
@Test
public void testGetNamespaces() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().getNamespaces();
assertNotNull(namespaces);
Optional<Namespace> matchingNamespace = namespaces.stream().
filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst();
assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!");
}
@Test
public void testGetNamespacesViaPager() throws GitLabApiException {
Pager<Namespace> pager = gitLabApi.getNamespaceApi().getNamespaces(10);
assertNotNull(pager);
while (pager.hasNext()) {
List<Namespace> namespaces = pager.next();
for (Namespace namespace : namespaces) {
if (TEST_NAMESPACE.equals(namespace.getPath()))
return;
}
}
fail(TEST_NAMESPACE + " not found!");
}
@Test
public void testGetNamespacesByPage() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().getNamespaces(1, 10);
assertNotNull(namespaces);
Optional<Namespace> matchingNamespace = namespaces.stream().
filter(n -> n.getPath().equals(TEST_NAMESPACE)).findFirst();
assertTrue(matchingNamespace.isPresent(), TEST_NAMESPACE + " not found!");
}
@Test
public void testFindNamespaces() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces(TEST_NAMESPACE);
assertNotNull(namespaces);
assertEquals(TEST_NAMESPACE, namespaces.get(0).getPath());
}
@Test
public void testFindSubgroupNamespaces() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces(TEST_SUB_GROUP);
assertNotNull(namespaces);
assertEquals(TEST_SUB_GROUP, namespaces.get(0).getPath());
}
@Test
public void testFindNamespacesByPage() throws GitLabApiException {
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces(TEST_NAMESPACE, 1, 10);
assertNotNull(namespaces);
assertEquals(TEST_NAMESPACE, namespaces.get(0).getPath());
}
@Test
public void testFindNamespacesViaPager() throws GitLabApiException {
Pager<Namespace> pager = gitLabApi.getNamespaceApi().findNamespaces(TEST_NAMESPACE, 10);
assertNotNull(pager);
assertEquals(TEST_NAMESPACE, pager.next().get(0).getPath());
}
}