PackageManagerOperationResolverImpl implements PackageManagerOperationResolver { protected boolean isPartOfInstallPlan(Package pkg, InstallPlan installPlan) { return installPlan.getSteps().stream().anyMatch(step -> { if (step instanceof InstallPlanStep.PackageInstallStep) { return isSamePackage(pkg, ((InstallPlanStep.PackageInstallStep) step).getPackage()); } else if (step instanceof InstallPlanStep.PackageVersionChangeStep) { final InstallPlanStep.PackageVersionChangeStep change = (InstallPlanStep.PackageVersionChangeStep) step; return isSamePackage(pkg, change.getInstalledPackage()) || isSamePackage(pkg, change.getTargetPackage()); } return false; }); } PackageManagerOperationResolverImpl(Supplier<Collection<Package>> installedPackagesSupplier,
                                             Supplier<Collection<Package>> availablePackagesSupplier); @Override ResolveState resolve(Collection<Package> packagesToInstall, Collection<Package> packagesToUninstall); @Override boolean isValid(ResolveState resolveState);  }
@Test public void testIsPartOfInstallPlan() throws Exception { final PackageManagerOperationResolverImpl res = new PackageManagerOperationResolverImpl(null, null); final InstallPlan installPlan = new InstallPlan(); installPlan.getSteps().add(new InstallPlanStep.PackageInstallStep(createPackage("foo", "2.0-1"))); installPlan.getSteps().add(new InstallPlanStep.PackageInstallStep(createPackage("bar", "2.1-4"))); assertTrue(res.isPartOfInstallPlan(createPackage("foo", "2.0-1"), installPlan)); assertFalse(res.isPartOfInstallPlan(createPackage("brazn", "2.0-1"), installPlan)); assertFalse(res.isPartOfInstallPlan(createPackage("foo", "2.1-1"), installPlan)); }