### Question:
G3ConvertUtils { public static Picture itemToPicture(Item item) { if(item==null ||item.getEntity()==null){ return null; } Picture picture = new Picture(); picture.setId(item.getEntity().getId()); picture.setTitle(item.getEntity().getTitle()); picture.setFileName(item.getEntity().getName()); picture.setThumbUrl(item.getEntity().getThumbUrl()); picture.setThumbWidth(item.getEntity().getThumbWidth()); picture.setThumbHeight(item.getEntity().getThumbHeight()); picture.setThumbSize(item.getEntity().getThumbSize()); picture.setResizedUrl(item.getEntity().getResizeUrl()); picture.setResizedWidth(item.getEntity().getResizeWidth()); picture.setResizedHeight(item.getEntity().getResizeHeight()); picture.setResizedSize(item.getEntity().getResizeSize()); picture.setFileUrl(item.getEntity().getFileUrl()); picture.setFileSize(item.getEntity().getFileSize()); picture.setHeight(item.getEntity().getHeight()); picture.setWidth(item.getEntity().getWidth()); picture.setPublicUrl(item.getEntity().getWebUrl()); return picture; }  static Album itemToAlbum(Item item); static Picture itemToPicture(Item item);  }### Answer:
@Test public void itemToPicture() throws IOException, JSONException { URL resource = Resources.getResource("get-photo-2.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item pictureItem = ItemUtils.parseJSONToItem(jsonResult); Picture itemToPicture = G3ConvertUtils.itemToPicture(pictureItem ); Picture expectedPicture = new Picture(); expectedPicture.setId(2); expectedPicture.setTitle("March\u00e9 Bon secours"); expectedPicture.setFileName("marche-bonsecours.JPG"); expectedPicture.setThumbUrl("http: expectedPicture.setThumbWidth(150); expectedPicture.setThumbHeight(200); expectedPicture.setThumbSize(17151); expectedPicture.setResizedUrl("http: expectedPicture.setResizedWidth(480); expectedPicture.setResizedHeight(640); expectedPicture.setResizedSize(58309); expectedPicture.setFileUrl("http: expectedPicture.setWidth(2304); expectedPicture.setHeight(3072); expectedPicture.setFileSize(675745); expectedPicture.setPublicUrl("http: assertEquals(expectedPicture, itemToPicture); }
@Test public void itemToPicture__bug3_resize_size_false() throws IOException, JSONException { URL resource = Resources.getResource("get-photo-bug3_resize_size_false.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item pictureItem = ItemUtils.parseJSONToItem(jsonResult); Picture itemToPicture = G3ConvertUtils.itemToPicture(pictureItem ); Picture expectedPicture = new Picture(); expectedPicture.setId(502); expectedPicture.setTitle("graduation pics 427"); expectedPicture.setFileName("graduation pics 427.jpg"); expectedPicture.setResizedUrl("http: expectedPicture.setFileUrl("http: expectedPicture.setWidth(2576); expectedPicture.setHeight(1932); expectedPicture.setFileSize(1144458); expectedPicture.setPublicUrl("http: assertEquals(expectedPicture, itemToPicture); }