diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/LineRange.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/LineRange.java new file mode 100644 index 000000000..0b4ce2a1b --- /dev/null +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/LineRange.java @@ -0,0 +1,135 @@ +package org.gitlab4j.api.models; + +import java.io.Serializable; + +import org.gitlab4j.models.utils.JacksonJson; +import org.gitlab4j.models.utils.JacksonJsonEnumHelper; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public class LineRange implements Serializable { + private static final long serialVersionUID = 1L; + + public static class Position implements Serializable { + private static final long serialVersionUID = 1L; + + public static enum PositionType { + OLD, + NEW; + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PositionType.class, false, false); + + @JsonCreator + public static PositionType forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + private String lineCode; + private PositionType type; + private Integer oldLine; + private Integer newLine; + + public String getLineCode() { + return lineCode; + } + + public void setLineCode(String lineCode) { + this.lineCode = lineCode; + } + + public Position withLineCode(String lineCode) { + this.lineCode = lineCode; + return this; + } + + public PositionType getType() { + return type; + } + + public void setType(PositionType type) { + this.type = type; + } + + public Position withType(PositionType type) { + this.type = type; + return this; + } + + public Integer getOldLine() { + return oldLine; + } + + public void setOldLine(Integer oldLine) { + this.oldLine = oldLine; + } + + public Position withOldLine(Integer oldLine) { + this.oldLine = oldLine; + return this; + } + + public Integer getNewLine() { + return newLine; + } + + public void setNewLine(Integer newLine) { + this.newLine = newLine; + } + + public Position withNewLine(Integer newLine) { + this.newLine = newLine; + return this; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } + } + + private Position start; + private Position end; + + public Position getStart() { + return start; + } + + public void setStart(Position start) { + this.start = start; + } + + public LineRange withStart(Position start) { + this.start = start; + return this; + } + + public Position getEnd() { + return end; + } + + public void setEnd(Position end) { + this.end = end; + } + + public LineRange withEnd(Position end) { + this.end = end; + return this; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Note.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Note.java index a76ba4ed4..45233538f 100644 --- a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Note.java +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Note.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.List; import org.gitlab4j.models.utils.JacksonJson; import org.gitlab4j.models.utils.JacksonJsonEnumHelper; @@ -96,7 +97,9 @@ public String toString() { // Use String for noteableType until the constant is fixed in the GitLab API private String noteableType; + private Long projectId; private Long noteableIid; + private String commitId; private Boolean system; private String title; private Date updatedAt; @@ -109,6 +112,7 @@ public String toString() { private Type type; private Position position; + private List suggestions; public String getAttachment() { return attachment; @@ -190,6 +194,14 @@ public void setNoteableType(String noteableType) { this.noteableType = noteableType; } + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + public Long getNoteableIid() { return noteableIid; } @@ -198,6 +210,14 @@ public void setNoteableIid(Long noteableIid) { this.noteableIid = noteableIid; } + public String getCommitId() { + return commitId; + } + + public void setCommitId(String commitId) { + this.commitId = commitId; + } + public Boolean getSystem() { return system; } @@ -286,6 +306,14 @@ public void setInternal(Boolean internal) { this.internal = internal; } + public List getSuggestions() { + return suggestions; + } + + public void setSuggestions(List suggestions) { + this.suggestions = suggestions; + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Position.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Position.java index f68446611..b064d672d 100644 --- a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Position.java +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Position.java @@ -48,6 +48,7 @@ public String toString() { private Integer height; private Double x; private Double y; + private LineRange lineRange; public String getBaseSha() { return baseSha; @@ -205,6 +206,19 @@ public Position withY(Double y) { return (this); } + public LineRange getLineRange() { + return lineRange; + } + + public void setLineRange(LineRange lineRange) { + this.lineRange = lineRange; + } + + public Position withLineRange(LineRange lineRange) { + this.lineRange = lineRange; + return (this); + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Suggestion.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Suggestion.java new file mode 100644 index 000000000..84d4460bc --- /dev/null +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/Suggestion.java @@ -0,0 +1,78 @@ +package org.gitlab4j.api.models; + +import java.io.Serializable; + +import org.gitlab4j.models.utils.JacksonJson; + +public class Suggestion implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + private Long fromLine; + private Long toLine; + private Boolean appliable; + private Boolean applied; + private String fromContent; + private String toContent; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getFromLine() { + return fromLine; + } + + public void setFromLine(Long fromLine) { + this.fromLine = fromLine; + } + + public Long getToLine() { + return toLine; + } + + public void setToLine(Long toLine) { + this.toLine = toLine; + } + + public Boolean getAppliable() { + return appliable; + } + + public void setAppliable(Boolean appliable) { + this.appliable = appliable; + } + + public Boolean getApplied() { + return applied; + } + + public void setApplied(Boolean applied) { + this.applied = applied; + } + + public String getFromContent() { + return fromContent; + } + + public void setFromContent(String fromContent) { + this.fromContent = fromContent; + } + + public String getToContent() { + return toContent; + } + + public void setToContent(String toContent) { + this.toContent = toContent; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/gitlab4j-models/src/test/resources/org/gitlab4j/models/merge-request-discussions.json b/gitlab4j-models/src/test/resources/org/gitlab4j/models/merge-request-discussions.json index 17108fe9d..ee35ab421 100644 --- a/gitlab4j-models/src/test/resources/org/gitlab4j/models/merge-request-discussions.json +++ b/gitlab4j-models/src/test/resources/org/gitlab4j/models/merge-request-discussions.json @@ -68,5 +68,67 @@ "resolvable": true } ] + }, + { + "id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6", + "individual_note": false, + "notes": [ + { + "id": 1128, + "type": "DiffNote", + "body": "diff comment", + "author": { + "id": 1, + "name": "root", + "username": "root", + "state": "active", + "avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80&d=identicon", + "web_url": "http://localhost:3000/root" + }, + "created_at": "2018-03-04T09:17:22.520Z", + "updated_at": "2018-03-04T09:17:22.520Z", + "system": false, + "noteable_id": 3, + "noteable_type": "MergeRequest", + "project_id": 5, + "commit_id": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031", + "position": { + "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef", + "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306", + "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031", + "old_path": "package.json", + "new_path": "package.json", + "position_type": "text", + "old_line": 27, + "new_line": 27, + "line_range": { + "start": { + "line_code": "588440f66559714280628a4f9799f0c4eb880a4a_10_10", + "type": "new", + "new_line": 10 + }, + "end": { + "line_code": "588440f66559714280628a4f9799f0c4eb880a4a_11_11", + "type": "old", + "old_line": 11, + "new_line": 11 + } + } + }, + "resolved": false, + "resolvable": true, + "suggestions": [ + { + "id": 1, + "from_line": 27, + "to_line": 27, + "appliable": true, + "applied": false, + "from_content": "x", + "to_content": "b" + } + ] + } + ] } ] \ No newline at end of file