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
c517cbac
Commit
c517cbac
authored
Oct 19, 2019
by
Greg Messner
Browse files
Added more getGroupIssues() methods (#452).
parent
e0f180a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/IssuesApi.java
View file @
c517cbac
...
...
@@ -265,6 +265,60 @@ public class IssuesApi extends AbstractApi implements Constants {
return
(
getIssues
(
filter
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a list of a group’s issues.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @return a List of issues for the specified group
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Issue
>
getGroupIssues
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
return
(
getGroupIssues
(
groupIdOrPath
,
null
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of groups's issues.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @param itemsPerPage the number of Issue instances that will be fetched per page.
* @return the Pager of issues for the specified group
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Issue
>
getGroupIssues
(
Object
groupIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
getGroupIssues
(
groupIdOrPath
,
null
,
itemsPerPage
));
}
/**
* Get a Stream of a group’s issues.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @return a Stream of issues for the specified group and filter
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Issue
>
getGroupIssuesStream
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
return
(
getGroupIssues
(
groupIdOrPath
,
null
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a list of a group’s issues.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @return a List of issues for the specified group and filter
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Issue
>
getGroupIssues
(
Object
groupIdOrPath
,
IssueFilter
filter
)
throws
GitLabApiException
{
return
(
getGroupIssues
(
groupIdOrPath
,
filter
,
getDefaultPerPage
()).
all
());
}
/**
* Get a list of groups's issues.
*
...
...
@@ -272,33 +326,30 @@ public class IssuesApi extends AbstractApi implements Constants {
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @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 Pager of issues
in
the specified
range.
* @param itemsPerPage the number of
Issue
instances that will be fetched per page.
* @return the Pager of issues
for
the specified
group and filter
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Issue
>
getGroupIssues
(
Object
groupIdOrPath
,
IssueFilter
filter
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
filter
.
getQueryParams
();
return
(
new
Pager
<
Issue
>(
this
,
Issue
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"issues"
));
GitLabApiForm
formData
=
(
filter
!=
null
?
filter
.
getQueryParams
()
:
new
GitLabApiForm
());
return
(
new
Pager
<
Issue
>(
this
,
Issue
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"issues"
));
}
/**
* Get a
list of project'
s issues.
* Get a
Stream of a group’
s issues.
*
* <pre><code>GitLab Endpoint: GET /
p
ro
ject
s/:id/issues</code></pre>
* <pre><code>GitLab Endpoint: GET /
g
ro
up
s/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Integer(ID), String(path), or Group instance
* @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.
* @return a Stream of issues for the specified group and filter
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Issue
>
getGroupIssues
(
Object
groupIdOrPath
,
IssueFilter
filter
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
filter
.
getQueryParams
(
page
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"issues"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Issue
>>()
{}));
public
Stream
<
Issue
>
getGroupIssuesStream
(
Object
groupIdOrPath
,
IssueFilter
filter
)
throws
GitLabApiException
{
return
(
getGroupIssues
(
groupIdOrPath
,
filter
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a single project issue.
*
...
...
src/test/java/org/gitlab4j/api/TestIssuesApi.java
View file @
c517cbac
...
...
@@ -32,12 +32,14 @@ import static org.junit.Assume.assumeNotNull;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Random
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.Constants.IssueState
;
import
org.gitlab4j.api.models.Duration
;
import
org.gitlab4j.api.models.Group
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.IssueFilter
;
import
org.gitlab4j.api.models.Project
;
...
...
@@ -63,9 +65,11 @@ public class TestIssuesApi extends AbstractIntegrationTest {
private
static
GitLabApi
gitLabApi
;
private
static
Project
testProject
;
private
static
Group
testGroup
;
private
static
final
String
ISSUE_TITLE
=
"Test Issue Title"
;
private
static
final
String
ISSUE_DESCRIPTION
=
"This is a really nice description, not."
;
private
static
final
String
TEST_GROUP
=
HelperUtils
.
getProperty
(
GROUP_KEY
);
private
static
Random
randomNumberGenerator
=
new
Random
();
public
TestIssuesApi
()
{
...
...
@@ -79,6 +83,11 @@ public class TestIssuesApi extends AbstractIntegrationTest {
gitLabApi
=
baseTestSetup
();
testProject
=
getTestProject
();
if
(
gitLabApi
!=
null
)
{
Optional
<
Group
>
group
=
gitLabApi
.
getGroupApi
().
getOptionalGroup
(
TEST_GROUP
);
testGroup
=
group
.
get
();
}
deleteAllTestIssues
();
}
...
...
@@ -146,6 +155,13 @@ public class TestIssuesApi extends AbstractIntegrationTest {
assertTrue
(
found
);
}
@Test
public
void
testGetGroupIssues
()
throws
GitLabApiException
{
assumeNotNull
(
testGroup
);
List
<
Issue
>
issues
=
gitLabApi
.
getIssuesApi
().
getGroupIssues
(
testGroup
);
assertNotNull
(
issues
);
}
@Test
public
void
testCreateIssue
()
throws
GitLabApiException
{
...
...
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