diff --git a/README.md b/README.md index 5337402a..5613e509 100644 --- a/README.md +++ b/README.md @@ -636,7 +636,7 @@ List runners = gitLabApi.getRunnersApi().getAllRunners(); #### SearchApi ```java // Do a global search for Projects -List projects = gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, "text-to-search-for"); +List projects = gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, "text-to-search-for"); ``` #### ServicesApi diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index 117b7dae..c42ec279 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -1,8 +1,20 @@ package org.gitlab4j.api; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; - +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.gitlab4j.api.models.Commit; +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.gitlab4j.api.utils.JacksonJsonEnumHelper; import com.fasterxml.jackson.annotation.JsonCreator; @@ -753,79 +765,147 @@ public String toString() { /** * Enum for the search scope when doing a globalSearch() with the SearchApi. */ - public enum SearchScope { + public static class SearchScope { + + private final String jsonName; + private final Class resultType; + + private SearchScope(String jsonName, Class resultType) { + this.jsonName = jsonName; + this.resultType = resultType; + } - PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, SNIPPET_TITLES, SNIPPET_BLOBS, USERS, - BLOBS, COMMITS, WIKI_BLOBS; + public Class getResultType() { + return resultType; + } + + public static final SearchScope PROJECTS = new SearchScope<>("projects", Project.class); + public static final SearchScope ISSUES = new SearchScope<>("issues", Issue.class); + public static final SearchScope MERGE_REQUESTS = new SearchScope<>("merge_requests", MergeRequest.class); + public static final SearchScope MILESTONES = new SearchScope<>("milestones", Milestone.class); + public static final SearchScope SNIPPET_TITLES = new SearchScope<>("snippet_titles", Snippet.class); + public static final SearchScope SNIPPET_BLOBS = new SearchScope<>("snippet_blobs", Snippet.class); + public static final SearchScope USERS = new SearchScope<>("users", User.class); + public static final SearchScope BLOBS = new SearchScope<>("blobs", SearchBlob.class); + public static final SearchScope COMMITS = new SearchScope<>("commits", Commit.class); + public static final SearchScope WIKI_BLOBS = new SearchScope<>("wiki_blobs", SearchBlob.class); - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SearchScope.class); + private static final Map jsonLookup = Arrays.stream(new SearchScope[]{PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, SNIPPET_TITLES, SNIPPET_BLOBS, USERS, BLOBS, COMMITS, WIKI_BLOBS}) + .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator - public static SearchScope forValue(String value) { - return enumHelper.forValue(value); + public static SearchScope forValue(String value) { + return (SearchScope) jsonLookup.get(value); } @JsonValue public String toValue() { - return (enumHelper.toString(this)); + return jsonName; } @Override public String toString() { - return (enumHelper.toString(this)); + return jsonName; } } /** * Enum for the search scope when doing a groupSearch() with the SearchApi. */ - public enum GroupSearchScope { + public static class GroupSearchScope { + + private final String jsonName; + private final Class resultType; - PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, WIKI_BLOBS, COMMITS, BLOBS, NOTES, USERS; + public GroupSearchScope(String jsonName, Class resultType) { + this.jsonName = jsonName; + this.resultType = resultType; + } - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(GroupSearchScope.class); + public Class getResultType() { + return resultType; + } + + public static final GroupSearchScope PROJECTS = new GroupSearchScope<>("projects", Project.class); + public static final GroupSearchScope ISSUES = new GroupSearchScope<>("issues", Issue.class); + public static final GroupSearchScope MERGE_REQUESTS = new GroupSearchScope<>("merge_requests", MergeRequest.class); + public static final GroupSearchScope MILESTONES = new GroupSearchScope<>("milestones", Milestone.class); + public static final GroupSearchScope WIKI_BLOBS = new GroupSearchScope<>("wiki_blobs", SearchBlob.class); + public static final GroupSearchScope COMMITS = new GroupSearchScope<>("commits", Commit.class); + public static final GroupSearchScope BLOBS = new GroupSearchScope<>("blobs", SearchBlob.class); + public static final GroupSearchScope NOTES = new GroupSearchScope<>("notes", Note.class); + public static final GroupSearchScope USERS = new GroupSearchScope<>("users", User.class); + + private static final Map jsonLookup = Arrays.stream(new GroupSearchScope[]{ + PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, WIKI_BLOBS, COMMITS, BLOBS, NOTES, USERS, + }) + .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator - public static GroupSearchScope forValue(String value) { - return enumHelper.forValue(value); + public static GroupSearchScope forValue(String value) { + return (GroupSearchScope) jsonLookup.get(value); } @JsonValue public String toValue() { - return (enumHelper.toString(this)); + return jsonName; } @Override public String toString() { - return (enumHelper.toString(this)); + return jsonName; } } /** * Enum for the search scope when doing a projectSearch() with the SearchApi. */ - public enum ProjectSearchScope { + public static class ProjectSearchScope { + + private final String jsonName; + private final Class resultType; + + public ProjectSearchScope(String jsonName, Class resultType) { + this.jsonName = jsonName; + this.resultType = resultType; + } + + public Class getResultType() { + return resultType; + } - BLOBS, COMMITS, ISSUES, MERGE_REQUESTS, MILESTONES, NOTES, WIKI_BLOBS, USERS; + public static final ProjectSearchScope BLOBS = new ProjectSearchScope<>("blobs", SearchBlob.class); + public static final ProjectSearchScope COMMITS = new ProjectSearchScope<>("commits", Commit.class); + public static final ProjectSearchScope ISSUES = new ProjectSearchScope<>("issues", Issue.class); + public static final ProjectSearchScope MERGE_REQUESTS = new ProjectSearchScope<>("merge_requests", MergeRequest.class); + public static final ProjectSearchScope MILESTONES = new ProjectSearchScope<>("milestones", Milestone.class); + public static final ProjectSearchScope NOTES = new ProjectSearchScope<>("notes", Note.class); + public static final ProjectSearchScope WIKI_BLOBS = new ProjectSearchScope<>("wiki_blobs", SearchBlob.class); + public static final ProjectSearchScope USERS = new ProjectSearchScope<>("users", User.class); - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ProjectSearchScope.class); + + private static final Map jsonLookup = Arrays.stream(new ProjectSearchScope[]{ + BLOBS, COMMITS, ISSUES, MERGE_REQUESTS, MILESTONES, NOTES, WIKI_BLOBS, USERS, + }) + .collect(Collectors.toMap(searchScope -> searchScope.jsonName, Function.identity())); @JsonCreator - public static ProjectSearchScope forValue(String value) { - return enumHelper.forValue(value); + public static ProjectSearchScope forValue(String value) { + return (ProjectSearchScope) jsonLookup.get(value); } @JsonValue public String toValue() { - return (enumHelper.toString(this)); + return jsonName; } @Override public String toString() { - return (enumHelper.toString(this)); + return jsonName; } } + /** Enum to use for specifying the action when doing a getTodos() with the TodosApi. */ public enum TodoAction { @@ -1107,10 +1187,10 @@ public enum DefaultBranchProtectionLevel { FULLY_PROTECTED(2), PROTECTED_AGAINST_PUSHES(3), FULL_PROTECTION_AFTER_INITIAL_PUSH(4); - + @JsonValue private final int value; - + private DefaultBranchProtectionLevel(int value) { this.value = value; } diff --git a/src/main/java/org/gitlab4j/api/SearchApi.java b/src/main/java/org/gitlab4j/api/SearchApi.java index 9d3d4fe2..e72c4bb0 100644 --- a/src/main/java/org/gitlab4j/api/SearchApi.java +++ b/src/main/java/org/gitlab4j/api/SearchApi.java @@ -35,7 +35,7 @@ public SearchApi(GitLabApi gitLabApi) { * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public List globalSearch(SearchScope scope, String search) throws GitLabApiException { + public List globalSearch(SearchScope scope, String search) throws GitLabApiException { return (globalSearch(scope, search, this.getDefaultPerPage()).all()); } @@ -51,7 +51,7 @@ public List globalSearch(SearchScope scope, String search) throws GitLabApiEx * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Stream globalSearchStream(SearchScope scope, String search) throws GitLabApiException { + public Stream globalSearchStream(SearchScope scope, String search) throws GitLabApiException { return (globalSearch(scope, search, getDefaultPerPage()).stream()); } @@ -68,48 +68,15 @@ public Stream globalSearchStream(SearchScope scope, String search) throws Git * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Pager globalSearch(SearchScope scope, String search, int itemsPerPage) throws GitLabApiException { + public Pager globalSearch(SearchScope scope, String search, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("scope", scope, true) .withParam("search", search, true); - switch (scope) { - case BLOBS: - return (new Pager(this, SearchBlob.class, itemsPerPage, formData.asMap(), "search")); - - case COMMITS: - return (new Pager(this, Commit.class, itemsPerPage, formData.asMap(), "search")); - - case PROJECTS: - return (new Pager(this, Project.class, itemsPerPage, formData.asMap(), "search")); - - case ISSUES: - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), "search")); - - case MERGE_REQUESTS: - return (new Pager(this, MergeRequest.class, itemsPerPage, formData.asMap(), "search")); - - case MILESTONES: - return (new Pager(this, Milestone.class, itemsPerPage, formData.asMap(), "search")); - - case SNIPPET_TITLES: - return (new Pager(this, Snippet.class, itemsPerPage, formData.asMap(), "search")); - - case SNIPPET_BLOBS: - return (new Pager(this, Snippet.class, itemsPerPage, formData.asMap(), "search")); - - case USERS: - return (new Pager(this, User.class, itemsPerPage, formData.asMap(), "search")); - - case WIKI_BLOBS: - return (new Pager(this, SearchBlob.class, itemsPerPage, formData.asMap(), "search")); - - default: - throw new GitLabApiException("Invalid SearchScope [" + scope + "]"); - } + return (new Pager<>(this, scope.getResultType(), itemsPerPage, formData.asMap(), "search")); } - + /** * Search within the specified group. If a user is not a member of a group and the group is private, * a request on that group will result to a 404 status code. @@ -124,7 +91,7 @@ public Pager globalSearch(SearchScope scope, String search, int itemsPerPage) * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public List groupSearch(Object groupIdOrPath, GroupSearchScope scope, String search) throws GitLabApiException { + public List groupSearch(Object groupIdOrPath, GroupSearchScope scope, String search) throws GitLabApiException { return (groupSearch(groupIdOrPath, scope, search, this.getDefaultPerPage()).all()); } @@ -142,7 +109,7 @@ public List groupSearch(Object groupIdOrPath, GroupSearchScope scope, String * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Stream groupSearchStream(Object groupIdOrPath, GroupSearchScope scope, String search) throws GitLabApiException { + public Stream groupSearchStream(Object groupIdOrPath, GroupSearchScope scope, String search) throws GitLabApiException { return (groupSearch(groupIdOrPath, scope, search, getDefaultPerPage()).stream()); } @@ -161,49 +128,15 @@ public Stream groupSearchStream(Object groupIdOrPath, GroupSearchScope scope, * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Pager groupSearch(Object groupIdOrPath, GroupSearchScope scope, String search, int itemsPerPage) throws GitLabApiException { + public Pager groupSearch(Object groupIdOrPath, GroupSearchScope scope, String search, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("scope", scope, true) .withParam("search", search, true); - switch (scope) { - case PROJECTS: - return (new Pager(this, Project.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case ISSUES: - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case MERGE_REQUESTS: - return (new Pager(this, MergeRequest.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case MILESTONES: - return (new Pager(this, Milestone.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case BLOBS: - case WIKI_BLOBS: - return (new Pager(this, SearchBlob.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); + return new Pager<>(this, scope.getResultType(), itemsPerPage, formData.asMap(), + "groups", getGroupIdOrPath(groupIdOrPath), "search"); - case COMMITS: - return (new Pager(this, Commit.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case NOTES: - return (new Pager(this, Note.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - case USERS: - return (new Pager(this, User.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "search")); - - default: - throw new GitLabApiException("Invalid GroupSearchScope [" + scope + "]"); - } } /** @@ -220,7 +153,7 @@ public Pager groupSearch(Object groupIdOrPath, GroupSearchScope scope, String * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search) throws GitLabApiException { + public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search) throws GitLabApiException { return (projectSearch(projectIdOrPath, scope, search, null, this.getDefaultPerPage()).all()); } @@ -234,16 +167,16 @@ public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, S * @param scope search the expression within the specified scope. Currently these scopes are supported: * issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users * @param search the search query - * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by + * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by * default. This is only applicable for scopes: commits, blobs, and wiki_blobs. * @return a List containing the object type specified by the scope * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref) throws GitLabApiException { + public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref) throws GitLabApiException { return (projectSearch(projectIdOrPath, scope, search, ref, this.getDefaultPerPage()).all()); } - + /** * Search within the specified project. If a user is not a member of a project and the project is private, * a request on that project will result to a 404 status code. @@ -258,7 +191,7 @@ public List projectSearch(Object projectIdOrPath, ProjectSearchScope scope, S * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope scope, String search) throws GitLabApiException { + public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope scope, String search) throws GitLabApiException { return (projectSearch(projectIdOrPath, scope, search, null, getDefaultPerPage()).stream()); } @@ -272,13 +205,13 @@ public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope * @param scope search the expression within the specified scope. Currently these scopes are supported: * issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users * @param search the search query - * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by + * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by * default. This is only applicable for scopes: commits, blobs, and wiki_blobs. * @return a Stream containing the object type specified by the scope * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref) throws GitLabApiException { + public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref) throws GitLabApiException { return (projectSearch(projectIdOrPath, scope, search, ref, getDefaultPerPage()).stream()); } @@ -298,11 +231,11 @@ public Stream projectSearchStream(Object projectIdOrPath, ProjectSearchScope * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Pager projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, int itemsPerPage) throws GitLabApiException { + public Pager projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, int itemsPerPage) throws GitLabApiException { return projectSearch(projectIdOrPath, scope, search, null, itemsPerPage); } - + /** * Search within the specified project. If a user is not a member of a project and the project is private, * a request on that project will result to a 404 status code. @@ -313,61 +246,28 @@ public Pager projectSearch(Object projectIdOrPath, ProjectSearchScope scope, * @param scope search the expression within the specified scope. Currently these scopes are supported: * issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users * @param search the search query - * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by + * @param ref the name of a repository branch or tag to search on. The project’s default branch is used by * default. This is only applicable for scopes: commits, blobs, and wiki_blobs. * @param itemsPerPage the number of items that will be fetched per page * @return a Pager containing the object type specified by the scope * @throws GitLabApiException if any exception occurs * @since GitLab 10.5 */ - public Pager projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref, int itemsPerPage) throws GitLabApiException { + public Pager projectSearch(Object projectIdOrPath, ProjectSearchScope scope, String search, String ref, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("scope", scope, true) .withParam("search", search, true) .withParam("ref", ref, false); - + if (ref != null) { if (!scope.equals(ProjectSearchScope.BLOBS) && !scope.equals(ProjectSearchScope.WIKI_BLOBS) && !scope.equals(ProjectSearchScope.COMMITS)) { throw new GitLabApiException("Ref parameter is only applicable for scopes: commits, blobs, and wiki_blobs"); } } - switch (scope) { - case BLOBS: - return (new Pager(this, SearchBlob.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case COMMITS: - return (new Pager(this, Commit.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); + return (new Pager<>(this, scope.getResultType(), itemsPerPage, formData.asMap(), + "projects", getProjectIdOrPath(projectIdOrPath), "search")); - case ISSUES: - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case MERGE_REQUESTS: - return (new Pager(this, MergeRequest.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case MILESTONES: - return (new Pager(this, Milestone.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case NOTES: - return (new Pager(this, Note.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case WIKI_BLOBS: - return (new Pager(this, SearchBlob.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - case USERS: - return (new Pager(this, User.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "search")); - - default: - throw new GitLabApiException("Invalid ProjectSearchScope [" + scope + "]"); - } } -} \ No newline at end of file +} diff --git a/src/test/java/org/gitlab4j/api/TestSearchApi.java b/src/test/java/org/gitlab4j/api/TestSearchApi.java index ad0f6d5b..c8bb219e 100644 --- a/src/test/java/org/gitlab4j/api/TestSearchApi.java +++ b/src/test/java/org/gitlab4j/api/TestSearchApi.java @@ -58,14 +58,14 @@ public static void testSetup() { @Test public void testGlobalProjectSearch() throws GitLabApiException { - List results = 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 = 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); @@ -74,7 +74,7 @@ public void testGlobalIssuesSearch() throws GitLabApiException { @Test public void testGlobalMergeRequestsSearch() throws GitLabApiException { - List results = 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); @@ -83,7 +83,7 @@ public void testGlobalMergeRequestsSearch() throws GitLabApiException { @Test public void testGlobalMilestonesSearch() throws GitLabApiException { - List results = 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); @@ -92,7 +92,7 @@ public void testGlobalMilestonesSearch() throws GitLabApiException { @Test public void testGlobalSnippetTitlesSearch() throws GitLabApiException { - List results = 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); @@ -101,7 +101,7 @@ public void testGlobalSnippetTitlesSearch() throws GitLabApiException { @Disabled public void testGlobalSnippetBlobsSearch() throws GitLabApiException { - List results = 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); @@ -110,21 +110,21 @@ public void testGlobalSnippetBlobsSearch() throws GitLabApiException { @Test public void testGlobalUsersSearch() throws GitLabApiException { - List results = 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 = 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 = 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); @@ -133,7 +133,7 @@ public void testGroupIssuesSearch() throws GitLabApiException { @Test public void testGrouplMergeRequestsSearch() throws GitLabApiException { - List results = 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); @@ -142,7 +142,7 @@ public void testGrouplMergeRequestsSearch() throws GitLabApiException { @Test public void testGroupMilestonesSearch() throws GitLabApiException { - List results = 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); @@ -151,14 +151,14 @@ public void testGroupMilestonesSearch() throws GitLabApiException { @Test public void testGrouplUsersSearch() throws GitLabApiException { - List results = 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 = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.ISSUES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -168,7 +168,7 @@ public void testProjectIssuesSearch() throws GitLabApiException { @Test public void testProjectlMergeRequestsSearch() throws GitLabApiException { - List results = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.MERGE_REQUESTS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -178,7 +178,7 @@ public void testProjectlMergeRequestsSearch() throws GitLabApiException { @Test public void testProjectMilestonesSearch() throws GitLabApiException { - List results = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.MILESTONES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -188,7 +188,7 @@ public void testProjectMilestonesSearch() throws GitLabApiException { @Test public void testProjectNotesSearch() throws GitLabApiException { - List results = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.NOTES, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -198,7 +198,7 @@ public void testProjectNotesSearch() throws GitLabApiException { @Test public void testProjectWikiBlobsSearch() throws GitLabApiException { - List results = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.WIKI_BLOBS, TEST_PROJECT_NAME); assertNotNull(results); if (results.size() > 0) { @@ -208,7 +208,7 @@ public void testProjectWikiBlobsSearch() throws GitLabApiException { @Test public void testProjectlUsersSearch() throws GitLabApiException { - List results = gitLabApi.getSearchApi().projectSearch( + List results = gitLabApi.getSearchApi().projectSearch( testProject, ProjectSearchScope.USERS, TEST_LOGIN_USERNAME); assertNotNull(results); assertTrue(results.get(0).getClass() == User.class);