use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method importTrackSimilaritiesIsPossibleForCovers.
@Test
public void importTrackSimilaritiesIsPossibleForCovers() {
Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
Track track1 = new Track("Daniel Johnston", "True Love Will Find You In The End");
Track track2 = new Track("Headless Heroes", "True Love Will Find You In The End");
WebserviceInvocation similarTrack1 = new WebserviceInvocation(SIMILAR, track1);
WebserviceInvocation similarTrack2 = new WebserviceInvocation(SIMILAR, track2);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(similarTrack1));
assertTrue(dao.isWebserviceInvocationAllowed(similarTrack2));
dao.logWebserviceInvocation(similarTrack1);
assertFalse(dao.isWebserviceInvocationAllowed(similarTrack1));
assertTrue(dao.isWebserviceInvocationAllowed(similarTrack2));
dao.logWebserviceInvocation(similarTrack2);
assertFalse(dao.isWebserviceInvocationAllowed(similarTrack1));
assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
}
use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.
the class TrackPlayCountTest method validateConstructor.
@Test
public void validateConstructor() {
String artistName = "madonna";
String trackName = "material girl";
int playCount = 30;
TrackPlayCount tpc = new TrackPlayCount(artistName, trackName, playCount);
Assert.assertEquals(tpc.getTrack(), new Track(artistName, trackName));
Assert.assertEquals(tpc.getPlayCount(), playCount);
}
use of com.github.hakko.musiccabinet.domain.model.music.Track 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.music.Track 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);
}
use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.
the class JdbcArtistTopTracksDao method batchInsert.
private void batchInsert(Artist artist, List<Track> topTracks) {
int sourceArtistId = jdbcTemplate.queryForInt("select * from music.get_artist_id(?)", artist.getName());
String sql = "insert into music.artisttoptrack_import (artist_id, track_name, rank) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_id", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("rank", Types.SMALLINT));
short rank = 0;
for (Track t : topTracks) {
batchUpdate.update(new Object[] { sourceArtistId, t.getName(), ++rank });
}
batchUpdate.flush();
}
Aggregations