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);
}
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());
}
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));
}
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));
}
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);
}
Aggregations