Skip to content

Commit 0b32741

Browse files
DoubleDProУсачев Дмитрий Дмитриевич
and
Усачев Дмитрий Дмитриевич
authored
Add field iteration into IssueFilter (#913)
Add iterationTitle in IssueFilter for filtration issues by this field Co-authored-by: Усачев Дмитрий Дмитриевич <[email protected]>
1 parent 5a20858 commit 0b32741

File tree

3 files changed

+69
-11
lines changed

3 files changed

+69
-11
lines changed

src/main/java/org/gitlab4j/api/IssuesApi.java

+39-10
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,46 @@ public Issue createIssue(Object projectIdOrPath, String title, String descriptio
422422
public Issue createIssue(Object projectIdOrPath, String title, String description, Boolean confidential, List<Long> assigneeIds, Long milestoneId, String labels,
423423
Date createdAt, Date dueDate, Long mergeRequestToResolveId, Long discussionToResolveId) throws GitLabApiException {
424424

425+
return (createIssue(projectIdOrPath, title, description, confidential, assigneeIds, milestoneId, labels, createdAt, dueDate, mergeRequestToResolveId, discussionToResolveId, null));
426+
}
427+
428+
/**
429+
* Create an issue for the project.
430+
*
431+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues</code></pre>
432+
*
433+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
434+
* @param title the issue title of an issue, required
435+
* @param description the description of an issue, optional
436+
* @param confidential set the issue to be confidential, default is false, optional
437+
* @param assigneeIds the IDs of the users to assign issue, optional
438+
* @param milestoneId the ID of a milestone to assign issue, optional
439+
* @param labels comma-separated label names for an issue, optional
440+
* @param createdAt the date the issue was created at, optional
441+
* @param dueDate the due date, optional
442+
* @param mergeRequestToResolveId the IID of a merge request in which to resolve all issues. This will fill the issue with a default
443+
* description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values. Optional
444+
* @param discussionToResolveId the ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved.
445+
* Use in combination with merge_request_to_resolve_discussions_of. Optional
446+
* @param iterationTitle the iteration title of an issue, optional
447+
* @return an instance of Issue
448+
* @throws GitLabApiException if any exception occurs
449+
*/
450+
public Issue createIssue(Object projectIdOrPath, String title, String description, Boolean confidential, List<Long> assigneeIds, Long milestoneId, String labels,
451+
Date createdAt, Date dueDate, Long mergeRequestToResolveId, Long discussionToResolveId, String iterationTitle) throws GitLabApiException {
452+
425453
GitLabApiForm formData = new GitLabApiForm()
426-
.withParam("title", title, true)
427-
.withParam("description", description)
428-
.withParam("confidential", confidential)
429-
.withParam("assignee_ids", assigneeIds)
430-
.withParam("milestone_id", milestoneId)
431-
.withParam("labels", labels)
432-
.withParam("created_at", createdAt)
433-
.withParam("due_date", dueDate)
434-
.withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId)
435-
.withParam("discussion_to_resolve", discussionToResolveId);
454+
.withParam("title", title, true)
455+
.withParam("description", description)
456+
.withParam("confidential", confidential)
457+
.withParam("assignee_ids", assigneeIds)
458+
.withParam("milestone_id", milestoneId)
459+
.withParam("labels", labels)
460+
.withParam("created_at", createdAt)
461+
.withParam("due_date", dueDate)
462+
.withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId)
463+
.withParam("discussion_to_resolve", discussionToResolveId)
464+
.withParam("iteration_title", iterationTitle);
436465
Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "issues");
437466
return (response.readEntity(Issue.class));
438467
}

