use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method testDeleteStream.
@Test
public void testDeleteStream() throws Exception {
FileMeta fileMeta0 = getMockFileMeta("id0");
FileMeta fileMeta1 = getMockFileMeta("id1");
fileMetaRepositoryDecorator.delete(Stream.of(fileMeta0, fileMeta1));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<FileMeta>> captor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).delete(captor.capture());
assertEquals(captor.getValue().collect(toList()), asList(fileMeta0, fileMeta1));
verify(fileStore).delete("id0");
verify(fileStore).delete("id1");
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method testDeleteAllStream.
@Test
public void testDeleteAllStream() throws Exception {
FileMeta fileMeta0 = getMockFileMeta("id0");
FileMeta fileMeta1 = getMockFileMeta("id1");
when(delegateRepository.findOneById("id0")).thenReturn(fileMeta0);
when(delegateRepository.findOneById("id1")).thenReturn(fileMeta1);
fileMetaRepositoryDecorator.deleteAll(Stream.of("id0", "id1"));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Object>> captor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).deleteAll(captor.capture());
assertEquals(captor.getValue().collect(toList()), asList("id0", "id1"));
verify(fileStore).delete("id0");
verify(fileStore).delete("id1");
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method testDeleteByIdUnknownId.
@Test(expectedExceptions = UnknownEntityException.class, expectedExceptionsMessageRegExp = "Unknown \\[file metadata] with id \\[id]")
public void testDeleteByIdUnknownId() throws Exception {
FileMeta fileMeta = getMockFileMeta("id");
when(delegateRepository.findOneById("id")).thenReturn(null);
fileMetaRepositoryDecorator.deleteById("id");
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method getMockFileMeta.
private FileMeta getMockFileMeta(String id) {
FileMeta fileMeta = mock(FileMeta.class);
when(fileMeta.getId()).thenReturn(id);
return fileMeta;
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method testDeleteAll.
@SuppressWarnings("unchecked")
@Test
public void testDeleteAll() throws Exception {
FileMeta fileMeta0 = getMockFileMeta("id0");
FileMeta fileMeta1 = getMockFileMeta("id1");
when(delegateRepository.findAll(any(Query.class))).thenReturn(Stream.of(fileMeta0, fileMeta1));
fileMetaRepositoryDecorator.deleteAll();
verify(delegateRepository).deleteAll();
verify(fileStore).delete("id0");
verify(fileStore).delete("id1");
}
Aggregations