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