Search in sources :

Example 1 with FileStorageService

use of pl.edu.icm.unity.engine.api.files.FileStorageService in project unity by unity-idm.

the class MetadataSourceHandlerTest method init.

@Before
public void init() throws EngineException, IOException, URISyntaxException {
    executorsService = mock(ExecutorsService.class);
    ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
    when(executorsService.getService()).thenReturn(pool);
    src = new RemoteMetadataSrc("http://url", null);
    fileStorageService = mock(FileStorageService.class);
    uriAccessService = mock(URIAccessService.class);
    when(fileStorageService.readFileFromWorkspace(any())).thenThrow(EngineException.class);
    when(uriAccessService.readURI(eq(new URI("http://url")))).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
    when(uriAccessService.readURI(eq(new URI("http://url")), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
    when(fileStorageService.storeFileInWorkspace(any(), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorsService(pl.edu.icm.unity.engine.api.utils.ExecutorsService) FileStorageService(pl.edu.icm.unity.engine.api.files.FileStorageService) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) URI(java.net.URI) FileData(pl.edu.icm.unity.base.file.FileData) Date(java.util.Date) Before(org.junit.Before)

Aggregations

URI (java.net.URI)1 Date (java.util.Date)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Before (org.junit.Before)1 FileData (pl.edu.icm.unity.base.file.FileData)1 FileStorageService (pl.edu.icm.unity.engine.api.files.FileStorageService)1 URIAccessService (pl.edu.icm.unity.engine.api.files.URIAccessService)1 ExecutorsService (pl.edu.icm.unity.engine.api.utils.ExecutorsService)1