DirectoryEventHandler { public ResourceId onEvent(final Path dir, ResourceId parentId, int depth, boolean restricted) { IdentificationResultImpl result = new IdentificationResultImpl(); result.setMethod(IdentificationMethod.NULL); final FileTime lastModified = FileUtil.lastModifiedQuietly(dir); RequestMetaData metaData = new RequestMetaData( -1L, lastModified == null ? new Date(0).getTime() : new Date(lastModified.toMillis()).getTime(), depth == 0 ? dir.toAbsolutePath().toString() : FileUtil.fileName(dir)); RequestIdentifier identifier = new RequestIdentifier(dir.toUri()); identifier.setParentResourceId(parentId); result.setRequestMetaData(metaData); result.setIdentifier(identifier); return resultHandler.handleDirectory(result, parentId, restricted); } DirectoryEventHandler();  DirectoryEventHandler(ResultHandler resultHandler); ResourceId onEvent(final Path dir, ResourceId parentId, int depth, boolean restricted); void setResultHandler(ResultHandler resultHandler);  }
@Test public void testDirectoryEventHandlerSavesANewNodeButDoesNotSubmitToDroid() { final Path file = Paths.get("my/directory"); URI uri = file.toUri(); ResourceId id = new ResourceId(1L, ""); directoryEventHandler.onEvent(file, id, 1, false); ArgumentCaptor<IdentificationResult> captor = ArgumentCaptor.forClass(IdentificationResult.class); verify(resultHandler).handleDirectory(captor.capture(), eq(id), eq(false)); IdentificationResult captured = captor.getValue(); assertEquals(uri, captured.getIdentifier().getUri()); assertEquals("directory", captured.getMetaData().getName()); }