PackageGraph implements ProgressCheck { @Override public void identifyEmbeddedPackage(final PackageId packageId, final PackageId parentId, final EmbeddedPackageInstallable slingInstallable) { final PackageId self = Optional.ofNullable(slingInstallable).map(EmbeddedPackageInstallable::getEmbeddedId).orElse(packageId); final PackageId parent = Optional.ofNullable(slingInstallable).map(EmbeddedPackageInstallable::getParentId).orElse(parentId); if (self != null && parent != null) { identified.add(self); getOrCreateNode(self).setParent(getOrCreateNode(parent)); } }  @Override Collection<Violation> getReportedViolations(); @Override void startedScan(); @Override void identifyPackage(final PackageId packageId, final File file); @Override void identifySubpackage(final PackageId packageId, final PackageId parentId); @Override void identifyEmbeddedPackage(final PackageId packageId, final PackageId parentId,
                                        final EmbeddedPackageInstallable slingInstallable); boolean isIdentified(final @NotNull PackageId packageId); @Nullable PackageId getLastIdentified(); boolean isRoot(final @NotNull PackageId packageId); boolean isLeftDescendantOfRight(final @NotNull PackageId left, final @NotNull PackageId right); Collection<PackageId> getSelfAndAncestors(final @NotNull PackageId self); Collection<PackageId> getSelfAndDescendants(final @NotNull PackageId self);  }
@Test public void testIdentifyEmbeddedPackage() { graph.startedScan(); assertNull("expect last identified is null", graph.getLastIdentified()); assertFalse("expect not identified " + cont2emb1, graph.isIdentified(cont2emb1)); graph.identifyEmbeddedPackage(cont2emb1, null, new EmbeddedPackageInstallable(container2, "", cont2emb1)); assertTrue("expect identified " + cont2emb1, graph.isIdentified(cont2emb1)); assertEquals("expect cont2emb1 is last identified", cont2emb1, graph.getLastIdentified()); assertFalse("expect not identified " + cont1emb1, graph.isIdentified(cont1emb1)); graph.identifyEmbeddedPackage(cont1emb1, container1, null); assertTrue("expect identified " + cont1emb1, graph.isIdentified(cont1emb1)); assertEquals("expect cont1emb1 is last identified", cont1emb1, graph.getLastIdentified()); }