Search in sources :

Example 31 with Artist

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

the class JdbcStarDaoTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    PostgreSQLUtil.loadFunction(starDao, ADD_TO_LIBRARY);
    starDao.getJdbcTemplate().execute("truncate music.artist cascade");
    starDao.getJdbcTemplate().execute("truncate library.file cascade");
    submitFile(additionDao, UnittestLibraryUtil.getFile(artistName1, albumName1, trackName1));
    submitFile(additionDao, UnittestLibraryUtil.getFile(artistName2, albumName2, trackName2));
    List<Artist> artists = browserDao.getArtists();
    Assert.assertEquals(2, artists.size());
    album1 = browserDao.getAlbums((artist1 = artists.get(0)).getId(), true).get(0);
    album2 = browserDao.getAlbums((artist2 = artists.get(1)).getId(), true).get(0);
    track1 = browserDao.getTracks(album1.getTrackIds()).get(0);
    track2 = browserDao.getTracks(album2.getTrackIds()).get(0);
    lastFmUser1 = new LastFmUser(user1);
    lastFmDao.createOrUpdateLastFmUser(lastFmUser1);
    lastFmUser2 = new LastFmUser(user2);
    lastFmDao.createOrUpdateLastFmUser(lastFmUser2);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) Before(org.junit.Before)

Example 32 with Artist

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

the class JdbcTagDaoTest method retrievesCorrectedAvailableTags.

@Test
public void retrievesCorrectedAvailableTags() {
    deleteTags();
    for (int i = 0; i < 5; i++) {
        artistTopTagsDao.createTopTags(new Artist("artist" + i), Arrays.asList(new Tag("sludge", (short) 100), new Tag("drone", (short) 90), new Tag("e-l-e-c-t-r-o", (short) 50), new Tag("disco", (short) 10)));
    }
    Map<String, String> tagCorrections = new HashMap<>();
    tagCorrections.put("e-l-e-c-t-r-o", "electro");
    dao.createTagCorrections(tagCorrections);
    dao.setTopTags(Arrays.asList("sludge"));
    List<TagOccurrence> tags = dao.getAvailableTags();
    Assert.assertEquals(3, tags.size());
    Assert.assertEquals("drone", tags.get(0).getTag());
    Assert.assertEquals("e-l-e-c-t-r-o", tags.get(1).getTag());
    Assert.assertEquals("electro", tags.get(1).getCorrectedTag());
    Assert.assertEquals("sludge", tags.get(2).getTag());
    Assert.assertFalse(tags.get(0).isUse());
    Assert.assertFalse(tags.get(1).isUse());
    Assert.assertTrue(tags.get(2).isUse());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) HashMap(java.util.HashMap) TagOccurrence(com.github.hakko.musiccabinet.domain.model.aggr.TagOccurrence) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 33 with Artist

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

the class JdbcWebserviceHistoryDaoTest method clearsLanguageSpecificWebserviceInvocations.

@Test
public void clearsLanguageSpecificWebserviceInvocations() {
    Artist artist = new Artist("ABBA");
    WebserviceInvocation wiInfo = new WebserviceInvocation(ARTIST_GET_INFO, artist);
    WebserviceInvocation wiSimilar = new WebserviceInvocation(ARTIST_GET_SIMILAR, artist);
    dao.logWebserviceInvocation(wiInfo);
    dao.logWebserviceInvocation(wiSimilar);
    Assert.assertFalse(dao.isWebserviceInvocationAllowed(wiInfo));
    Assert.assertFalse(dao.isWebserviceInvocationAllowed(wiSimilar));
    dao.clearLanguageSpecificWebserviceInvocations();
    Assert.assertTrue(dao.isWebserviceInvocationAllowed(wiInfo));
    Assert.assertFalse(dao.isWebserviceInvocationAllowed(wiSimilar));
}
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 34 with Artist

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

the class JdbcWebserviceHistoryDaoTest method importTrackSimilaritiesIsNotPossibleTwice.

@Test
public void importTrackSimilaritiesIsNotPossibleTwice() {
    Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
    Artist artist = new Artist("Bill Fay");
    Track track1 = new Track(artist, "Omega");
    Track track2 = new Track(artist, "Don't let my marigolds die");
    WebserviceInvocation similarTrack1 = new WebserviceInvocation(SIMILAR, track1);
    WebserviceInvocation similarTrack2 = new WebserviceInvocation(SIMILAR, track2);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack1));
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack2));
    dao.logWebserviceInvocation(similarTrack2);
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack1));
    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
}
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) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 35 with Artist

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

the class JdbcPlayCountDaoTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    dao.getJdbcTemplate().execute("truncate music.lastfmuser cascade");
    dao.getJdbcTemplate().execute("truncate library.file cascade");
    dao.getJdbcTemplate().execute("truncate music.artist cascade");
    user1 = new LastFmUser(username1 = "user1");
    user2 = new LastFmUser(username2 = "user2");
    lastFmDao.createOrUpdateLastFmUser(user1);
    lastFmDao.createOrUpdateLastFmUser(user2);
    File file1 = UnittestLibraryUtil.getFile("artist1", "album1", "title1");
    File file2 = UnittestLibraryUtil.getFile("artist1", "album1", "title2");
    File file3 = UnittestLibraryUtil.getFile("artist2", "album2", "title3");
    submitFile(additionDao, Arrays.asList(file1, file2, file3));
    List<Artist> artists = browserDao.getArtists();
    assertEquals(2, artists.size());
    artist1 = artists.get(0);
    artist2 = artists.get(1);
    List<Album> albums1 = browserDao.getAlbums(artist1.getId(), true);
    assertEquals(1, albums1.size());
    album1 = albums1.get(0);
    List<Album> albums2 = browserDao.getAlbums(artist2.getId(), true);
    assertEquals(1, albums2.size());
    album2 = albums2.get(0);
    List<Track> tracks1 = browserDao.getTracks(album1.getTrackIds());
    Collections.sort(tracks1, trackComparator);
    assertEquals(2, tracks1.size());
    track1a = tracks1.get(0);
    track1b = tracks1.get(1);
    List<Track> tracks2 = browserDao.getTracks(album2.getTrackIds());
    assertEquals(1, tracks2.size());
    track2 = tracks2.get(0);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) Album(com.github.hakko.musiccabinet.domain.model.music.Album) File(com.github.hakko.musiccabinet.domain.model.library.File) UnittestLibraryUtil.submitFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Before(org.junit.Before)

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