@Test
public void testScanOnListenerExceptionFromIdentifySubpackage() throws Exception {

    final File testPackage = TestPackageUtil.prepareTestPackage("subsubtest.zip");
    final ProgressCheck check = mock(ProgressCheck.class);
    final ErrorListener errorListener = mock(ErrorListener.class);
    doThrow(RuntimeException.class).when(check).identifySubpackage(
            any(PackageId.class),
            any(PackageId.class)
    );
    final CompletableFuture<Exception> eLatch = new CompletableFuture<>();
    final CompletableFuture<ProgressCheck> handlerLatch = new CompletableFuture<>();
    final CompletableFuture<PackageId> idLatch = new CompletableFuture<>();
    doAnswer(call -> {
        eLatch.complete(call.getArgument(0, Exception.class));
        handlerLatch.complete(call.getArgument(1, ProgressCheck.class));
        idLatch.complete(call.getArgument(2, PackageId.class));
        return true;
    }).when(errorListener).onListenerException(any(Exception.class), any(ProgressCheck.class), any(PackageId.class));
    builder().withProgressCheck(check).withErrorListener(errorListener).build().scanPackage(testPackage);
    assertTrue("error is of type", eLatch.getNow(null) instanceof RuntimeException);
    assertSame("same check", check, handlerLatch.getNow(null));
    assertEquals("package id is",
            PackageId.fromString("my_packages:subtest"), idLatch.getNow(null));
}