forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSearchApi.java
216 lines (188 loc) · 8.01 KB
/
TestSearchApi.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.gitlab4j.api.Constants.GroupSearchScope;
import org.gitlab4j.api.Constants.ProjectSearchScope;
import org.gitlab4j.api.Constants.SearchScope;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.Milestone;
import org.gitlab4j.api.models.Note;
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.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)
@org.junit.jupiter.api.Disabled("Integration tests are disabled, see https://github.com/gitlab4j/gitlab4j-api/issues/1165")
public class TestSearchApi extends AbstractIntegrationTest {
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
private static GitLabApi gitLabApi;
private static Project testProject;
private static Group testGroup;
public TestSearchApi() {
super();
}
@BeforeAll
public static void testSetup() {
// Must setup the connection to the GitLab test server and get the test Project
// instance
gitLabApi = baseTestSetup();
testProject = getTestProject();
if (gitLabApi != null) {
try {
List<Group> groups = gitLabApi.getGroupApi().getGroups(TEST_GROUP);
testGroup = groups.get(0);
} catch (GitLabApiException gle) {
System.err.println("Problem fetching test group, error=" + gle.getMessage());
}
}
}
@Test
public void testGlobalProjectSearch() throws GitLabApiException {
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 = gitLabApi.getSearchApi().globalSearch(SearchScope.ISSUES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Issue.class);
}
}
@Test
public void testGlobalMergeRequestsSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().globalSearch(SearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == MergeRequest.class);
}
}
@Test
public void testGlobalMilestonesSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().globalSearch(SearchScope.MILESTONES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Milestone.class);
}
}
@Test
public void testGlobalSnippetTitlesSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_TITLES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Snippet.class);
}
}
@Disabled
public void testGlobalSnippetBlobsSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().globalSearch(SearchScope.SNIPPET_BLOBS, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Snippet.class);
}
}
@Test
public void testGlobalUsersSearch() throws GitLabApiException {
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 = 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 = gitLabApi.getSearchApi().groupSearch(testGroup, GroupSearchScope.ISSUES, TEST_GROUP_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Issue.class);
}
}
@Test
public void testGrouplMergeRequestsSearch() throws GitLabApiException {
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);
}
}
@Test
public void testGroupMilestonesSearch() throws GitLabApiException {
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);
}
}
@Test
public void testGrouplUsersSearch() throws GitLabApiException {
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 = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.ISSUES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Issue.class);
}
}
@Test
public void testProjectlMergeRequestsSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == MergeRequest.class);
}
}
@Test
public void testProjectMilestonesSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.MILESTONES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Milestone.class);
}
}
@Test
public void testProjectNotesSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.NOTES, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == Note.class);
}
}
@Test
public void testProjectWikiBlobsSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.WIKI_BLOBS, TEST_PROJECT_NAME);
assertNotNull(results);
if (results.size() > 0) {
assertTrue(results.get(0).getClass() == SearchBlob.class);
}
}
@Test
public void testProjectlUsersSearch() throws GitLabApiException {
List<?> results = gitLabApi.getSearchApi().projectSearch(
testProject, ProjectSearchScope.USERS, TEST_LOGIN_USERNAME);
assertNotNull(results);
assertTrue(results.get(0).getClass() == User.class);
}
}