Search in sources :

Example 16 with Artist

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));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 17 with Artist

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();
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) UnittestLibraryUtil.submitFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile) Before(org.junit.Before)

Example 18 with Artist

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);
}
Also used : RecommendedArtist(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist) Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) UserRecommendedArtists(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists) ArrayList(java.util.ArrayList) RecommendedArtist(com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist) UnittestLibraryUtil.getFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile) File(com.github.hakko.musiccabinet.domain.model.library.File) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) HashSet(java.util.HashSet)

Example 19 with Artist

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));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) File(com.github.hakko.musiccabinet.domain.model.library.File) Test(org.junit.Test)

Example 20 with Artist

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);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Test(org.junit.Test)

Aggregations

Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)66 Test (org.junit.Test)33 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)19 ArrayList (java.util.ArrayList)13 Album (com.github.hakko.musiccabinet.domain.model.music.Album)11 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)11 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)10 Track (com.github.hakko.musiccabinet.domain.model.music.Track)9 File (com.github.hakko.musiccabinet.domain.model.library.File)8 NameValuePair (org.apache.http.NameValuePair)8 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)7 Before (org.junit.Before)6 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)5 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)5 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)5 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)5 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)4 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)4 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 ResultSet (java.sql.ResultSet)4