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
55518136
Commit
55518136
authored
Sep 18, 2018
by
Greg Messner
Browse files
Mods to fix cast class exception related to jira_issue_transition_id (#253).
parent
beab02f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/services/JiraService.java
View file @
55518136
package
org.gitlab4j.api.services
;
import
java.util.Map
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
...
...
@@ -109,4 +111,28 @@ public class JiraService extends NotificationService {
setJiraIssueTransitionId
(
jiraIssueTransitionId
);
return
(
this
);
}
@Override
public
void
setProperties
(
Map
<
String
,
Object
>
properties
)
{
fixJiraIssueTransitionId
(
properties
);
super
.
setProperties
(
properties
);
}
/**
* Make sure jiraIssueTransitionId is an integer and not an empty string.
* @param properties the Map holding the properties
*/
private
void
fixJiraIssueTransitionId
(
Map
<
String
,
Object
>
properties
)
{
if
(
properties
!=
null
)
{
Object
jiraIssueTransitionId
=
properties
.
get
(
JIRA_ISSUE_TRANSITION_ID_PROP
);
if
(
jiraIssueTransitionId
instanceof
String
)
{
if
(((
String
)
jiraIssueTransitionId
).
trim
().
isEmpty
())
{
properties
.
put
(
JIRA_ISSUE_TRANSITION_ID_PROP
,
null
);
}
else
{
properties
.
put
(
JIRA_ISSUE_TRANSITION_ID_PROP
,
Integer
.
valueOf
((
String
)
jiraIssueTransitionId
));
}
}
}
}
}
src/test/java/org/gitlab4j/api/TestServicesApi.java
View file @
55518136
...
...
@@ -105,8 +105,14 @@ public class TestServicesApi {
@Test
public
void
testGetJiraService
()
throws
GitLabApiException
{
JiraService
jiraService
=
gitLabApi
.
getServicesApi
().
getJiraService
(
testProject
);
assertNotNull
(
jiraService
);
// Make sure the jira_issue_transition_id is retrievable.
// This is testing that a class cast exception is not thrown.
Integer
jiraIssueTransitionId
=
jiraService
.
getJiraIssueTransitionId
();
assertTrue
(
jiraIssueTransitionId
==
null
||
jiraIssueTransitionId
!=
null
);
}
@Test
...
...
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