Search in sources :

Example 11 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 12 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)

Example 13 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class LibraryBrowserServiceTest method findsVariousArtistsTracks.

@Test
public void findsVariousArtistsTracks() throws Exception {
    scannerService.add(set(media5));
    Artist artist = new Artist("Various Artists");
    int artistId = musicDao.getArtistId(artist);
    List<Album> albums = browserService.getAlbums(artistId, true);
    assertAlbums(albums, artist, "Music From Searching For Wrong-Eyed Jesus");
    Album album = albums.get(0);
    List<Track> tracks = browserService.getTracks(album.getTrackIds());
    List<Track> expectedTracks = asList(new Track("Harry Crews", "Everything Was Stories"), new Track("Jim White", "Still Waters"), new Track("The Handsome Family", "My Sister's Tiny Hands"));
    assertTracks(tracks, expectedTracks);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 14 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class LibraryBrowserServiceTest method findsTracks.

@Test
public void findsTracks() throws Exception {
    scannerService.add(set(media1));
    Artist artist = new Artist("The Beatles");
    int artistId = musicDao.getArtistId(artist);
    List<Album> albums = browserService.getAlbums(artistId, true);
    Album redAlbum = getAlbum(albums, "1962-1966");
    List<Track> tracks = browserService.getTracks(redAlbum.getTrackIds());
    List<Track> expectedTracks = new ArrayList<>();
    for (String title : asList("Love Me Do", "Please Please Me", "From Me To You", "She Loves You", "Help!")) {
        expectedTracks.add(new Track("The Beatles", title));
    }
    assertTracks(tracks, expectedTracks);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArrayList(java.util.ArrayList) Album(com.github.hakko.musiccabinet.domain.model.music.Album) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 15 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class LibraryBrowserServiceTest method addsCoverArtPathForTrack.

@Test
public void addsCoverArtPathForTrack() throws Exception {
    Artist artist = new Artist("Artist Name");
    int artistId = musicDao.getArtistId(artist);
    scannerService.add(set(media3));
    List<Album> albums = browserService.getAlbums(artistId, false, true);
    int trackId = albums.get(0).getTrackIds().get(0);
    List<Track> tracks = browserService.getTracks(asList(trackId));
    Assert.assertNotNull(tracks);
    Assert.assertEquals(1, tracks.size());
    Assert.assertNull(tracks.get(0).getMetaData().getArtworkPath());
    browserService.addArtwork(tracks);
    String artworkPath = tracks.get(0).getMetaData().getArtworkPath();
    Assert.assertNotNull(artworkPath);
    Assert.assertTrue(artworkPath.endsWith("Embedded artwork" + separatorChar + "Embedded artwork.mp3"));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album) Track(com.github.hakko.musiccabinet.domain.model.music.Track) 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