@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void scrobblerIgnoresTooNewSubmissions() throws ApplicationException {
Scrobble scrobble = new Scrobble(user1, track1, false);
Message message = new GenericMessage<Scrobble>(scrobble);
PollableChannel scrobbleChannel = mock(PollableChannel.class);
when(scrobbleChannel.receive()).thenReturn(message, (Message) null);
scrobbleService.setScrobbleChannel(scrobbleChannel);
scrobbleService.receive();
scrobbleService.scrobbleTracks();
assertNotNull(scrobbleService.userScrobbles);
assertEquals(1, scrobbleService.userScrobbles.keySet().size());
assertEquals(1, scrobbleService.userScrobbles.get(scrobble.getLastFmUser()).size());
scrobble.setStartTime(scrobble.getStartTime().minusSeconds(10));
scrobbleService.scrobbleTracks();
assertEquals(1, scrobbleService.userScrobbles.get(scrobble.getLastFmUser()).size());
scrobble.setStartTime(scrobble.getStartTime().minusMinutes(10));
scrobbleService.scrobbleTracks();
assertEquals(0, scrobbleService.userScrobbles.get(scrobble.getLastFmUser()).size());
}