use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class ArtistTopTagsServiceTest method artistTopTagsUpdateUpdatesAllArtists.
@Test
public void artistTopTagsUpdateUpdatesAllArtists() throws ApplicationException, IOException {
clearLibraryAndAddCherTrack();
WebserviceInvocation wi = new WebserviceInvocation(ARTIST_GET_TOP_TAGS, new Artist(artistName));
Assert.assertTrue(webserviceHistoryService.isWebserviceInvocationAllowed(wi));
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TAGS);
Assert.assertNotNull(artistNames);
Assert.assertEquals(1, artistNames.size());
Assert.assertTrue(artistNames.contains(artistName));
ArtistTopTagsService artistTopTagsService = new ArtistTopTagsService();
artistTopTagsService.setArtistTopTagsClient(getArtistTopTagsClient(webserviceHistoryService));
artistTopTagsService.setArtistTopTagsDao(artistTopTagsDao);
artistTopTagsService.setWebserviceHistoryService(webserviceHistoryService);
artistTopTagsService.updateSearchIndex();
Assert.assertFalse(webserviceHistoryService.isWebserviceInvocationAllowed(wi));
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class JdbcUserLovedTracksDaoTest method loadFunctionDependency.
@Before
public void loadFunctionDependency() throws ApplicationException {
PostgreSQLUtil.loadFunction(dao, UPDATE_USER_LOVED_TRACKS);
PostgreSQLUtil.truncateTables(dao);
lastFmDao.createOrUpdateLastFmUser(user1);
lastFmDao.createOrUpdateLastFmUser(user2);
File file1 = getFile(artistName1, albumName1, trackName1), file2 = getFile(artistName2, albumName2, trackName2);
submitFile(additionDao, Arrays.asList(file1, file2));
List<Artist> artists = browserDao.getArtists();
assertEquals(2, artists.size());
album1 = browserDao.getAlbums(artists.get(0).getId(), true).get(0);
album2 = browserDao.getAlbums(artists.get(1).getId(), true).get(0);
track1 = browserDao.getTracks(album1.getTrackIds()).get(0);
track2 = browserDao.getTracks(album2.getTrackIds()).get(0);
deleteLovedAndStarredTracks();
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class JdbcUserRecommendedArtistsDaoTest method createArtistMetaData.
private void createArtistMetaData() {
Set<Artist> artists = new HashSet<>();
for (UserRecommendedArtists ura : Arrays.asList(joanRec, rjRec, ftpareaRec)) {
for (RecommendedArtist rec : ura.getArtists()) {
artists.add(rec.getArtist());
}
}
List<File> files = new ArrayList<>();
for (Artist artist : artists) {
files.add(getFile(artist.getName(), null, null));
}
List<ArtistInfo> artistInfos = new ArrayList<>();
for (Artist artist : artists) {
artistInfos.add(new ArtistInfo(artist, "/url/to/" + artist.getName()));
}
additionDao.getJdbcTemplate().execute("truncate library.directory cascade");
UnittestLibraryUtil.submitFile(additionDao, files);
artistInfoDao.createArtistInfo(artistInfos);
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method identifiesArtistsWithoutInvocations.
@Test
public void identifiesArtistsWithoutInvocations() {
deleteLibraryTracks();
deleteWebserviceInvocations();
File file = UnittestLibraryUtil.getFile("Madonna", null, "Jump");
UnittestLibraryUtil.submitFile(additionDao, file);
final Calltype INFO = ARTIST_GET_INFO, TOP_TRACKS = ARTIST_GET_TOP_TRACKS;
final String MADONNA = file.getMetadata().getArtist();
List<String> artistInfo, artistTopTracks;
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertNotNull(artistInfo);
Assert.assertNotNull(artistTopTracks);
Assert.assertTrue(artistInfo.contains(MADONNA));
Assert.assertTrue(artistTopTracks.contains(MADONNA));
dao.logWebserviceInvocation(new WebserviceInvocation(INFO, new Artist(MADONNA)));
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertFalse(artistInfo.contains(MADONNA));
Assert.assertTrue(artistTopTracks.contains(MADONNA));
dao.logWebserviceInvocation(new WebserviceInvocation(TOP_TRACKS, new Artist(MADONNA)));
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertFalse(artistInfo.contains(MADONNA));
Assert.assertFalse(artistTopTracks.contains(MADONNA));
}
use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.
the class LibraryBrowserServiceTest method findsAlbums.
@Test
public void findsAlbums() throws Exception {
Artist theBeatles = new Artist("The Beatles");
int beatlesId = musicDao.getArtistId(theBeatles);
scannerService.add(set(media1));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles, "1962-1966", UNKNOWN_ALBUM);
// shouldn't change anything
scannerService.add(set(media1));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles, "1962-1966", UNKNOWN_ALBUM);
scannerService.add(set(media2));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles, "1962-1966", "1967-1970", UNKNOWN_ALBUM);
scannerService.delete(set(media1));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles, "1967-1970");
// shouldn't change anything
scannerService.delete(set(media1));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles, "1967-1970");
scannerService.delete(set(media2));
assertAlbums(browserService.getAlbums(beatlesId, true), theBeatles);
}
Aggregations