@Test
public void testProcessInstallableQueue_singleSubpackageInstallable() throws Exception {

    final JcrPackageManager manager = mock(JcrPackageManager.class);
    final Session session = mock(Session.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 List<EmbeddedPackageInstallable> installables = new ArrayList<>();
    installables.add(installable);
    final SlingSimulatorBackend installWatcher = mock(SlingSimulatorBackend.class);
    final List<Optional<EmbeddedPackageInstallable>> dequeuedValues = new ArrayList<>();
    doAnswer(call -> {
        if (installables.isEmpty()) {
            dequeuedValues.add(Optional.empty());
            return null;
        } else {
            EmbeddedPackageInstallable toReturn = installables.remove(0);
            dequeuedValues.add(Optional.ofNullable(toReturn));
            return toReturn;
        }
    }).when(installWatcher).dequeueInstallable();
    final JcrPackage jcrPackage = mock(JcrPackage.class);
    final CompletableFuture<EmbeddedPackageInstallable> openedSlot = new CompletableFuture<>();
    doAnswer(call -> {
        openedSlot.complete(call.getArgument(0));
        return (Fun.ThrowingSupplier<JcrPackage>) () -> jcrPackage;
    }).when(installWatcher).open(installable);
    new OakMachine.Builder()
            .withSlingSimulator(installWatcher)
            .build().processInstallableQueue(session, manager, root, false);
    assertEquals("expect dequeued values",
            Arrays.asList(Optional.of(installable), Optional.empty()), dequeuedValues);
    assertSame("expect request to open installable", installable, openedSlot.getNow(null));
}