Commit 55518136 authored by Greg Messner's avatar Greg Messner
Browse files

Mods to fix cast class exception related to jira_issue_transition_id (#253).

parent beab02f7
package org.gitlab4j.api.services; package org.gitlab4j.api.services;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
...@@ -109,4 +111,28 @@ public class JiraService extends NotificationService { ...@@ -109,4 +111,28 @@ public class JiraService extends NotificationService {
setJiraIssueTransitionId(jiraIssueTransitionId); setJiraIssueTransitionId(jiraIssueTransitionId);
return (this); 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));
}
}
}
}
} }
...@@ -105,8 +105,14 @@ public class TestServicesApi { ...@@ -105,8 +105,14 @@ public class TestServicesApi {
@Test @Test
public void testGetJiraService() throws GitLabApiException { public void testGetJiraService() throws GitLabApiException {
JiraService jiraService = gitLabApi.getServicesApi().getJiraService(testProject); JiraService jiraService = gitLabApi.getServicesApi().getJiraService(testProject);
assertNotNull(jiraService); 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 @Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment