@Test public void updateReleaseDate() { System.out.println("updateRelease"); when(albumDao.update(backInBlackAlbum)).thenReturn(backInBlackAlbum); when(albumDao.findById(any(Long.class))).thenReturn(backInBlackAlbum); AlbumDTO result = albumFacade.updateAlbumReleaseDate(1l, Date.valueOf("1945-10-15")); assertEquals(mappingService.mapTo(backInBlackAlbum, AlbumDTO.class), result); }
@Test public void testFindAlbumByID() { System.out.println("findAlbumByID"); when(albumDao.findById(any(Long.class))).thenReturn(backInBlackAlbum); AlbumDTO result = albumFacade.findById(1l); assertEquals(mappingService.mapTo(backInBlackAlbum, AlbumDTO.class), result); }
@Test public void updateTitle() { System.out.println("updateTitle"); when(albumDao.update(backInBlackAlbum)).thenReturn(backInBlackAlbum); when(albumDao.findById(any(Long.class))).thenReturn(backInBlackAlbum); AlbumDTO result = albumFacade.updateAlbumTitle(1l, "new"); assertEquals(mappingService.mapTo(backInBlackAlbum, AlbumDTO.class), result); }
@Test public void testCreateAlbum() { System.out.println("createAlbum"); when(albumDao.create(any(Album.class))).thenReturn(true); when(albumDao.findById(any(Long.class))).thenReturn(backInBlackAlbum); Long createdID = albumFacade.createAlbum(albumDTO); assertEquals(null, createdID); }
@Test public void testDeleteAlbum() { System.out.println("deleteAlbum"); when(albumDao.findById(any(Long.class))).thenReturn(backInBlackAlbum); when(albumDao.delete(any(Album.class))).thenReturn(true); boolean expectedResult = albumFacade.deleteAlbum(1l); assertEquals(true, expectedResult); }