@Test public void itemToAlbum() throws IOException, JSONException { URL resource = Resources.getResource("get-album-1.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item albumItem = ItemUtils.parseJSONToItem(jsonResult); Album itemToAlbum = G3ConvertUtils.itemToAlbum(albumItem ); Album expectedAlbum = new Album(); expectedAlbum.setId(1); expectedAlbum.setName(1); expectedAlbum.setTitle("Gallery"); expectedAlbum.setSummary(""); expectedAlbum.setAlbumUrl("http: assertEquals(expectedAlbum, itemToAlbum); assertEquals("http: }
public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()); album.setAlbumUrl(item.getEntity().getWebUrl()); album.setAlbumCoverUrl(item.getEntity().getThumbUrl()); return album; }
G3ConvertUtils { public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()); album.setAlbumUrl(item.getEntity().getWebUrl()); album.setAlbumCoverUrl(item.getEntity().getThumbUrl()); return album; } }
G3ConvertUtils { public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()); album.setAlbumUrl(item.getEntity().getWebUrl()); album.setAlbumCoverUrl(item.getEntity().getThumbUrl()); return album; }  }
G3ConvertUtils { public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()); album.setAlbumUrl(item.getEntity().getWebUrl()); album.setAlbumCoverUrl(item.getEntity().getThumbUrl()); return album; }  static Album itemToAlbum(Item item); static Picture itemToPicture(Item item); }
G3ConvertUtils { public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()); album.setAlbumUrl(item.getEntity().getWebUrl()); album.setAlbumCoverUrl(item.getEntity().getThumbUrl()); return album; }  static Album itemToAlbum(Item item); static Picture itemToPicture(Item item);  }