@Test public void findAlbumFromAlbumNameTest() { Album rootAlbum = new Album(); rootAlbum.setName(999); Album album1 = new Album(); album1.setName(1); rootAlbum.getSubAlbums().add(album1); Album album2 = new Album(); album2.setName(2); rootAlbum.getSubAlbums().add(album2); Album album3 = new Album(); album3.setName(3); rootAlbum.getSubAlbums().add(album3); Album album4 = new Album(); album4.setName(4); rootAlbum.getSubAlbums().add(album4); Album album31 = new Album(); album31.setName(31); album3.getSubAlbums().add(album31); Album album311 = new Album(); album311.setName(311); album311.setId(12); album31.getSubAlbums().add(album311); Album album311_fake = new Album(); album311_fake.setName(311); album311_fake.setFakeAlbum(true); album311.getSubAlbums().add(album311_fake); Album albumFound = AlbumUtils.findAlbumFromAlbumName(rootAlbum, 311); assertEquals(album311, albumFound); assertNull(AlbumUtils.findAlbumFromAlbumName(rootAlbum, 312)); }
public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; }
AlbumUtils { public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; } }
AlbumUtils { public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; }  }
AlbumUtils { public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; }  static Album findAlbumFromAlbumName(Album rootAlbum, int albumName); }
AlbumUtils { public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; }  static Album findAlbumFromAlbumName(Album rootAlbum, int albumName);  }