src/main/java/org/gitlab4j/api/models/IssueFilter.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public class IssueFilter {
9191
*/
9292
private Date updatedBefore;
9393

94+
/**
95+
* Return issues in current iteration.
96+
*/
97+
private String iterationTitle;
98+
9499

95100
/*- properties -*/
96101
public List<String> getIids() {
@@ -213,6 +218,14 @@ public void setUpdatedBefore(Date updatedBefore) {
213218
this.updatedBefore = updatedBefore;
214219
}
215220

221+
public String getIterationTitle() {
222+
return iterationTitle;
223+
}
224+
225+
public void setIterationTitle(String iterationTitle) {
226+
this.iterationTitle = iterationTitle;
227+
}
228+
216229
/*- builder -*/
217230
public IssueFilter withIids(List<String> iids) {
218231
this.iids = iids;
@@ -289,6 +302,11 @@ public IssueFilter withUpdatedBefore(Date updatedBefore) {
289302
return (this);
290303
}
291304

305+
public IssueFilter withIterationTitle(String iterationTitle) {
306+
this.iterationTitle = iterationTitle;
307+
return (this);
308+
}
309+
292310
/*- params generator -*/
293311
@JsonIgnore
294312
public GitLabApiForm getQueryParams(int page, int perPage) {
@@ -314,6 +332,7 @@ public GitLabApiForm getQueryParams() {
314332
.withParam("created_after", ISO8601.toString(createdAfter, false))
315333
.withParam("created_before", ISO8601.toString(createdBefore, false))
316334
.withParam("updated_after", ISO8601.toString(updatedAfter, false))
317-
.withParam("updated_before", ISO8601.toString(updatedBefore, false)));
335+
.withParam("updated_before", ISO8601.toString(updatedBefore, false)))
336+
.withParam("iteration_title", iterationTitle);
318337
}
319338
}

src/test/java/org/gitlab4j/api/TestIssuesApi.java

+10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class TestIssuesApi extends AbstractIntegrationTest {
7171

7272
private static final String ISSUE_TITLE = "Test Issue Title";
7373
private static final String ISSUE_DESCRIPTION = "This is a really nice description, not.";
74+
private static final String ITERATION_TITLE = "iteration title";
7475
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
7576
private static Random randomNumberGenerator = new Random();
7677

@@ -320,8 +321,10 @@ public void testGetIssuesWithOptions() throws GitLabApiException {
320321

321322
Issue issueOpen = gitLabApi.getIssuesApi().createIssue(projectId, getUniqueTitle(), ISSUE_DESCRIPTION);
322323
Issue issueClose = gitLabApi.getIssuesApi().createIssue(projectId, getUniqueTitle(), ISSUE_DESCRIPTION);
324+
Issue issueInIteration = gitLabApi.getIssuesApi().createIssue(projectId, getUniqueTitle(), ISSUE_DESCRIPTION, null, null, null, null, null, null, null, null, ITERATION_TITLE);
323325
issueClose = gitLabApi.getIssuesApi().closeIssue(projectId, issueClose.getIid());
324326

327+
325328
final Long openIid = issueOpen.getIid();
326329
IssueFilter openFilter = new IssueFilter().withState(IssueState.OPENED);
327330
List<Issue> opens = gitLabApi.getIssuesApi().getIssues(projectId, openFilter);
@@ -333,5 +336,12 @@ public void testGetIssuesWithOptions() throws GitLabApiException {
333336
List<Issue> closes = gitLabApi.getIssuesApi().getIssues(projectId, closeFilter);
334337
assertNotNull(closes);
335338
assertTrue(closes.stream().map(Issue::getIid).anyMatch(iid -> iid.equals(closedIid)));
339+
340+
final Long issueInIterationIid = issueInIteration.getIid();
341+
IssueFilter issueInIterationFilter = new IssueFilter().withIterationTitle(ITERATION_TITLE);
342+
List<Issue> issuesInIteration = gitLabApi.getIssuesApi().getIssues(projectId, issueInIterationFilter);
343+
assertNotNull(issuesInIteration);
344+
assertTrue(issuesInIteration.stream().map(Issue::getIid).anyMatch(iid -> iid.equals(issueInIterationIid)));
345+
336346
}
337347
}

0 commit comments

Comments
 (0)