@Test public void biographyAndImageUrlAreReturnedAsInfo() throws ApplicationException { deleteArtistInfos(); int abbaId = musicDao.getArtistId(aiAbba.getArtist()); dao.createArtistInfo(Arrays.asList(aiAbba)); ArtistInfo dbAbba = dao.getArtistInfo(abbaId); Assert.assertEquals(ABBA_IMAGE_URL, dbAbba.getLargeImageUrl()); Assert.assertEquals(ABBA_BIO_SUMMARY, dbAbba.getBioSummary()); }
@Test public void bioSummaryCanBeUpdated() { deleteArtistInfos(); int abbaId = musicDao.getArtistId(aiAbba.getArtist()); String biography = "new ABBA biography"; dao.createArtistInfo(Arrays.asList(aiAbba)); dao.setBioSummary(abbaId, biography); ArtistInfo dbAbba = dao.getArtistInfo(abbaId); Assert.assertEquals(biography, dbAbba.getBioSummary()); }
@Test public void createAndValidateArtistInfos() throws ApplicationException { deleteArtistInfos(); List<ArtistInfo> artistInfos = new ArrayList<>(); artistInfos.add(aiAbba); artistInfos.add(aiCher); dao.createArtistInfo(artistInfos); ArtistInfo dbAbba = dao.getArtistInfo(aiAbba.getArtist()); ArtistInfo dbCher = dao.getArtistInfo(aiCher.getArtist()); Assert.assertEquals(aiAbba, dbAbba); Assert.assertEquals(aiCher, dbCher); }
@Before public void loadFunctionDependency() throws ApplicationException { PostgreSQLUtil.loadFunction(dao, UPDATE_ARTISTINFO); aiAbba = new ArtistInfoParserImpl(new ResourceUtil(AI_ABBA_FILE).getInputStream()).getArtistInfo(); aiCher = new ArtistInfoParserImpl(new ResourceUtil(AI_CHER_FILE).getInputStream()).getArtistInfo(); aiTina = new ArtistInfoParserImpl(new ResourceUtil(AI_TINA_FILE).getInputStream()).getArtistInfo(); deleteArtists(); // re-create artists for (ArtistInfo ai : new ArtistInfo[] {aiAbba, aiCher, aiTina}) { musicDao.getArtistId(ai.getArtist()); } }
@Test public void createAndValidateUpdatedArtistInfos() throws ApplicationException { deleteArtistInfos(); String newBio = "Abba was a pop group."; String newContent = "Abba was a pop group. They sold many records."; dao.createArtistInfo(Arrays.asList(aiAbba, aiTina)); aiAbba.setBioSummary(newBio); aiAbba.setBioContent(newContent); dao.createArtistInfo(Arrays.asList(aiAbba, aiCher)); ArtistInfo dbAbba = dao.getArtistInfo(aiAbba.getArtist()); Assert.assertEquals(newBio, dbAbba.getBioSummary()); Assert.assertEquals(newContent, dbAbba.getBioContent()); }