@Test public void g2PictureToPicture__noresize() throws IOException, JSONException { G2Picture g2Picture = new G2Picture(); g2Picture.setTitle("Title.jpg"); g2Picture.setId(10214); g2Picture.setName("1"); g2Picture.setThumbName("2"); g2Picture.setThumbWidth(320); g2Picture.setThumbHeight(480); g2Picture.setResizedName(null); g2Picture.setResizedWidth(480); g2Picture.setResizedHeight(640); g2Picture.setRawWidth(768); g2Picture.setRawHeight(1024); g2Picture.setRawFilesize(10241024); g2Picture.setCaption("Title"); g2Picture.setForceExtension("true"); g2Picture.setHidden(true); String galleryUrl = "http: Picture picture = G2ConvertUtils.g2PictureToPicture(g2Picture, galleryUrl); Picture expectedPicture = new Picture(); expectedPicture.setId(10214L); expectedPicture.setTitle("Title"); expectedPicture.setFileName("Title.jpg"); expectedPicture.setFileUrl(galleryUrl + "/" + G2ConvertUtils.BASE_URL_DEF + 1); expectedPicture.setWidth(768); expectedPicture.setHeight(1024); expectedPicture.setFileSize(10241024); expectedPicture.setThumbUrl(galleryUrl + "/" + G2ConvertUtils.BASE_URL_DEF + 2); expectedPicture.setThumbWidth(320); expectedPicture.setThumbHeight(480); expectedPicture.setResizedUrl(null); expectedPicture.setResizedWidth(480); expectedPicture.setResizedHeight(640); expectedPicture.setPublicUrl(galleryUrl + "/" + G2ConvertUtils.BASE_URL_DEF + 1); Assert.assertEquals(expectedPicture, picture); }
public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.getTitle()); picture.setThumbUrl( baseUrl + g2Picture.getThumbName()); picture.setThumbWidth(g2Picture.getThumbWidth()); picture.setThumbHeight(g2Picture.getThumbHeight()); if(g2Picture.getResizedName()!=null){ picture.setResizedUrl(baseUrl +g2Picture.getResizedName()); } picture.setResizedWidth(g2Picture.getResizedWidth()); picture.setResizedHeight(g2Picture.getResizedHeight()); picture.setFileUrl(baseUrl +g2Picture.getName()); picture.setPublicUrl(baseUrl +g2Picture.getName()); picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth()); return picture; }
G2ConvertUtils { public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.getTitle()); picture.setThumbUrl( baseUrl + g2Picture.getThumbName()); picture.setThumbWidth(g2Picture.getThumbWidth()); picture.setThumbHeight(g2Picture.getThumbHeight()); if(g2Picture.getResizedName()!=null){ picture.setResizedUrl(baseUrl +g2Picture.getResizedName()); } picture.setResizedWidth(g2Picture.getResizedWidth()); picture.setResizedHeight(g2Picture.getResizedHeight()); picture.setFileUrl(baseUrl +g2Picture.getName()); picture.setPublicUrl(baseUrl +g2Picture.getName()); picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth()); return picture; } }
G2ConvertUtils { public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.getTitle()); picture.setThumbUrl( baseUrl + g2Picture.getThumbName()); picture.setThumbWidth(g2Picture.getThumbWidth()); picture.setThumbHeight(g2Picture.getThumbHeight()); if(g2Picture.getResizedName()!=null){ picture.setResizedUrl(baseUrl +g2Picture.getResizedName()); } picture.setResizedWidth(g2Picture.getResizedWidth()); picture.setResizedHeight(g2Picture.getResizedHeight()); picture.setFileUrl(baseUrl +g2Picture.getName()); picture.setPublicUrl(baseUrl +g2Picture.getName()); picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth()); return picture; }  }
G2ConvertUtils { public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.getTitle()); picture.setThumbUrl( baseUrl + g2Picture.getThumbName()); picture.setThumbWidth(g2Picture.getThumbWidth()); picture.setThumbHeight(g2Picture.getThumbHeight()); if(g2Picture.getResizedName()!=null){ picture.setResizedUrl(baseUrl +g2Picture.getResizedName()); } picture.setResizedWidth(g2Picture.getResizedWidth()); picture.setResizedHeight(g2Picture.getResizedHeight()); picture.setFileUrl(baseUrl +g2Picture.getName()); picture.setPublicUrl(baseUrl +g2Picture.getName()); picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth()); return picture; }  static Album g2AlbumToAlbum(G2Album g2Album); static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl); static String getBaseUrl(String galleryUrl); static boolean isEmbeddedGallery(String url); }
G2ConvertUtils { public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.getTitle()); picture.setThumbUrl( baseUrl + g2Picture.getThumbName()); picture.setThumbWidth(g2Picture.getThumbWidth()); picture.setThumbHeight(g2Picture.getThumbHeight()); if(g2Picture.getResizedName()!=null){ picture.setResizedUrl(baseUrl +g2Picture.getResizedName()); } picture.setResizedWidth(g2Picture.getResizedWidth()); picture.setResizedHeight(g2Picture.getResizedHeight()); picture.setFileUrl(baseUrl +g2Picture.getName()); picture.setPublicUrl(baseUrl +g2Picture.getName()); picture.setFileSize(g2Picture.getRawFilesize()); picture.setHeight(g2Picture.getRawHeight()); picture.setWidth(g2Picture.getRawWidth()); return picture; }  static Album g2AlbumToAlbum(G2Album g2Album); static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl); static String getBaseUrl(String galleryUrl); static boolean isEmbeddedGallery(String url);  }