use of com.github.hakko.musiccabinet.dao.LibraryPresenceDao in project musiccabinet by hakko.
the class LibraryPresenceServiceTest method delegatesHandlingOfAddedAndDeletedResources.
@Test
public void delegatesHandlingOfAddedAndDeletedResources() {
LibraryPresenceDao presenceDao = mock(LibraryPresenceDao.class);
when(presenceDao.getFiles(dir1)).thenReturn(set(file1, file2, file3));
when(presenceDao.getSubdirectories(dir1)).thenReturn(set(dir2));
presenceService.setLibraryPresenceDao(presenceDao);
file2b.setSize(file2.getSize() + 1);
PollableChannel presenceChannel = presenceService.libraryPresenceChannel;
presenceChannel.send(LibraryUtil.msg(dir1, set(dir2), set(file1, file2b)));
presenceChannel.send(FINISHED_MESSAGE);
presenceService.receive();
Message<?> additionMessage, deletionMessage;
assertNotNull(additionMessage = presenceService.libraryMetadataChannel.receive());
assertNotNull(deletionMessage = presenceService.libraryDeletionChannel.receive());
assertEquals(FINISHED_MESSAGE, presenceService.libraryMetadataChannel.receive());
assertEquals(FINISHED_MESSAGE, presenceService.libraryDeletionChannel.receive());
Set<File> addedFiles = ((DirectoryContent) additionMessage.getPayload()).getFiles();
Set<File> deletedFiles = ((DirectoryContent) deletionMessage.getPayload()).getFiles();
assertEquals(set(file2b), addedFiles);
assertEquals(set(file2, file3), deletedFiles);
}
Aggregations