@Test
public void testImporterListenerAdapter_onMessage_deletedPathException() throws Exception {

    final File testPackage = TestPackageUtil.prepareTestPackage("tmp_foo_bar.zip");
    final InitStage stage = new InitStage.Builder().withForcedRoot("/tmp/foo/bar/cat").build();
    final ProgressCheck check = mock(ProgressCheck.class);
    doThrow(RepositoryException.class).when(check)
            .deletedPath(any(PackageId.class), anyString(), any(Session.class));
    final CompletableFuture<Exception> eLatch = new CompletableFuture<>();
    final CompletableFuture<ProgressCheck> handlerLatch = new CompletableFuture<>();
    final CompletableFuture<PackageId> idLatch = new CompletableFuture<>();
    final CompletableFuture<String> pathLatch = new CompletableFuture<>();
    final ErrorListener errorListener = mock(ErrorListener.class);
    doAnswer(call -> {
        eLatch.complete(call.getArgument(0, Exception.class));
        handlerLatch.complete(call.getArgument(1, ProgressCheck.class));
        idLatch.complete(call.getArgument(2, PackageId.class));
        pathLatch.complete(call.getArgument(3, String.class));
        return true;
    }).when(errorListener).onListenerPathException(any(Exception.class), any(ProgressCheck.class),
            any(PackageId.class), anyString());
    builder().withInitStage(stage)
            .withProgressCheck(check)
            .withErrorListener(errorListener)
            .build().scanPackage(testPackage);
    assertTrue("error is of type", eLatch.getNow(null) instanceof RepositoryException);
    assertSame("same check", check, handlerLatch.getNow(null));
    assertEquals("package id is",
            PackageId.fromString("my_packages:tmp_foo_bar"), idLatch.getNow(null));
    assertEquals("path is", "/tmp/foo/bar/cat", pathLatch.getNow(""));
}