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
284b11e4
Commit
284b11e4
authored
Nov 30, 2017
by
Greg Messner
Browse files
Fixed Label entity and added unit test for same.
parent
cdf53b78
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/LabelsApi.java
View file @
284b11e4
...
...
@@ -8,19 +8,13 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.models.Label
;
public
class
LabelsApi
extends
AbstractApi
{
public
LabelsApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
}
public
List
<
Label
>
getLabels
(
Integer
projectId
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
Response
response
=
get
(
javax
.
ws
.
rs
.
core
.
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"labels"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Label
>>()
{
}));
return
(
getLabels
(
projectId
,
1
,
getDefaultPerPage
()));
}
public
List
<
Label
>
getLabels
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
...
...
@@ -30,8 +24,7 @@ public class LabelsApi extends AbstractApi {
}
Response
response
=
get
(
javax
.
ws
.
rs
.
core
.
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"labels"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Label
>>()
{
}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Label
>>()
{}));
}
public
Label
createLabel
(
Integer
projectId
,
String
name
,
String
color
,
String
description
)
throws
GitLabApiException
{
...
...
src/main/java/org/gitlab4j/api/models/Label.java
View file @
284b11e4
...
...
@@ -7,22 +7,15 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Label
{
private
Integer
id
;
private
Integer
id
;
private
String
name
;
private
String
color
;
private
String
description
;
private
Integer
openIssuesCount
;
private
Integer
closedIssuesCount
;
private
Integer
openMergeRequestCount
;
private
Integer
openMergeRequestsCount
;
private
boolean
subscribed
;
private
Integer
priority
;
public
Integer
getId
()
{
...
...
@@ -73,12 +66,12 @@ public class Label {
this
.
closedIssuesCount
=
closedIssuesCount
;
}
public
Integer
getOpenMergeRequestCount
()
{
return
openMergeRequestCount
;
public
Integer
getOpenMergeRequest
s
Count
()
{
return
openMergeRequest
s
Count
;
}
public
void
setOpenMergeRequestCount
(
Integer
openMergeRequestCount
)
{
this
.
openMergeRequestCount
=
openMergeRequestCount
;
public
void
setOpenMergeRequest
s
Count
(
Integer
openMergeRequest
s
Count
)
{
this
.
openMergeRequest
s
Count
=
openMergeRequest
s
Count
;
}
public
boolean
isSubscribed
()
{
...
...
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
284b11e4
...
...
@@ -43,6 +43,7 @@ import org.gitlab4j.api.models.ImpersonationToken;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.Job
;
import
org.gitlab4j.api.models.Key
;
import
org.gitlab4j.api.models.Label
;
import
org.gitlab4j.api.models.Member
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.models.Milestone
;
...
...
@@ -417,6 +418,21 @@ public class TestGitLabApiBeans {
}
}
@Test
public
void
testLabels
()
{
try
{
InputStreamReader
reader
=
new
InputStreamReader
(
GitLabApi
.
class
.
getResourceAsStream
(
"labels.json"
));
ObjectMapper
objectMapper
=
jacksonJson
.
getContext
(
null
);
List
<
Label
>
labels
=
objectMapper
.
readValue
(
reader
,
new
TypeReference
<
List
<
Label
>>()
{});
assertTrue
(
compareJson
(
labels
,
"labels"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
<
T
>
T
makeFakeApiCall
(
Class
<
T
>
returnType
,
String
file
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
InputStreamReader
reader
=
new
InputStreamReader
(
GitLabApi
.
class
.
getResourceAsStream
(
file
+
".json"
));
...
...
src/test/resources/org/gitlab4j/api/labels.json
0 → 100644
View file @
284b11e4
[
{
"id"
:
1
,
"name"
:
"bug"
,
"color"
:
"#d9534f"
,
"description"
:
"Bug reported by user"
,
"open_issues_count"
:
1
,
"closed_issues_count"
:
0
,
"open_merge_requests_count"
:
1
,
"subscribed"
:
false
,
"priority"
:
10
},
{
"id"
:
4
,
"color"
:
"#d9534f"
,
"name"
:
"confirmed"
,
"description"
:
"Confirmed issue"
,
"open_issues_count"
:
2
,
"closed_issues_count"
:
5
,
"open_merge_requests_count"
:
0
,
"subscribed"
:
false
},
{
"id"
:
7
,
"name"
:
"critical"
,
"color"
:
"#d9534f"
,
"description"
:
"Critical issue. Need fix ASAP"
,
"open_issues_count"
:
1
,
"closed_issues_count"
:
3
,
"open_merge_requests_count"
:
1
,
"subscribed"
:
false
},
{
"id"
:
8
,
"name"
:
"documentation"
,
"color"
:
"#f0ad4e"
,
"description"
:
"Issue about documentation"
,
"open_issues_count"
:
1
,
"closed_issues_count"
:
0
,
"open_merge_requests_count"
:
2
,
"subscribed"
:
false
},
{
"id"
:
9
,
"color"
:
"#5cb85c"
,
"name"
:
"enhancement"
,
"description"
:
"Enhancement proposal"
,
"open_issues_count"
:
1
,
"closed_issues_count"
:
0
,
"open_merge_requests_count"
:
1
,
"subscribed"
:
true
}
]
\ 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