forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestGitLabCiYamlApi.java
67 lines (57 loc) · 2.41 KB
/
TestGitLabCiYamlApi.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
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertAll;
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.GitLabCiTemplate;
import org.gitlab4j.api.models.GitLabCiTemplateElement;
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_PROJECT_NAME
* TEST_HOST_URL
*
* 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 TestGitLabCiYamlApi extends AbstractIntegrationTest {
private static GitLabApi gitLabApi;
@BeforeAll
public static void setUp() {
gitLabApi = baseTestSetup();
}
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
@Test
public void testGetAllCiYamlTemplates() throws GitLabApiException {
List<GitLabCiTemplateElement> ciYamlTemplatesElements = gitLabApi.getGitLabCiYamlApi().getAllGitLabCiYamlTemplates();
assertAll(
() -> assertNotNull(ciYamlTemplatesElements),
() -> assertTrue(ciYamlTemplatesElements.size() > 0)
);
}
@Test
public void testGetSingleCiYamlTemplate() throws GitLabApiException {
List<GitLabCiTemplateElement> ciYamlTemplatesElements = gitLabApi.getGitLabCiYamlApi().getAllGitLabCiYamlTemplates();
assumeTrue(ciYamlTemplatesElements != null);
assumeTrue(ciYamlTemplatesElements.size() > 0);
String templateKey = ciYamlTemplatesElements.get(0).getKey();
GitLabCiTemplate ciYamlTemplate = gitLabApi.getGitLabCiYamlApi().getSingleGitLabCiYamlTemplate(templateKey);
assertAll(
() -> assertNotNull(ciYamlTemplate),
() -> assertNotNull(ciYamlTemplate.getContent()),
() -> assertEquals(templateKey, ciYamlTemplate.getName())
);
}
}