@Test public void testFilterCandidatesSelfSatisfiedCapability() throws IOException { Bundle bundle = wiredBundle( Collections.emptyList() ); BundleCapability candidate1 = bundleCap(1, targetBundleVersion, false ); List<BundleCapability> candidates = new ArrayList<>(); candidates.add(candidate1); BundleCapability matchingCandidate = bundleCap(2, "1.1.0", false ); candidates.add(matchingCandidate); BundleRequirement req = packageRequirement(packageFilter); c.replay(); BundleWires wires = new BundleWires(bundle); Set<BundleCapability> goodCandidates = wires.filterCandidates( req, candidates ); assertEquals(1, goodCandidates.size()); assertEquals(candidate1, goodCandidates.iterator().next()); c.verify(); }
Set<BundleCapability> filterCandidates( BundleRequirement requirement, Collection<BundleCapability> candidates) { Set<String> wiredCapabilityIds = wiring.get(getRequirementId(requirement)); return candidates.stream() .filter( capability -> isCapabilityWiredToBundle( wiredCapabilityIds, capability ) ) .collect( Collectors.toSet() ); }
BundleWires { Set<BundleCapability> filterCandidates( BundleRequirement requirement, Collection<BundleCapability> candidates) { Set<String> wiredCapabilityIds = wiring.get(getRequirementId(requirement)); return candidates.stream() .filter( capability -> isCapabilityWiredToBundle( wiredCapabilityIds, capability ) ) .collect( Collectors.toSet() ); } }
BundleWires { Set<BundleCapability> filterCandidates( BundleRequirement requirement, Collection<BundleCapability> candidates) { Set<String> wiredCapabilityIds = wiring.get(getRequirementId(requirement)); return candidates.stream() .filter( capability -> isCapabilityWiredToBundle( wiredCapabilityIds, capability ) ) .collect( Collectors.toSet() ); } BundleWires(Bundle bundle);   BundleWires(long bundleId, BufferedReader reader); }
BundleWires { Set<BundleCapability> filterCandidates( BundleRequirement requirement, Collection<BundleCapability> candidates) { Set<String> wiredCapabilityIds = wiring.get(getRequirementId(requirement)); return candidates.stream() .filter( capability -> isCapabilityWiredToBundle( wiredCapabilityIds, capability ) ) .collect( Collectors.toSet() ); } BundleWires(Bundle bundle);   BundleWires(long bundleId, BufferedReader reader);  }
BundleWires { Set<BundleCapability> filterCandidates( BundleRequirement requirement, Collection<BundleCapability> candidates) { Set<String> wiredCapabilityIds = wiring.get(getRequirementId(requirement)); return candidates.stream() .filter( capability -> isCapabilityWiredToBundle( wiredCapabilityIds, capability ) ) .collect( Collectors.toSet() ); } BundleWires(Bundle bundle);   BundleWires(long bundleId, BufferedReader reader);   }