Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
f93aeec4
Unverified
Commit
f93aeec4
authored
May 05, 2023
by
Jérémie Bresson
Committed by
GitHub
May 05, 2023
Browse files
Fix Epic Issue link association (#969)
* Fix Epic Issue link association Fixes #729 * Change return type
parent
7606448a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/EpicsApi.java
View file @
f93aeec4
...
@@ -11,6 +11,7 @@ import javax.ws.rs.core.Response;
...
@@ -11,6 +11,7 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.models.Epic
;
import
org.gitlab4j.api.models.Epic
;
import
org.gitlab4j.api.models.EpicIssue
;
import
org.gitlab4j.api.models.EpicIssue
;
import
org.gitlab4j.api.models.EpicIssueLink
;
/**
/**
* This class implements the client side API for the GitLab Epics and Epic Issues API calls.
* This class implements the client side API for the GitLab Epics and Epic Issues API calls.
...
@@ -347,10 +348,10 @@ public class EpicsApi extends AbstractApi {
...
@@ -347,10 +348,10 @@ public class EpicsApi extends AbstractApi {
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the IID of the epic to get issues for
* @param epicIid the IID of the epic to get issues for
* @return a list of all
epic
issues belonging to the specified epic
* @return a list of all issues belonging to the specified epic
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Epic
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
)
throws
GitLabApiException
{
public
List
<
Epic
Issue
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
)
throws
GitLabApiException
{
return
(
getEpicIssues
(
groupIdOrPath
,
epicIid
,
getDefaultPerPage
()).
all
());
return
(
getEpicIssues
(
groupIdOrPath
,
epicIid
,
getDefaultPerPage
()).
all
());
}
}
...
@@ -364,12 +365,12 @@ public class EpicsApi extends AbstractApi {
...
@@ -364,12 +365,12 @@ public class EpicsApi extends AbstractApi {
* @param epicIid the IID of the epic to get issues for
* @param epicIid the IID of the epic to get issues for
* @param page the page to get
* @param page the page to get
* @param perPage the number of issues per page
* @param perPage the number of issues per page
* @return a list of all
epic
issues belonging to the specified epic in the specified range
* @return a list of all issues belonging to the specified epic in the specified range
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Epic
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Epic
Issue
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Epic
>>()
{
}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Epic
Issue
>>()
{
}));
}
}
/**
/**
...
@@ -380,11 +381,11 @@ public class EpicsApi extends AbstractApi {
...
@@ -380,11 +381,11 @@ public class EpicsApi extends AbstractApi {
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the IID of the epic to get issues for
* @param epicIid the IID of the epic to get issues for
* @param itemsPerPage the number of issues per page
* @param itemsPerPage the number of issues per page
* @return the Pager of all
epic
issues belonging to the specified epic
* @return the Pager of all issues belonging to the specified epic
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Epic
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
Epic
Issue
>
getEpicIssues
(
Object
groupIdOrPath
,
Long
epicIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Epic
>(
this
,
Epic
.
class
,
itemsPerPage
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
));
return
(
new
Pager
<
Epic
Issue
>(
this
,
Epic
Issue
.
class
,
itemsPerPage
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
));
}
}
/**
/**
...
@@ -394,10 +395,10 @@ public class EpicsApi extends AbstractApi {
...
@@ -394,10 +395,10 @@ public class EpicsApi extends AbstractApi {
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the IID of the epic to get issues for
* @param epicIid the IID of the epic to get issues for
* @return a Stream of all
epic
issues belonging to the specified epic
* @return a Stream of all issues belonging to the specified epic
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Stream
<
Epic
>
getEpicIssuesStream
(
Object
groupIdOrPath
,
Long
epicIid
)
throws
GitLabApiException
{
public
Stream
<
Epic
Issue
>
getEpicIssuesStream
(
Object
groupIdOrPath
,
Long
epicIid
)
throws
GitLabApiException
{
return
(
getEpicIssues
(
groupIdOrPath
,
epicIid
,
getDefaultPerPage
()).
stream
());
return
(
getEpicIssues
(
groupIdOrPath
,
epicIid
,
getDefaultPerPage
()).
stream
());
}
}
...
@@ -409,52 +410,52 @@ public class EpicsApi extends AbstractApi {
...
@@ -409,52 +410,52 @@ public class EpicsApi extends AbstractApi {
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the Epic IID to assign the issue to
* @param epicIid the Epic IID to assign the issue to
* @param issueI
i
d the issue
I
ID of the issue to assign to the epic
* @param issueId the issue ID of the issue to assign to the epic
* @return an EpicIssue instance containing info on the newly assigned epic issue
* @return an EpicIssue instance containing info on the newly assigned epic issue
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
EpicIssue
assignIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
issueI
i
d
)
throws
GitLabApiException
{
public
EpicIssue
assignIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
issueId
)
throws
GitLabApiException
{
Response
response
=
post
(
Response
.
Status
.
CREATED
,
(
Form
)
null
,
Response
response
=
post
(
Response
.
Status
.
CREATED
,
(
Form
)
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
issueI
i
d
);
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
issueId
);
return
(
response
.
readEntity
(
EpicIssue
.
class
));
return
(
response
.
readEntity
(
EpicIssue
.
class
));
}
}
/**
/**
* Remove an epic - issue association.
* Remove an epic - issue association.
*
*
* <pre><code>GitLab Endpoint: DELETE /groups/:id/epics/:epic_iid/issues/:issue_id</code></pre>
* <pre><code>GitLab Endpoint: DELETE /groups/:id/epics/:epic_iid/issues/:
epic_
issue_id</code></pre>
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the Epic IID to remove the issue from
* @param epicIid the Epic IID to remove the issue from
* @param
i
ssueI
i
d the
issue IID
of the issue to remove from the epic
* @param
epicI
ssueId the
ID of the "issue - epic" association
of the issue to remove from the epic
* @return an EpicIssue instance containing info on the removed issue
* @return an EpicIssue
Link
instance containing info on the removed issue
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
EpicIssue
removeIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
i
ssueI
i
d
)
throws
GitLabApiException
{
public
EpicIssue
Link
removeIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
epicI
ssueId
)
throws
GitLabApiException
{
Response
response
=
delete
(
Response
.
Status
.
OK
,
null
,
Response
response
=
delete
(
Response
.
Status
.
OK
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
i
ssueI
i
d
);
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
epicI
ssueId
);
return
(
response
.
readEntity
(
EpicIssue
.
class
));
return
(
response
.
readEntity
(
EpicIssue
Link
.
class
));
}
}
/**
/**
* Updates an epic - issue association.
* Updates an epic - issue association.
*
*
* <pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid/issues/:issue_id</code></pre>
* <pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid/issues/:
epic_
issue_id</code></pre>
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the Epic IID that the issue is assigned to
* @param epicIid the Epic IID that the issue is assigned to
* @param
i
ssueI
i
d the
issue IID to update
* @param
epicI
ssueId the
ID of the "issue - epic" association
* @param moveBeforeId the ID of the issue - epic association that should be placed before the link in the question (optional)
* @param moveBeforeId the ID of the
"
issue - epic
"
association that should be placed before the link in the question (optional)
* @param moveAfterId the ID of the issue - epic association that should be placed after the link in the question (optional)
* @param moveAfterId the ID of the
"
issue - epic
"
association that should be placed after the link in the question (optional)
* @return a
n EpicIssue instance containing info on the newly assign
ed epic
issue
* @return a
list of all issues belonging to the specifi
ed epic
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
EpicIssue
updateIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
i
ssueI
i
d
,
Long
moveBeforeId
,
Long
moveAfterId
)
throws
GitLabApiException
{
public
List
<
EpicIssue
>
updateIssue
(
Object
groupIdOrPath
,
Long
epicIid
,
Long
epicI
ssueId
,
Long
moveBeforeId
,
Long
moveAfterId
)
throws
GitLabApiException
{
GitLabApiForm
form
=
new
GitLabApiForm
()
GitLabApiForm
form
=
new
GitLabApiForm
()
.
withParam
(
"move_before_id"
,
moveBeforeId
)
.
withParam
(
"move_before_id"
,
moveBeforeId
)
.
withParam
(
"move_after_id"
,
moveAfterId
);
.
withParam
(
"move_after_id"
,
moveAfterId
);
Response
response
=
p
os
t
(
Response
.
Status
.
OK
,
form
,
Response
response
=
p
u
t
(
Response
.
Status
.
OK
,
form
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
i
ssueI
i
d
);
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"epics"
,
epicIid
,
"issues"
,
epicI
ssueId
);
return
(
response
.
readEntity
(
EpicIssue
.
class
)
);
return
response
.
readEntity
(
new
GenericType
<
List
<
EpicIssue
>>()
{}
);
}
}
}
}
src/main/java/org/gitlab4j/api/models/EpicIssueLink.java
0 → 100644
View file @
f93aeec4
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
EpicIssueLink
{
private
Long
id
;
private
Integer
relativePosition
;
private
Epic
epic
;
private
Issue
issue
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
epicIssueId
)
{
this
.
id
=
epicIssueId
;
}
public
Integer
getRelativePosition
()
{
return
relativePosition
;
}
public
void
setRelativePosition
(
Integer
relativePosition
)
{
this
.
relativePosition
=
relativePosition
;
}
public
Epic
getEpic
()
{
return
epic
;
}
public
void
setEpic
(
Epic
epic
)
{
this
.
epic
=
epic
;
}
public
Issue
getIssue
()
{
return
issue
;
}
public
void
setIssue
(
Issue
issue
)
{
this
.
issue
=
issue
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
f93aeec4
...
@@ -60,6 +60,7 @@ import org.gitlab4j.api.models.Email;
...
@@ -60,6 +60,7 @@ import org.gitlab4j.api.models.Email;
import
org.gitlab4j.api.models.Environment
;
import
org.gitlab4j.api.models.Environment
;
import
org.gitlab4j.api.models.Epic
;
import
org.gitlab4j.api.models.Epic
;
import
org.gitlab4j.api.models.EpicIssue
;
import
org.gitlab4j.api.models.EpicIssue
;
import
org.gitlab4j.api.models.EpicIssueLink
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.ExportStatus
;
import
org.gitlab4j.api.models.ExportStatus
;
import
org.gitlab4j.api.models.ExternalStatusCheck
;
import
org.gitlab4j.api.models.ExternalStatusCheck
;
...
@@ -254,6 +255,12 @@ public class TestGitLabApiBeans {
...
@@ -254,6 +255,12 @@ public class TestGitLabApiBeans {
assertTrue
(
compareJson
(
epicIssue
,
"epic-issue.json"
));
assertTrue
(
compareJson
(
epicIssue
,
"epic-issue.json"
));
}
}
@Test
public
void
testEpicIssueLink
()
throws
Exception
{
EpicIssueLink
epicIssueLink
=
unmarshalResource
(
EpicIssueLink
.
class
,
"epic-issue-link.json"
);
assertTrue
(
compareJson
(
epicIssueLink
,
"epic-issue-link.json"
));
}
@Test
@Test
public
void
testEvent
()
throws
Exception
{
public
void
testEvent
()
throws
Exception
{
Event
event
=
unmarshalResource
(
Event
.
class
,
"event.json"
);
Event
event
=
unmarshalResource
(
Event
.
class
,
"event.json"
);
...
...
src/test/resources/org/gitlab4j/api/epic-issue-link.json
0 → 100644
View file @
f93aeec4
{
"id"
:
237
,
"relative_position"
:
-1026
,
"epic"
:
{
"id"
:
25
,
"iid"
:
1
,
"color"
:
"#1068bf"
,
"group_id"
:
139
,
"title"
:
"Test group Epic"
,
"description"
:
""
,
"author"
:
{
"id"
:
1
,
"username"
:
"pipin"
,
"name"
:
"Pip"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/pipin"
},
"state"
:
"opened"
,
"web_url"
:
"https://gitlab.example.com/groups/my/test-group/-/epics/1"
,
"references"
:
{
"short"
:
"&1"
,
"relative"
:
"&1"
,
"full"
:
"my/test-group&1"
},
"reference"
:
"my/test-group&1"
,
"created_at"
:
"2022-08-23T13:50:08.507Z"
,
"updated_at"
:
"2023-04-27T13:36:34.636Z"
,
"labels"
:
[],
"upvotes"
:
0
,
"downvotes"
:
0
,
"_links"
:
{
"self"
:
"https://gitlab.example.com/api/v4/groups/139/epics/1"
,
"epic_issues"
:
"https://gitlab.example.com/api/v4/groups/139/epics/1/issues"
,
"group"
:
"https://gitlab.example.com/api/v4/groups/139"
}
},
"issue"
:
{
"id"
:
1106
,
"iid"
:
9
,
"project_id"
:
58
,
"title"
:
"a title"
,
"description"
:
"a description"
,
"state"
:
"opened"
,
"created_at"
:
"2022-09-12T07:30:09.431Z"
,
"updated_at"
:
"2023-04-27T13:36:34.703Z"
,
"labels"
:
[],
"assignees"
:
[],
"author"
:
{
"id"
:
1
,
"username"
:
"pipin"
,
"name"
:
"Pip"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/pipin"
},
"user_notes_count"
:
0
,
"merge_requests_count"
:
1
,
"upvotes"
:
0
,
"downvotes"
:
0
,
"web_url"
:
"https://gitlab.example.com/my/test-group/a-project/-/issues/9"
,
"time_stats"
:
{
"time_estimate"
:
0
,
"total_time_spent"
:
0
},
"task_completion_status"
:
{
"count"
:
0
,
"completed_count"
:
0
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment