AttachmentJsonParser implements JsonParser<Attachment> { @Override public Attachment parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final String filename = json.getString("filename"); final BasicUser author = JsonParseUtil.parseBasicUser(json.getJSONObject("author")); final DateTime creationDate = JsonParseUtil.parseDateTime(json.getString("created")); final int size = json.getInt("size"); final String mimeType = json.getString("mimeType"); final URI contentURI = JsonParseUtil.parseURI(json.getString("content")); final URI thumbnailURI = JsonParseUtil.parseOptionalURI(json, THUMBNAIL); return new Attachment(selfUri, filename, author, creationDate, size, mimeType, contentURI, thumbnailURI); }  @Override Attachment parse(JSONObject json);  }
@Test public void testParse() throws Exception { final AttachmentJsonParser parser = new AttachmentJsonParser(); final Attachment attachment = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/attachment/valid.json")); assertEquals(toUri("http: assertEquals(toUri("http: assertEquals(new Attachment(toUri("http: "snipe.png", TestConstants.USER_ADMIN, new DateTime(2010, 7, 26, 13, 31, 35, 577, DateTimeZone.forOffsetHours(2)), 31020, "image/png", toUri("http: toUri("http: }