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

Fixed issues exposed by unit tests.

parent da9b94cb
...@@ -3,6 +3,7 @@ package com.messners.gitlab.api; ...@@ -3,6 +3,7 @@ package com.messners.gitlab.api;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.util.Date;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
...@@ -10,15 +11,21 @@ import javax.ws.rs.ext.ContextResolver; ...@@ -10,15 +11,21 @@ import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.Version;
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter; import org.codehaus.jackson.map.ObjectWriter;
import org.codehaus.jackson.map.PropertyNamingStrategy; import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig; import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.codehaus.jackson.map.module.SimpleModule;
/** /**
* Jackson JSON Configuration and utility class. * Jackson JSON Configuration and utility class.
...@@ -40,7 +47,11 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol ...@@ -40,7 +47,11 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, Boolean.TRUE); objectMapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, Boolean.TRUE);
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, Boolean.TRUE); objectMapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, Boolean.TRUE);
SimpleModule module = new SimpleModule("GitLabApiJsonModule", new Version(1, 0, 0, null));
module.addSerializer(Date.class, new JsonDateSerializer());
objectMapper.registerModule(module);
} }
/** /**
...@@ -118,4 +129,15 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol ...@@ -118,4 +129,15 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
return (results); return (results);
} }
public static class JsonDateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(java.util.Date date, JsonGenerator gen, SerializerProvider provider)
throws IOException, JsonProcessingException {
String iso8601String = ISO8601.toString(date);
gen.writeString(iso8601String);
}
}
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ public class AbstractUser { ...@@ -15,6 +15,7 @@ public class AbstractUser {
private String name; private String name;
private String state; private String state;
private String username; private String username;
private Boolean blocked;
public Date getCreatedAt () { public Date getCreatedAt () {
return this.createdAt; return this.createdAt;
...@@ -63,4 +64,12 @@ public class AbstractUser { ...@@ -63,4 +64,12 @@ public class AbstractUser {
public void setUsername (String username) { public void setUsername (String username) {
this.username = username; this.username = username;
} }
public Boolean getBlocked() {
return blocked;
}
public void setBlocked(Boolean blocked) {
this.blocked = blocked;
}
} }
...@@ -6,8 +6,6 @@ import java.util.List; ...@@ -6,8 +6,6 @@ import java.util.List;
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.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
...@@ -22,9 +20,7 @@ public class Commit { ...@@ -22,9 +20,7 @@ public class Commit {
private String id; private String id;
private String message; private String message;
@XmlElement(name = "id", type = String.class) private List<Parent> parents;
@XmlElementWrapper(name = "parents")
private List<String> parentIds;
private String shortId; private String shortId;
private Date timestamp; private Date timestamp;
...@@ -85,12 +81,12 @@ public class Commit { ...@@ -85,12 +81,12 @@ public class Commit {
this.message = message; this.message = message;
} }
public List<String> getParents () { public List<Parent> getParents () {
return this.parentIds; return this.parents;
} }
public void setParents (List<String> parentIds) { public void setParents (List<Parent> parents) {
this.parentIds = parentIds; this.parents = parents;
} }
public void setShort_id (String short_id) { public void setShort_id (String short_id) {
......
...@@ -6,45 +6,51 @@ import javax.xml.bind.annotation.XmlAccessorType; ...@@ -6,45 +6,51 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
@XmlRootElement @XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class Diff { public class Diff {
@JsonSerialize(include=Inclusion.ALWAYS)
@JsonProperty("a_mode") @JsonProperty("a_mode")
private String aMode; private String a_mode;
@JsonSerialize(include=Inclusion.ALWAYS)
@JsonProperty("b_mode") @JsonProperty("b_mode")
private String bMode; private String b_mode;
private boolean deletedFile; private Boolean deletedFile;
private String diff; private String diff;
private boolean newFile; private Boolean newFile;
private String newPath; private String newPath;
private String oldPath; private String oldPath;
private boolean renamedFile; private Boolean renamedFile;
@JsonProperty("a_mode")
public String getAMode () { public String getAMode () {
return this.aMode; return this.a_mode;
} }
public void setAMode (String aMode) { public void setAMode (String aMode) {
this.aMode = aMode; this.a_mode = aMode;
} }
@JsonProperty("b_mode")
public String getBMode () { public String getBMode () {
return this.bMode; return this.b_mode;
} }
public void setBMode (String bMode) { public void setBMode (String bMode) {
this.bMode = bMode; this.b_mode = bMode;
} }
public boolean getDeletedFile () { public Boolean getDeletedFile () {
return this.deletedFile; return this.deletedFile;
} }
public void setDeletedFile (boolean deletedFile) { public void setDeletedFile (Boolean deletedFile) {
this.deletedFile = deletedFile; this.deletedFile = deletedFile;
} }
...@@ -56,11 +62,11 @@ public class Diff { ...@@ -56,11 +62,11 @@ public class Diff {
this.diff = diff; this.diff = diff;
} }
public boolean getNewFile () { public Boolean getNewFile () {
return this.newFile; return this.newFile;
} }
public void setNewFile (boolean newFile) { public void setNewFile (Boolean newFile) {
this.newFile = newFile; this.newFile = newFile;
} }
...@@ -80,11 +86,11 @@ public class Diff { ...@@ -80,11 +86,11 @@ public class Diff {
this.oldPath = oldPath; this.oldPath = oldPath;
} }
public boolean getRenamedFile () { public Boolean getRenamedFile () {
return this.renamedFile; return this.renamedFile;
} }
public void setRenamedFile (boolean renamedFile) { public void setRenamedFile (Boolean renamedFile) {
this.renamedFile = renamedFile; this.renamedFile = renamedFile;
} }
} }
...@@ -10,7 +10,7 @@ public class Tag { ...@@ -10,7 +10,7 @@ public class Tag {
private Commit commit; private Commit commit;
private String name; private String name;
private boolean isProtected; private Boolean isProtected;
public Commit getCommit () { public Commit getCommit () {
return this.commit; return this.commit;
...@@ -28,11 +28,11 @@ public class Tag { ...@@ -28,11 +28,11 @@ public class Tag {
this.name = name; this.name = name;
} }
public boolean getProtected () { public Boolean getProtected () {
return this.isProtected; return this.isProtected;
} }
public void setProtected (boolean isProtected) { public void setProtected (Boolean isProtected) {
this.isProtected = isProtected; this.isProtected = isProtected;
} }
} }
...@@ -2,11 +2,7 @@ ...@@ -2,11 +2,7 @@
"name": "master", "name": "master",
"commit": { "commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"parents": [ "parents": [{ "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" }],
{
"id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
}
],
"tree": "46e82de44b1061621357f24c05515327f2795a95", "tree": "46e82de44b1061621357f24c05515327f2795a95",
"message": "add projects API", "message": "add projects API",
"author": { "author": {
...@@ -17,8 +13,8 @@ ...@@ -17,8 +13,8 @@
"name": "John Smith", "name": "John Smith",
"email": "john@example.com" "email": "john@example.com"
}, },
"authored_date": "2012-06-27T05:51:39-07:00", "authored_date": "2012-06-27T12:51:39Z",
"committed_date": "2012-06-28T03:44:20-07:00" "committed_date": "2012-06-28T10:44:20Z"
}, },
"protected": true "protected": true
} }
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
"title": "Replace sanitize with escape once", "title": "Replace sanitize with escape once",
"author_name": "Dmitriy Zaporozhets", "author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com", "author_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2012-09-20T11:50:22+03:00" "created_at": "2012-09-20T08:50:22Z"
} }
...@@ -11,12 +11,8 @@ ...@@ -11,12 +11,8 @@
"project_id":14, "project_id":14,
"created_at":"2013-12-03T17:15:43Z", "created_at":"2013-12-03T17:15:43Z",
"updated_at":"2013-12-03T17:15:43Z", "updated_at":"2013-12-03T17:15:43Z",
"st_commits":null,
"st_diffs":null,
"position":0, "position":0,
"branch_name":null,
"description":"Create new API for manipulations with repository", "description":"Create new API for manipulations with repository",
"milestone_id":null,
"state":"opened", "state":"opened",
"iid":23, "iid":23,
"merge_status":"unchecked", "merge_status":"unchecked",
......
{ {
"title": null,
"project_id": 15, "project_id": 15,
"action_name": "opened", "action_name": "opened",
"target_id": null,
"target_type": null,
"author_id": 1, "author_id": 1,
"data": { "data": {
"before": "50d4420237a9de7be1304607147aec22e4a14af7", "before": "50d4420237a9de7be1304607147aec22e4a14af7",
...@@ -20,7 +17,7 @@ ...@@ -20,7 +17,7 @@
"commits": [{ "commits": [{
"id": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", "id": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"message": "Add simple search to projects in public area", "message": "Add simple search to projects in public area",
"timestamp": "2013-05-13T18:18:08+00:00", "timestamp": "2013-05-13T18:18:08Z",
"url": "https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", "url": "https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428",
"author": { "author": {
"name": "Dmitriy Zaporozhets", "name": "Dmitriy Zaporozhets",
...@@ -28,7 +25,6 @@ ...@@ -28,7 +25,6 @@
} }
}], }],
"total_commits_count": 1 "total_commits_count": 1
}, }
"target_title": null
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"id": 1, "id": 1,
"title": "v1.0", "title": "v1.0",
"description": "", "description": "",
"due_date": "2012-07-20", "due_date": "2012-07-20T00:00:00Z",
"state": "reopenend", "state": "reopenend",
"updated_at": "2012-07-04T13:42:48Z", "updated_at": "2012-07-04T13:42:48Z",
"created_at": "2012-07-04T13:42:48Z" "created_at": "2012-07-04T13:42:48Z"
......
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
"title":"MS-Viewport", "title":"MS-Viewport",
"created_at":"2013-12-03T17:23:34Z", "created_at":"2013-12-03T17:23:34Z",
"updated_at":"2013-12-03T17:23:34Z", "updated_at":"2013-12-03T17:23:34Z",
"st_commits":null,
"st_diffs":null,
"milestone_id":null,
"state":"opened", "state":"opened",
"merge_status":"unchecked", "merge_status":"unchecked",
"target_project_id":14, "target_project_id":14,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"project_id":16, "project_id":16,
"title":"10.0", "title":"10.0",
"description":"Version", "description":"Version",
"due_date":"2013-11-29", "due_date":"2013-11-29T00:00:00Z",
"state":"active", "state":"active",
"updated_at":"2013-10-02T09:24:18Z", "updated_at":"2013-10-02T09:24:18Z",
"created_at":"2013-10-02T09:24:18Z" "created_at":"2013-10-02T09:24:18Z"
......
{ {
"id":52, "id":52,
"title":"Snippet", "title":"Snippet",
"attachment":null,
"file_name":"snippet.rb", "file_name":"snippet.rb",
"author":{ "author":{
"id":1, "id":1,
...@@ -11,7 +10,6 @@ ...@@ -11,7 +10,6 @@
"state":"active", "state":"active",
"created_at":"2013-09-30T13:46:01Z" "created_at":"2013-09-30T13:46:01Z"
}, },
"expires_at":null,
"updated_at":"2013-10-02T07:34:20Z", "updated_at":"2013-10-02T07:34:20Z",
"created_at":"2013-10-02T07:34:20Z" "created_at":"2013-10-02T07:34:20Z"
} }
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
"state": "active", "state": "active",
"created_at": "2012-05-23T08:00:58Z" "created_at": "2012-05-23T08:00:58Z"
}, },
"expires_at": null,
"updated_at": "2012-06-28T10:52:04Z", "updated_at": "2012-06-28T10:52:04Z",
"created_at": "2012-06-28T10:52:04Z" "created_at": "2012-06-28T10:52:04Z"
} }
......
{ {
"id": 6, "id": 6,
"description": null,
"default_branch": "master", "default_branch": "master",
"public": false, "public": false,
"visibility_level": 0, "visibility_level": 0,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
{ {
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"message": "Update Catalan translation to e38cb41.", "message": "Update Catalan translation to e38cb41.",
"timestamp": "2011-12-12T14:27:31+02:00", "timestamp": "2011-12-12T12:27:31Z",
"url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", "url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": { "author": {
"name": "Jordi Mallach", "name": "Jordi Mallach",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
{ {
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme", "message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00", "timestamp": "2012-01-03T21:36:29Z",
"url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", "url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": { "author": {
"name": "GitLab dev user", "name": "GitLab dev user",
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"private_token": "dd34asd13as", "private_token": "dd34asd13as",
"blocked": false, "blocked": false,
"created_at": "2012-05-23T08:00:58Z", "created_at": "2012-05-23T08:00:58Z",
"bio": null,
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
"name": "Jack Smith", "name": "Jack Smith",
"email": "jack@example.com" "email": "jack@example.com"
}, },
"authored_date": "2012-05-28T04:42:42-07:00", "authored_date": "2012-05-28T11:42:42Z",
"committed_date": "2012-05-28T04:42:42-07:00" "committed_date": "2012-05-28T11:42:42Z"
}, },
"protected": null "protected": false
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"name": "John Smith", "name": "John Smith",
"state": "active", "state": "active",
"created_at": "2012-05-23T08:00:58Z", "created_at": "2012-05-23T08:00:58Z",
"bio": null,
"skype": "", "skype": "",
"linkedin": "", "linkedin": "",
"twitter": "", "twitter": "",
......
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