@Test
public void testProcessSubpackageInstallable_onSubpackageException() throws Exception {

    final JcrPackageManager manager = mock(JcrPackageManager.class);
    doThrow(RepositoryException.class).when(manager).open(any(PackageId.class));
    final PackageId root = PackageId.fromString("my_packages:subsubtest");
    final PackageId sub1 = PackageId.fromString("my_packages:subtest");
    final String jcrPath = "/some/path";
    final EmbeddedPackageInstallable installable = new EmbeddedPackageInstallable(root, jcrPath, sub1);
    final Session session = mock(Session.class);
    final CompletableFuture<Exception> eLatch = new CompletableFuture<>();
    final CompletableFuture<EmbeddedPackageInstallable> installableLatch = new CompletableFuture<>();
    final ErrorListener errorListener = mock(ErrorListener.class);
    doAnswer(call -> {
        eLatch.complete(call.getArgument(0, Exception.class));
        installableLatch.complete(call.getArgument(1, EmbeddedPackageInstallable.class));
        return true;
    }).when(errorListener).onSlingEmbeddedPackageError(any(Exception.class),
            any(EmbeddedPackageInstallable.class));
    final SlingSimulatorBackend installWatcher = mock(SlingSimulatorBackend.class);
    when(installWatcher.open(installable))
            .thenReturn(() -> manager.open(sub1));
    builder()
            .withSlingSimulator(installWatcher)
            .withErrorListener(errorListener).build()
            .processEmbeddedPackage(session, manager, installable, false);
    assertTrue("error is of type", eLatch.getNow(null) instanceof RepositoryException);
    assertSame("expect same installable", installable, installableLatch.getNow(null));
}