ResourceId parentId = new ResourceId(20L, "X");
ResourceId nodeId = new ResourceId(20L, "X");
while ((entry = zin.getNextZipEntry()) != null) {
URI expectedUri = ArchiveFileUtils.toZipUri(file.toURI(), entry.getName());
RequestIdentifier identifer = new RequestIdentifier(expectedUri);
identifer.setAncestorId(10L);
identifer.setParentResourceId(parentId);
if (!entry.isDirectory()) {
when(factory.newRequest(any(RequestMetaData.class), eq(identifer)))
.thenReturn(mockRequests.get(entryCount));
entryCount++;
} else {
expectedDirectories.add(expectedUri);
}
}
AsynchDroid droidCore = mock(AsynchDroid.class);
ZipArchiveHandler handler = new ZipArchiveHandler();
ResultHandler resultHandler = mock(ResultHandler.class);
when(resultHandler.handleDirectory(any(IdentificationResult.class), eq(parentId),
eq(false))).thenReturn(nodeId);
handler.setResultHandler(resultHandler);
handler.setFactory(factory);
handler.setDroidCore(droidCore);
IdentificationRequest originalRequest = mock(IdentificationRequest.class);
RequestIdentifier identifier = new RequestIdentifier(file.toURI());
identifier.setAncestorId(10L);
identifier.setResourceId(nodeId);
identifier.setParentResourceId(parentId);
when(originalRequest.getIdentifier()).thenReturn(identifier);
when(originalRequest.getSourceInputStream()).thenReturn(new FileInputStream(file));
handler.handle(originalRequest);