@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://www.iffam.org/gallery/index.php/rest/data/502?size=resize"); expectedPicture.setFileUrl("http://www.iffam.org/gallery/index.php/rest/data/502?size=full"); expectedPicture.setWidth(2576); expectedPicture.setHeight(1932); expectedPicture.setFileSize(1144458); expectedPicture.setPublicUrl("http://www.iffam.org/gallery/index.php/Twitpic/graduation-pics-427"); assertEquals(expectedPicture, itemToPicture); }
expectedPicture.setWidth(2304); expectedPicture.setHeight(3072); expectedPicture.setFileSize(675745);
picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth());
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; }
expectedPicture.setWidth(768); expectedPicture.setHeight(1024); expectedPicture.setFileSize(10241024);
expectedPicture.setWidth(768); expectedPicture.setHeight(1024); expectedPicture.setFileSize(10241024);