forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestNotificationSettingsApi.java
91 lines (78 loc) · 3.38 KB
/
TestNotificationSettingsApi.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
package org.gitlab4j.api;
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.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
*
* TEST_NAMESPACE
* TEST_PROJECT_NAME
* TEST_GROUP
* 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")
@TestMethodOrder(MethodOrderer.MethodName.class)
public class TestNotificationSettingsApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
private static GitLabApi gitLabApi;
public TestNotificationSettingsApi() {
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 testGlobalNotificationSettings() throws GitLabApiException {
NotificationSettings settings = gitLabApi.getNotificationSettingsApi().getGlobalNotificationSettings();
assertNotNull(settings);
}
@Test
public void testSetGlobalNotificationSettings() throws GitLabApiException {
NotificationSettings settings = new NotificationSettings();
settings.setLevel(NotificationSettings.Level.DISABLED);
NotificationSettings newSettings = gitLabApi.getNotificationSettingsApi().updateGlobalNotificationSettings(settings);
assertNotNull(newSettings);
assertEquals(NotificationSettings.Level.DISABLED, newSettings.getLevel());
}
@Test
public void testGroupNotificationSettings() throws GitLabApiException {
assumeFalse(TEST_GROUP == null || TEST_GROUP.trim().isEmpty());
List<Group> groups = gitLabApi.getGroupApi().getGroups(TEST_GROUP);
assertNotNull(groups);
assertFalse(groups.isEmpty());
NotificationSettings settings = gitLabApi.getNotificationSettingsApi().getGroupNotificationSettings(groups.get(0).getId());
assertNotNull(settings);
}
@Test
public void testProjectNotificationSettings() throws GitLabApiException {
Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME);
assertNotNull(project);
NotificationSettings settings = gitLabApi.getNotificationSettingsApi().getProjectNotificationSettings(project.getId());
assertNotNull(settings);
}
}