PackageManagerOperationResolverImpl implements PackageManagerOperationResolver { protected Stream<InstallPlanStep> findPackagesToInstall(Collection<Package> packagesToInstall, InstallPlan installPlan) { return packagesToInstall.stream() .filter(pkg -> !isPartOfInstallPlan(pkg, installPlan)) .map(InstallPlanStep.PackageInstallStep::new); } 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 testFindPackagesToInstall() { PackageManagerOperationResolverImpl res = new PackageManagerOperationResolverImpl(null, null); Collection<Package> packagesToInstall = Arrays.asList(createPackage("foo", "2.0-1")); List<InstallPlanStep> collect = res.findPackagesToInstall(packagesToInstall, new InstallPlan()).collect(Collectors.toList()); assertFalse(collect.isEmpty()); assertEquals(1, collect.size()); }
@Test public void testFindPackagesToInstallWithOnePackageAlreadyPartOfInstall() { PackageManagerOperationResolverImpl res = new PackageManagerOperationResolverImpl(null, null); Collection<Package> packagesToInstall = Arrays.asList(createPackage("foo", "2.0-1"), createPackage("brazn", "3.0-1")); 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"))); List<InstallPlanStep> collect = res.findPackagesToInstall(packagesToInstall, installPlan).collect(Collectors.toList()); assertFalse(collect.isEmpty()); assertEquals(1, collect.size()); assertEquals("brazn", ((InstallPlanStep.PackageInstallStep) collect.get(0)).getPackage().getName()); }