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

Added support for external issue IDs (#528)

parent 67218105
......@@ -7,6 +7,12 @@ import java.util.List;
import org.gitlab4j.api.Constants.IssueState;
import org.gitlab4j.api.utils.JacksonJson;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.node.IntNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.node.ValueNode;
public class Issue {
public static class TaskCompletionStatus {
......@@ -46,7 +52,14 @@ public class Issue {
private User closedBy;
private String description;
private Date dueDate;
@JsonProperty("id")
private ValueNode actualId;
@JsonIgnore
private String externalId;
@JsonIgnore
private Integer id;
private Integer iid;
private Integer issueLinkId;
private List<String> labels;
......@@ -121,15 +134,44 @@ public class Issue {
}
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
this.dueDate = dueDate;
}
public ValueNode getActualId() {
return actualId;
}
public void setActualId(ValueNode id) {
actualId = id;
if (actualId instanceof TextNode) {
externalId = actualId.asText();
} else if (actualId instanceof IntNode) {
this.id = actualId.asInt();
}
}
public Integer getId() {
return id;
return (id);
}
public void setId(Integer id) {
this.id = id;
this.id = id;
if (id != null) {
actualId = new IntNode(id);
externalId = null;
}
}
public String getExternalId() {
return (externalId);
}
public void setExternalId(String externalId) {
this.externalId = externalId;
if (externalId != null) {
actualId = new TextNode(externalId);
id = null;
}
}
public Integer getIid() {
......
......@@ -296,6 +296,12 @@ public class TestGitLabApiBeans {
assertTrue(compareJson(issueLink, "issue-link.json"));
}
@Test
public void testIssuesClosedBy() throws Exception {
List<Issue> issues = unmarshalResourceList(Issue.class, "issues-closed-by-mr.json");
assertTrue(compareJson(issues, "issues-closed-by-mr.json"));
}
@Test
public void testLabelEvents() throws Exception {
List<LabelEvent> events = unmarshalResourceList(LabelEvent.class, "label-events.json");
......
[
{
"state" : "opened",
"description" : "Ratione dolores corrupti mollitia soluta quia.",
"author" : {
"state" : "active",
"id" : 18,
"web_url" : "https://gitlab.example.com/eileen.lowe",
"name" : "Alexandra Bashirian",
"username" : "eileen.lowe"
},
"milestone" : {
"project_id" : 1,
"description" : "Ducimus nam enim ex consequatur cumque ratione.",
"state" : "closed",
"iid" : 2,
"created_at" : "2016-01-04T15:31:39.996Z",
"title" : "v4.0",
"id" : 17,
"updated_at" : "2016-01-04T15:31:39.996Z"
},
"project_id" : 1,
"assignee" : {
"state" : "active",
"id" : 1,
"name" : "Administrator",
"web_url" : "https://gitlab.example.com/root",
"username" : "root"
},
"updated_at" : "2016-01-04T15:31:51.081Z",
"id" : 76,
"title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.",
"created_at" : "2016-01-04T15:31:51.081Z",
"iid" : 6,
"labels" : [],
"user_notes_count": 1
},
{
"id" : "PROJECT-123",
"title" : "Title of this Jira issue"
}
]
\ No newline at end of file
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