use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class JdbcMusicBrainzAlbumDaoTest method findsAlbumsMissingFromLibraryWithRecentlyPlayedFilter.
@Test
public void findsAlbumsMissingFromLibraryWithRecentlyPlayedFilter() {
List<MBAlbum> albums = albumDao.getMissingAlbums(null, null, USER, 10, 0);
assertEquals(0, albums.size());
LastFmUser lastFmUser = new LastFmUser(USER);
lastFmDao.createOrUpdateLastFmUser(lastFmUser);
submitFile(additionDao, getFile(artist.getName(), UNKNOWN, UNKNOWN));
Track track = browserDao.getTracks(browserDao.getRandomTrackIds(1)).get(0);
playCountDao.addPlayCount(lastFmUser, track);
albums = albumDao.getMissingAlbums(null, null, USER, 10, 0);
assertEquals(2, albums.size());
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser 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);
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method importUserRelatedDataNotPossibleTwice.
@Test
public void importUserRelatedDataNotPossibleTwice() {
Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
LastFmUser user = new LastFmUser("arnathalon");
WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, user, OVERALL.getDays());
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(topArtists));
dao.logWebserviceInvocation(topArtists);
assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class TrackUnLoveClientTest method validateParameters.
@Test
public void validateParameters() throws ApplicationException {
final String method = TrackUnLoveClient.METHOD;
final String lastFmUser = "arnathalon";
final String sessionKey = "sessionkey";
final String artist = "artist";
final String track = "track";
new TrackUnLoveClient() {
@Override
protected WSResponse executeWSRequest(List<NameValuePair> params) throws ApplicationException {
assertHasParameter(params, PARAM_METHOD, method);
assertHasParameter(params, PARAM_TRACK, track);
assertHasParameter(params, PARAM_ARTIST, artist);
assertHasParameter(params, PARAM_SK, sessionKey);
return null;
}
}.unlove(new Track(artist, track), new LastFmUser(lastFmUser, sessionKey));
}
use of com.github.hakko.musiccabinet.domain.model.library.LastFmUser in project musiccabinet by hakko.
the class UpdateNowPlayingClientTest method validateParameters.
@Test
public void validateParameters() throws ApplicationException {
final Track track = browserDao.getTracks(browserDao.getRandomTrackIds(1)).get(0);
final LastFmUser user = new LastFmUser("lastFmUser", "sessionKey");
final Scrobble scrobble = new Scrobble(user, track, false);
final String method = UpdateNowPlayingClient.METHOD;
new UpdateNowPlayingClient() {
@Override
protected WSResponse executeWSRequest(List<NameValuePair> params) throws ApplicationException {
assertHasParameter(params, PARAM_METHOD, method);
assertHasParameter(params, PARAM_ARTIST, track.getArtist().getName());
assertHasParameter(params, PARAM_ALBUM, track.getMetaData().getAlbum());
assertHasParameter(params, PARAM_TRACK, track.getName());
assertHasParameter(params, PARAM_DURATION, "" + track.getMetaData().getDuration());
assertHasParameter(params, PARAM_SK, user.getSessionKey());
return null;
}
}.updateNowPlaying(scrobble);
}
Aggregations