PackageGraph implements ProgressCheck { public Collection<PackageId> getSelfAndDescendants(final @NotNull PackageId self) { return internalGetSelfAndDescendents(self).collect(Collectors.toList()); }  @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 testGetSelfAndDescendants() { assertEquals("expect for self " + container1, Arrays.asList(container1, cont1sub1, cont1emb1), graph.getSelfAndDescendants(container1)); assertEquals("expect for self " + container2, Arrays.asList(container2, cont2sub1, cont2emb1), graph.getSelfAndDescendants(container2)); assertEquals("expect for self " + cont1sub1, Collections.singletonList(cont1sub1), graph.getSelfAndDescendants(cont1sub1)); assertEquals("expect for self " + cont2sub1, Collections.singletonList(cont2sub1), graph.getSelfAndDescendants(cont2sub1)); assertEquals("expect for self " + cont1emb1, Collections.singletonList(cont1emb1), graph.getSelfAndDescendants(cont1emb1)); assertEquals("expect for self " + cont2emb1, Collections.singletonList(cont2emb1), graph.getSelfAndDescendants(cont2emb1)); }