Commit 880b5a31 authored by zhengrenjie's avatar zhengrenjie Committed by Greg Messner
Browse files

Added three getIssues() methods with all optionals in Issues Api. (#246)

parent 78fd3717
......@@ -86,6 +86,29 @@ public interface Constants {
}
}
/** Enum to use for ordering the results of getIssues(). */
public enum IssueOrderBy {
CREATED_AT, UPDATED_AT;
private static JacksonJsonEnumHelper<IssueOrderBy> enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class);
@JsonCreator
public static IssueOrderBy forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
/** Enum to use for ordering the results of getProjects(). */
public enum ProjectOrderBy {
......
......@@ -33,6 +33,7 @@ import javax.ws.rs.core.Response;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Duration;
import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.IssueFilter;
import org.gitlab4j.api.models.TimeStats;
import org.gitlab4j.api.utils.DurationUtils;
......@@ -128,6 +129,107 @@ public class IssuesApi extends AbstractApi implements Constants {
return (new Pager<Issue>(this, Issue.class, itemsPerPage, null, "projects", projectId, "issues"));
}
/**
* Get a list of project's issues. Only returns the first page with default 100 items.
*
* GET /projects/:id/issues
*
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public List<Issue> getIssues(Object projectIdOrPath, IssueFilter filter) throws GitLabApiException {
return (getIssues(projectIdOrPath, filter, 1, getDefaultPerPage()));
}
/**
* Get a list of project's issues.
*
* GET /projects/:id/issues
*
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param page the page to get.
* @param perPage the number of projects per page.
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public List<Issue> getIssues(Object projectIdOrPath, IssueFilter filter, int page, int perPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams(page, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues");
return (response.readEntity(new GenericType<List<Issue>>() {}));
}
/**
* Get a list of project's issues.
*
* GET /projects/:id/issues
*
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param itemsPerPage the number of Project instances that will be fetched per page.
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public Pager<Issue> getIssues(Object projectIdOrPath, IssueFilter filter, int itemsPerPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams();
return (new Pager<Issue>(this, Issue.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues"));
}
/**
* Get all issues the authenticated user has access to.
* By default it returns only issues created by the current user.
* Only returns the first page with default 100 items.
*
* GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public List<Issue> getIssues(IssueFilter filter) throws GitLabApiException {
return (getIssues(filter, 1, getDefaultPerPage()));
}
/**
* Get all issues the authenticated user has access to.
* By default it returns only issues created by the current user.
*
* GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param page the page to get.
* @param perPage the number of projects per page.
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public List<Issue> getIssues(IssueFilter filter, int page, int perPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams(page, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "issues");
return (response.readEntity(new GenericType<List<Issue>>() {}));
}
/**
* Get all issues the authenticated user has access to.
* By default it returns only issues created by the current user.
*
* GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param itemsPerPage the number of Project instances that will be fetched per page.
* @return the list of issues in the specified range.
* @throws GitLabApiException
*/
public Pager<Issue> getIssues(IssueFilter filter, int itemsPerPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams();
return (new Pager<Issue>(this, Issue.class, itemsPerPage, formData.asMap(), "issues"));
}
/**
* Get a single project issue.
*
......
package org.gitlab4j.api.models;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Date;
import java.util.List;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.Constants.IssueOrderBy;
import org.gitlab4j.api.Constants.IssueScope;
import org.gitlab4j.api.Constants.IssueState;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.GitLabApiForm;
import org.gitlab4j.api.utils.ISO8601;
/**
* Created by zhengrenjie on 2018/09/11 12:31
*
* This class is used to filter issues when getting lists of them.
*/
public class IssueFilter {
/**
* Return only the milestone having the given iid.
*/
private List<String> iids;
/**
* {@link org.gitlab4j.api.Constants.IssueState} Return all issues or just those that are opened or closed.
*/
private IssueState state;
/**
* Comma-separated list of label names, issues must have all labels to be returned. No+Label lists all issues with no labels.
*/
private List<String> labels;
/**
* The milestone title. No+Milestone lists all issues with no milestone.
*/
private String milestone;
/**
* {@link org.gitlab4j.api.Constants.IssueScope} Return issues for the given scope: created_by_me, assigned_to_me or all. For versions before 11.0, use the now deprecated created-by-me or assigned-to-me scopes instead.
*/
private IssueScope scope;
/**
* Return issues created by the given user id.
*/
private Integer authorId;
/**
* Return issues assigned to the given user id.
*/
private Integer assigneeId;
/**
* Return issues reacted by the authenticated user by the given emoji.
*/
private String myReactionEmoji;
/**
* {@link org.gitlab4j.api.Constants.IssueOrderBy} Return issues ordered by created_at or updated_at fields. Default is created_at.
*/
private IssueOrderBy orderBy;
/**
* {@link org.gitlab4j.api.Constants.SortOrder} Return issues sorted in asc or desc order. Default is desc.
*/
private SortOrder sort;
/**
* Search project issues against their title and description.
*/
private String search;
/**
* Return issues created on or after the given time.
*/
private Date createdAfter;
/**
* Return issues created on or before the given time.
*/
private Date createdBefore;
/**
* Return issues updated on or after the given time.
*/
private Date updatedAfter;
/**
* Return issues updated on or before the given time.
*/
private Date updatedBefore;
/*- properties -*/
public List<String> getIids() {
return iids;
}
public void setIids(List<String> iids) {
this.iids = iids;
}
public IssueState getState() {
return state;
}
public void setState(IssueState state) {
this.state = state;
}
public List<String> getLabels() {
return labels;
}
public void setLabels(List<String> labels) {
this.labels = labels;
}
public String getMilestone() {
return milestone;
}
public void setMilestone(String milestone) {
this.milestone = milestone;
}
public IssueScope getScope() {
return scope;
}
public void setScope(IssueScope scope) {
this.scope = scope;
}
public Integer getAuthorId() {
return authorId;
}
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
public Integer getAssigneeId() {
return assigneeId;
}
public void setAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
}
public String getMyReactionEmoji() {
return myReactionEmoji;
}
public void setMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
}
public IssueOrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(IssueOrderBy orderBy) {
this.orderBy = orderBy;
}
public SortOrder getSort() {
return sort;
}
public void setSort(SortOrder sort) {
this.sort = sort;
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public Date getCreatedAfter() {
return createdAfter;
}
public void setCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
}
public Date getCreatedBefore() {
return createdBefore;
}
public void setCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
}
public Date getUpdatedAfter() {
return updatedAfter;
}
public void setUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
}
public Date getUpdatedBefore() {
return updatedBefore;
}
public void setUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
}
/*- builder -*/
public IssueFilter withIids(List<String> iids) {
this.iids = iids;
return (this);
}
public IssueFilter withState(IssueState state) {
this.state = state;
return (this);
}
public IssueFilter withLabels(List<String> labels) {
this.labels = labels;
return (this);
}
public IssueFilter withMilestone(String milestone) {
this.milestone = milestone;
return (this);
}
public IssueFilter withScope(IssueScope scope) {
this.scope = scope;
return (this);
}
public IssueFilter withAuthorId(Integer authorId) {
this.authorId = authorId;
return (this);
}
public IssueFilter withAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
return (this);
}
public IssueFilter withMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
return (this);
}
public IssueFilter withOrderBy(IssueOrderBy orderBy) {
this.orderBy = orderBy;
return (this);
}
public IssueFilter withSort(SortOrder sort) {
this.sort = sort;
return (this);
}
public IssueFilter withSearch(String search) {
this.search = search;
return (this);
}
public IssueFilter withCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
return (this);
}
public IssueFilter withCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
return (this);
}
public IssueFilter withUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
return (this);
}
public IssueFilter withUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
return (this);
}
/*- params generator -*/
@JsonIgnore
public GitLabApiForm getQueryParams(int page, int perPage) {
return (getQueryParams()
.withParam(Constants.PAGE_PARAM, page)
.withParam(Constants.PER_PAGE_PARAM, perPage));
}
@JsonIgnore
public GitLabApiForm getQueryParams() {
return (new GitLabApiForm()
.withParam("iids", iids)
.withParam("state", state)
.withParam("labels", (labels != null ? String.join(",", labels) : null))
.withParam("milestone", milestone)
.withParam("scope", scope)
.withParam("author_id", authorId)
.withParam("assignee_id", assigneeId)
.withParam("my_reaction_emoji", myReactionEmoji)
.withParam("order_by", orderBy)
.withParam("sort", sort)
.withParam("search", search)
.withParam("created_after", ISO8601.toString(createdAfter, false))
.withParam("created_before", ISO8601.toString(createdBefore, false))
.withParam("updated_after", ISO8601.toString(updatedAfter, false))
.withParam("updated_before", ISO8601.toString(updatedBefore, false)));
}
}
package org.gitlab4j.api.models;
import java.util.Date;
import java.util.List;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.Constants.MergeRequestOrderBy;
import org.gitlab4j.api.Constants.MergeRequestScope;
import org.gitlab4j.api.Constants.MergeRequestState;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.GitLabApiForm;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* This class is used to filter merge requests when getting lists of them.
*/
public class MergeRequestFilter {
private Integer projectId;
private List<Integer> iids;
private MergeRequestState state;
private MergeRequestOrderBy orderBy;
private SortOrder sort;
private String milestone;
private Boolean simpleView;
private List<String> labels;
private Date createdAfter;
private Date createdBefore;
private Date updatedAfter;
private Date updatedBefore;
private MergeRequestScope scope;
private Integer authorId;
private Integer assigneeId;
private String myReactionEmoji;
private String sourceBranch;
private String targetBranch;
private String search;
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public MergeRequestFilter withProjectId(Integer projectId) {
this.projectId = projectId;
return (this);
}
public List<Integer> getIids() {
return iids;
}
public void setIids(List<Integer> iids) {
this.iids = iids;
}
public MergeRequestFilter withIids(List<Integer> iids) {
this.iids = iids;
return (this);
}
public MergeRequestState getState() {
return state;
}
public void setState(MergeRequestState state) {
this.state = state;
}
public MergeRequestFilter withState(MergeRequestState state) {
this.state = state;
return (this);
}
public MergeRequestOrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(MergeRequestOrderBy orderBy) {
this.orderBy = orderBy;
}
public MergeRequestFilter withOrderBy(MergeRequestOrderBy orderBy) {
this.orderBy = orderBy;
return (this);
}
public SortOrder getSort() {
return sort;
}
public void setSort(SortOrder sort) {
this.sort = sort;
}
public MergeRequestFilter withSort(SortOrder sort) {
this.sort = sort;
return (this);
}
public String getMilestone() {
return milestone;
}
public void setMilestone(String milestone) {
this.milestone = milestone;
}
public MergeRequestFilter withMilestone(String milestone) {
this.milestone = milestone;
return (this);
}
public Boolean getSimpleView() {
return simpleView;
}
public void setSimpleView(Boolean simpleView) {
this.simpleView = simpleView;
}
public MergeRequestFilter withSimpleView(Boolean simpleView) {
this.simpleView = simpleView;
return (this);
}
public List<String> getLabels() {
return labels;
}
public void setLabels(List<String> labels) {
this.labels = labels;
}
public MergeRequestFilter withLabels(List<String> labels) {
this.labels = labels;
return (this);
}
public Date getCreatedAfter() {
return createdAfter;
}
public void setCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
}
public MergeRequestFilter withCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
return (this);
}
public Date getCreatedBefore() {
return createdBefore;
}
public void setCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
}
public MergeRequestFilter withCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
return (this);
}
public Date getUpdatedAfter() {
return updatedAfter;
}
public void setUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
}
public MergeRequestFilter withUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
return (this);
}
public Date getUpdatedBefore() {
return updatedBefore;
}
public void setUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
}
public MergeRequestFilter withUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
return (this);
}
public MergeRequestScope getScope() {
return scope;
}
public void setScope(MergeRequestScope scope) {
this.scope = scope;
}
public MergeRequestFilter withScope(MergeRequestScope scope) {
this.scope = scope;
return (this);
}
public Integer getAuthorId() {
return authorId;
}
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
public MergeRequestFilter withAuthorId(Integer authorId) {
this.authorId = authorId;
return (this);
}
public Integer getAssigneeId() {
return assigneeId;
}
public void setAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
}
public MergeRequestFilter withAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
return (this);
}
public String getMyReactionEmoji() {
return myReactionEmoji;
}
public void setMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
}
public MergeRequestFilter withMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
return (this);
}
public String getSourceBranch() {
return sourceBranch;
}
public void setSourceBranch(String sourceBranch) {
this.sourceBranch = sourceBranch;
}
public MergeRequestFilter withSourceBranch(String sourceBranch) {
this.sourceBranch = sourceBranch;
return (this);
}
public String getTargetBranch() {
return targetBranch;
}
public void setTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
}
public MergeRequestFilter withTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
return (this);
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public MergeRequestFilter withSearch(String search) {
this.search = search;
return (this);
}
@JsonIgnore
public GitLabApiForm getQueryParams(int page, int perPage) {
return (getQueryParams()
.withParam(Constants.PAGE_PARAM, page)
.withParam(Constants.PER_PAGE_PARAM, perPage));
}
@JsonIgnore
public GitLabApiForm getQueryParams() {
return (new GitLabApiForm()
.withParam("iids", iids)
.withParam("state", state)
.withParam("order_by", orderBy)
.withParam("sort", sort)
.withParam("milestone", milestone)
.withParam("view", (simpleView != null && simpleView ? "simple" : null))
.withParam("labels", labels)
.withParam("created_after", createdAfter)
.withParam("created_before", createdBefore)
.withParam("updated_after", updatedAfter)
.withParam("updated_before", updatedBefore)
.withParam("scope", scope)
.withParam("assignee_id", assigneeId)
.withParam("my_reaction_emoji", myReactionEmoji)
.withParam("source_branch", sourceBranch)
.withParam("target_branch", targetBranch)
.withParam("search", search));
}
}
package org.gitlab4j.api.models;
import java.util.Date;
import java.util.List;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.Constants.MergeRequestOrderBy;
import org.gitlab4j.api.Constants.MergeRequestScope;
import org.gitlab4j.api.Constants.MergeRequestState;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.GitLabApiForm;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* This class is used to filter merge requests when getting lists of them.
*/
public class MergeRequestFilter {
private Integer projectId;
private List<Integer> iids;
private MergeRequestState state;
private MergeRequestOrderBy orderBy;
private SortOrder sort;
private String milestone;
private Boolean simpleView;
private List<String> labels;
private Date createdAfter;
private Date createdBefore;
private Date updatedAfter;
private Date updatedBefore;
private MergeRequestScope scope;
private Integer authorId;
private Integer assigneeId;
private String myReactionEmoji;
private String sourceBranch;
private String targetBranch;
private String search;
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public MergeRequestFilter withProjectId(Integer projectId) {
this.projectId = projectId;
return (this);
}
public List<Integer> getIids() {
return iids;
}
public void setIids(List<Integer> iids) {
this.iids = iids;
}
public MergeRequestFilter withIids(List<Integer> iids) {
this.iids = iids;
return (this);
}
public MergeRequestState getState() {
return state;
}
public void setState(MergeRequestState state) {
this.state = state;
}
public MergeRequestFilter withState(MergeRequestState state) {
this.state = state;
return (this);
}
public MergeRequestOrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(MergeRequestOrderBy orderBy) {
this.orderBy = orderBy;
}
public MergeRequestFilter withOrderBy(MergeRequestOrderBy orderBy) {
this.orderBy = orderBy;
return (this);
}
public SortOrder getSort() {
return sort;
}
public void setSort(SortOrder sort) {
this.sort = sort;
}
public MergeRequestFilter withSort(SortOrder sort) {
this.sort = sort;
return (this);
}
public String getMilestone() {
return milestone;
}
public void setMilestone(String milestone) {
this.milestone = milestone;
}
public MergeRequestFilter withMilestone(String milestone) {
this.milestone = milestone;
return (this);
}
public Boolean getSimpleView() {
return simpleView;
}
public void setSimpleView(Boolean simpleView) {
this.simpleView = simpleView;
}
public MergeRequestFilter withSimpleView(Boolean simpleView) {
this.simpleView = simpleView;
return (this);
}
public List<String> getLabels() {
return labels;
}
public void setLabels(List<String> labels) {
this.labels = labels;
}
public MergeRequestFilter withLabels(List<String> labels) {
this.labels = labels;
return (this);
}
public Date getCreatedAfter() {
return createdAfter;
}
public void setCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
}
public MergeRequestFilter withCreatedAfter(Date createdAfter) {
this.createdAfter = createdAfter;
return (this);
}
public Date getCreatedBefore() {
return createdBefore;
}
public void setCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
}
public MergeRequestFilter withCreatedBefore(Date createdBefore) {
this.createdBefore = createdBefore;
return (this);
}
public Date getUpdatedAfter() {
return updatedAfter;
}
public void setUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
}
public MergeRequestFilter withUpdatedAfter(Date updatedAfter) {
this.updatedAfter = updatedAfter;
return (this);
}
public Date getUpdatedBefore() {
return updatedBefore;
}
public void setUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
}
public MergeRequestFilter withUpdatedBefore(Date updatedBefore) {
this.updatedBefore = updatedBefore;
return (this);
}
public MergeRequestScope getScope() {
return scope;
}
public void setScope(MergeRequestScope scope) {
this.scope = scope;
}
public MergeRequestFilter withScope(MergeRequestScope scope) {
this.scope = scope;
return (this);
}
public Integer getAuthorId() {
return authorId;
}
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
public MergeRequestFilter withAuthorId(Integer authorId) {
this.authorId = authorId;
return (this);
}
public Integer getAssigneeId() {
return assigneeId;
}
public void setAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
}
public MergeRequestFilter withAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
return (this);
}
public String getMyReactionEmoji() {
return myReactionEmoji;
}
public void setMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
}
public MergeRequestFilter withMyReactionEmoji(String myReactionEmoji) {
this.myReactionEmoji = myReactionEmoji;
return (this);
}
public String getSourceBranch() {
return sourceBranch;
}
public void setSourceBranch(String sourceBranch) {
this.sourceBranch = sourceBranch;
}
public MergeRequestFilter withSourceBranch(String sourceBranch) {
this.sourceBranch = sourceBranch;
return (this);
}
public String getTargetBranch() {
return targetBranch;
}
public void setTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
}
public MergeRequestFilter withTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
return (this);
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public MergeRequestFilter withSearch(String search) {
this.search = search;
return (this);
}
@JsonIgnore
public GitLabApiForm getQueryParams(int page, int perPage) {
return (getQueryParams()
.withParam(Constants.PAGE_PARAM, page)
.withParam(Constants.PER_PAGE_PARAM, perPage));
}
@JsonIgnore
public GitLabApiForm getQueryParams() {
return (new GitLabApiForm()
.withParam("iids", iids)
.withParam("state", state)
.withParam("order_by", orderBy)
.withParam("sort", sort)
.withParam("milestone", milestone)
.withParam("view", (simpleView != null && simpleView ? "simple" : null))
.withParam("labels", labels)
.withParam("created_after", createdAfter)
.withParam("created_before", createdBefore)
.withParam("updated_after", updatedAfter)
.withParam("updated_before", updatedBefore)
.withParam("scope", scope)
.withParam("assignee_id", assigneeId)
.withParam("my_reaction_emoji", myReactionEmoji)
.withParam("source_branch", sourceBranch)
.withParam("target_branch", targetBranch)
.withParam("search", search));
}
}
......@@ -40,6 +40,7 @@ import org.gitlab4j.api.Constants.IssueState;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Duration;
import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.IssueFilter;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.TimeStats;
import org.junit.AfterClass;
......@@ -325,4 +326,28 @@ public class TestIssuesApi {
assertTimeStats(timeStats, 0, 0);
}
@Test
public void testGetIssuesWithOptions() throws GitLabApiException {
assertNotNull(testProject);
Integer projectId = testProject.getId();
Issue issueOpen = gitLabApi.getIssuesApi().createIssue(projectId, getUniqueTitle(), ISSUE_DESCRIPTION);
Issue issueClose = gitLabApi.getIssuesApi().createIssue(projectId, getUniqueTitle(), ISSUE_DESCRIPTION);
issueClose = gitLabApi.getIssuesApi().closeIssue(projectId, issueClose.getIid());
IssueFilter openFilter = new IssueFilter()
.withState(IssueState.OPENED);
IssueFilter closeFilter = new IssueFilter()
.withState(IssueState.CLOSED);
List<Issue> opens = gitLabApi.getIssuesApi().getIssues(projectId,openFilter);
List<Issue> closes = gitLabApi.getIssuesApi().getIssues(projectId,closeFilter);
assertNotNull(opens);
assertNotNull(closes);
assertEquals(opens.get(0).getIid(), issueOpen.getIid());
assertEquals(closes.get(0).getIid(), issueClose.getIid());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment