@Test
public void testCreateInstallableOrReport() throws Exception {

    ErrorListener errorListener = mock(ErrorListener.class);
    slingSimulator.setErrorListener(errorListener);
    final CompletableFuture<Exception> eLatch = new CompletableFuture<>();
    final CompletableFuture<Class<?>> tLatch = new CompletableFuture<>();
    final CompletableFuture<PackageId> idLatch = new CompletableFuture<>();
    final CompletableFuture<String> pathLatch = new CompletableFuture<>();
    doAnswer(call -> {
        eLatch.complete(call.getArgument(0, Exception.class));
        tLatch.complete(call.getArgument(1, Class.class));
        idLatch.complete(call.getArgument(2, PackageId.class));
        pathLatch.complete(call.getArgument(3, String.class));
        return true;
    }).when(errorListener).onSlingCreateInstallableError(
            any(Exception.class),
            any(Class.class),
            any(PackageId.class),
            anyString());
    final Exception expectError = new IOException("you yamled when you should have jsoned!");
    final Class<?> expectType = OsgiConfigInstallable.class;
    final PackageId expectId = PackageId.fromString("test");
    final String expectPath = "/some/path-id.cfg.json";
    final OsgiConfigInstallableParams goodParams = new OsgiConfigInstallableParams(Collections.emptyMap(),
            "id", "path", null);
    final OsgiConfigInstallableParams badParams = new OsgiConfigInstallableParams(Collections.emptyMap(),
            "id", "path", expectError);
    OsgiConfigInstallable goodInstallable = slingSimulator.createInstallableOrReport(goodParams, expectId, expectPath)
            .orElse(null);
    assertNotNull("expect non null installable for goodParams", goodInstallable);
    assertFalse("eLatch is not done", eLatch.isDone());
    assertFalse("tLatch is not done", tLatch.isDone());
    assertFalse("idLatch is not done", idLatch.isDone());
    assertFalse("pathLatch is not done", pathLatch.isDone());
    OsgiConfigInstallable badInstallable = slingSimulator.createInstallableOrReport(badParams, expectId, expectPath)
            .orElse(null);
    assertNull("expect null installable for badParams", badInstallable);
    assertSame("expect same error", expectError, eLatch.getNow(null));
    assertSame("expect same type", expectType, tLatch.getNow(null));
    assertSame("expect same parentId", expectId, idLatch.getNow(null));
    assertSame("expect same path", expectPath, pathLatch.getNow(null));
}