use of org.springframework.integration.core.PollableChannel in project musiccabinet by hakko.
the class ScrobbleServiceTest method skipsIdenticalScrobble.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void skipsIdenticalScrobble() throws InterruptedException, ApplicationException {
// a second scrobble of the same track is just silently thrown away.
// verify by checking that it's the original scrobble (check startTime)
// that remains in the queue when a dupe is scrobbled.
Scrobble scrobble1 = new Scrobble(user1, track1, false);
Thread.sleep(3);
Scrobble scrobble2 = new Scrobble(user1, track1, false);
Message message1 = new GenericMessage<Scrobble>(scrobble1);
Message message2 = new GenericMessage<Scrobble>(scrobble2);
PollableChannel scrobbleChannel = mock(PollableChannel.class);
when(scrobbleChannel.receive()).thenReturn(message1, message2, null);
scrobbleService.setScrobbleChannel(scrobbleChannel);
scrobbleService.receive();
assertNotNull(scrobbleService.userScrobbles);
assertEquals(1, scrobbleService.userScrobbles.keySet().size());
assertEquals(1, scrobbleService.userScrobbles.get(scrobble1.getLastFmUser()).size());
assertEquals(scrobble1.getStartTime(), scrobbleService.userScrobbles.get(scrobble1.getLastFmUser()).getFirst().getStartTime());
}
use of org.springframework.integration.core.PollableChannel in project musiccabinet by hakko.
the class LibraryAdditionServiceTest method addsNestedDirectoriesAndFiles.
@Test
public void addsNestedDirectoriesAndFiles() {
additionService.clearImport();
PollableChannel additionChannel = additionService.libraryAdditionChannel;
additionChannel.send(msg(dir2, new HashSet<String>(), set(file2a)));
additionChannel.send(msg(dir1, set(dir2), set(file1a, file1b)));
additionChannel.send(msg(null, set(dir1), new HashSet<File>()));
additionChannel.send(FINISHED_MESSAGE);
additionService.receive();
additionService.updateLibrary();
assertEquals(set(file1a, file1b), presenceDao.getFiles(dir1));
assertEquals(set(file2a), presenceDao.getFiles(dir2));
}
Aggregations