@Test public void detectShouldContainRelationshipDetectedByBothSources() { FixedRelationshipDetector detector1 = new FixedRelationshipDetector(Arrays.asList(TestHelper.dependencyOnB())); FixedRelationshipDetector detector2 = new FixedRelationshipDetector( TestHelper.relationshipSetOfDependencyBAndConsumerC()); CompositeRelationshipDetector compositeDetector = new CompositeRelationshipDetector( Arrays.asList(detector1, detector2)); Set<Relationship> expected = TestHelper.relationshipSetOfDependencyBAndConsumerC(); Assert.assertEquals(expected, compositeDetector.detect()); }
@Override public Set<Relationship> detect() { return detectors.stream() .map(RelationshipDetector::detect) .flatMap(Collection::stream) .collect(Collectors.toSet()); }
CompositeRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return detectors.stream() .map(RelationshipDetector::detect) .flatMap(Collection::stream) .collect(Collectors.toSet()); } }
CompositeRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return detectors.stream() .map(RelationshipDetector::detect) .flatMap(Collection::stream) .collect(Collectors.toSet()); } CompositeRelationshipDetector(Collection<RelationshipDetector> detectors); }
CompositeRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return detectors.stream() .map(RelationshipDetector::detect) .flatMap(Collection::stream) .collect(Collectors.toSet()); } CompositeRelationshipDetector(Collection<RelationshipDetector> detectors); @Override Set<Relationship> detect(); }
CompositeRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return detectors.stream() .map(RelationshipDetector::detect) .flatMap(Collection::stream) .collect(Collectors.toSet()); } CompositeRelationshipDetector(Collection<RelationshipDetector> detectors); @Override Set<Relationship> detect();  }