Search in sources :

Example 1 with FileMeta

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");
}
Also used : Stream(java.util.stream.Stream) FileMeta(org.molgenis.data.file.model.FileMeta) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 2 with FileMeta

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");
}
Also used : Stream(java.util.stream.Stream) FileMeta(org.molgenis.data.file.model.FileMeta) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 3 with FileMeta

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");
}
Also used : FileMeta(org.molgenis.data.file.model.FileMeta) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with FileMeta

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;
}
Also used : FileMeta(org.molgenis.data.file.model.FileMeta)

Example 5 with 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");
}
Also used : Query(org.molgenis.data.Query) FileMeta(org.molgenis.data.file.model.FileMeta) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

FileMeta (org.molgenis.data.file.model.FileMeta)32 Test (org.testng.annotations.Test)14 File (java.io.File)12 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)6 Attribute (org.molgenis.data.meta.model.Attribute)5 Entity (org.molgenis.data.Entity)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStream (java.io.InputStream)3 MolgenisDataException (org.molgenis.data.MolgenisDataException)3 EntityType (org.molgenis.data.meta.model.EntityType)3 IOException (java.io.IOException)2 Stream (java.util.stream.Stream)2 ZipFile (net.lingala.zip4j.core.ZipFile)2 ZipException (net.lingala.zip4j.exception.ZipException)2 Repository (org.molgenis.data.Repository)2 EntityImportReport (org.molgenis.data.importer.EntityImportReport)2 ImportService (org.molgenis.data.importer.ImportService)2 FileIngestJobExecution (org.molgenis.file.ingest.meta.FileIngestJobExecution)2 ServletUriComponentsBuilder (org.springframework.web.servlet.support.ServletUriComponentsBuilder)2 UriComponents (org.springframework.web.util.UriComponents)2