PackageGraph implements ProgressCheck { @Override public void identifySubpackage(final PackageId packageId, final PackageId parentId) { if (packageId != null && parentId != null) { identified.add(packageId); getOrCreateNode(packageId).setParent(getOrCreateNode(parentId)); } }  @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 testIdentifySubpackage() { graph.startedScan(); assertNull("expect last identified is null", graph.getLastIdentified()); assertFalse("expect not identified " + cont2sub1, graph.isIdentified(cont2sub1)); graph.identifySubpackage(cont2sub1, container2); assertTrue("expect identified " + cont2sub1, graph.isIdentified(cont2sub1)); assertEquals("expect cont2sub1 is last identified", cont2sub1, graph.getLastIdentified()); assertFalse("expect not identified " + cont1sub1, graph.isIdentified(cont1sub1)); graph.identifySubpackage(cont1sub1, container1); assertTrue("expect identified " + cont1sub1, graph.isIdentified(cont1sub1)); assertEquals("expect cont1sub1 is last identified", cont1sub1, graph.getLastIdentified()); }