### Question:
JiwigoConvertUtils { public static Album categoriesToAlbum(List<Category> categories){ Album resultAlbum = new Album(); resultAlbum.setName(0); resultAlbum.setId(0); Album album; for (Category category : categories) { album = jiwigoCategoryToAlbum(category); if(category.getParentCategories().size()==0){ resultAlbum.getSubAlbums().add(album); } else{ Album parentAlbum = AlbumUtils.findAlbumFromAlbumName(resultAlbum, category.getParentCategories().get(0).getIdentifier()); parentAlbum.getSubAlbums().add(album); } } return resultAlbum; }  static Album jiwigoCategoryToAlbum(Category jiwigoCategory); static Picture jiwigoImageToPicture(Image jiwigoImage); static Album categoriesToAlbum(List<Category> categories);  }### Answer:
@Test public void categoriesToAlbum() { List<Category> categories = new ArrayList<Category>(); Category coaticook = new Category(); coaticook.setName("coaticook"); coaticook.setIdentifier(1); Category barrage = new Category(); barrage.setName("barrage"); barrage.setIdentifier(2); Category barrage2 = new Category(); barrage2.setName("barrage2"); barrage2.setIdentifier(20); Category sousBarrage = new Category(); sousBarrage.setName("sous barrage"); sousBarrage.setIdentifier(3); coaticook.getChildCategories().add(barrage); coaticook.getChildCategories().add(barrage2); barrage.getChildCategories().add(sousBarrage); sousBarrage.getParentCategories().add(barrage); barrage.getParentCategories().add(coaticook); barrage2.getParentCategories().add(coaticook); categories.add(coaticook); categories.add(barrage); categories.add(barrage2); categories.add(sousBarrage); Album resultAlbum = JiwigoConvertUtils.categoriesToAlbum(categories); Assert.assertEquals(0, resultAlbum.getName()); Assert.assertEquals(1, resultAlbum.getSubAlbums().get(0).getName()); Assert.assertEquals(2, resultAlbum.getSubAlbums().get(0).getSubAlbums().get(0).getName()); Assert.assertEquals(20, resultAlbum.getSubAlbums().get(0).getSubAlbums().get(1).getName()); Assert.assertEquals(3, resultAlbum.getSubAlbums().get(0).getSubAlbums().get(0).getSubAlbums().get(0).getName()); }