use of com.github.hakko.musiccabinet.domain.model.aggr.Scrobble in project musiccabinet by hakko.
the class UpdateNowPlayingService method addScrobble.
private void addScrobble(Scrobble scrobble) {
ConcurrentLinkedDeque<Scrobble> deque = userScrobbles.get(scrobble.getLastFmUser());
Scrobble tail;
while ((tail = deque.peekLast()) != null && tooClose(tail, scrobble)) {
// indicates the occurrence of a previous track that was played for a few
// seconds, and that should be removed
deque.pollLast();
}
deque.add(scrobble);
}
use of com.github.hakko.musiccabinet.domain.model.aggr.Scrobble 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