Search in sources :

Example 21 with Artist

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

the class ArtistInfoParserTest method resourceFileCorrectlyParsed.

@Test
public void resourceFileCorrectlyParsed() throws ApplicationException {
    ArtistInfoParser parser = new ArtistInfoParserImpl(new ResourceUtil(ARTIST_INFO_FILE).getInputStream());
    ArtistInfo artistInfo = parser.getArtistInfo();
    assertEquals(new Artist("ABBA"), artistInfo.getArtist());
    assertEquals(SMALL_IMAGE_URL, artistInfo.getSmallImageUrl());
    assertEquals(MEDIUM_IMAGE_URL, artistInfo.getMediumImageUrl());
    assertEquals(LARGE_IMAGE_URL, artistInfo.getLargeImageUrl());
    assertEquals(EXTRA_LARGE_IMAGE_URL, artistInfo.getExtraLargeImageUrl());
    assertEquals(LISTENERS, artistInfo.getListeners());
    assertEquals(PLAY_COUNT, artistInfo.getPlayCount());
    assertEquals(BIO_SUMMARY, artistInfo.getBioSummary());
    assertEquals(BIO_CONTENT, artistInfo.getBioContent());
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 22 with Artist

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

the class JdbcMusicBrainzAlbumDaoTest method prepareTestData.

@Before
public void prepareTestData() throws ApplicationException {
    PostgreSQLUtil.loadFunction(albumDao, UPDATE_MB_ALBUM);
    additionDao.getJdbcTemplate().execute("truncate music.artist cascade");
    additionDao.getJdbcTemplate().execute("truncate library.file cascade");
    artist = new Artist(ARTIST);
    musicDao.setArtistId(artist);
    album1 = new MBRelease(MBID1, null, null, TITLE1, TYPE1, YEAR1, null);
    album2 = new MBRelease(MBID2, null, null, TITLE2, TYPE2, YEAR2, null);
    album1.setArtistId(artist.getId());
    album2.setArtistId(artist.getId());
    albumDao.createAlbums(Arrays.asList(album1, album2));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) MBRelease(com.github.hakko.musiccabinet.domain.model.music.MBRelease) Before(org.junit.Before)

Example 23 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 24 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 25 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)

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