@Test(expectedExceptions = NullPointerException.class) public void removeSong() { System.out.println("removeSong"); when(albumDao.removeSong(backInBlackAlbum, shootToThrillSong)).thenReturn(backInBlackAlbum); AlbumDTO result = albumFacade.removeSong(backInBlackAlbum.getId(), shootToThrillSong.getId()); assertEquals(mappingService.mapTo(backInBlackAlbum, AlbumDTO.class), result); }
@Test public void testFindAlbumByTitle() { System.out.println("findAlbumByTitle"); when(albumDao.findByTitle(any(String.class))).thenReturn(backInBlackAlbum); AlbumDTO result = albumFacade.findByTitle(backInBlackAlbum.getTitle()); assertEquals(mappingService.mapTo(backInBlackAlbum, AlbumDTO.class), result); }
@BeforeClass public void setUp() { MockitoAnnotations.initMocks(this); acdc = new Musician(); acdc.setRealName("Brian Johnson"); acdc.setArtistName("AC/DC"); acdc.setDateOfBirth(Date.valueOf("1945-10-15")); backInBlackAlbum = new Album(); backInBlackAlbum.setMusician(acdc); backInBlackAlbum.setReleaseDate(Date.valueOf("1980-7-25")); backInBlackAlbum.setTitle("Back In Black"); shootToThrillSong = new Song(); shootToThrillSong.setTitle("Shoot To Thrill"); shootToThrillSong.setAlbum(backInBlackAlbum); shootToThrillSong.setGenre(progressiveRock); shootToThrillSong.setMusician(acdc); shootToThrillSong.setAlbumPosition(2); shootToThrillSong.setBitrate(320); albumDTO = new AlbumDTO(); albumDTO.setTitle(backInBlackAlbum.getTitle()); albumDTO.setReleaseDate(backInBlackAlbum.getReleaseDate()); albumDTO.setMusician(new MusicianDTO()); albumDTO.setCover(backInBlackAlbum.getCover()); progressiveRock = new Genre(); progressiveRock.setTitle("Progressive Rock"); progressiveRock.setYearOfOrigin(1960); }