@Test public void constructorShouldCopyCollection() { Dependency a = Dependency.on(TestHelper.componentA()); List<Relationship> originalCollection = new ArrayList<>(); originalCollection.add(a); FixedRelationshipDetector detector = new FixedRelationshipDetector(originalCollection); Dependency b = Dependency.on(TestHelper.componentB()); originalCollection.add(b); Set<Relationship> actual = detector.detect(); Set<Relationship> expected = new HashSet<>(); expected.add(a); Assert.assertEquals(expected, actual); }
@Override public Set<Relationship> detect() { return new HashSet<>(relationships); }
FixedRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return new HashSet<>(relationships); } }
FixedRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return new HashSet<>(relationships); } FixedRelationshipDetector(Collection<Relationship> rels); }
FixedRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return new HashSet<>(relationships); } FixedRelationshipDetector(Collection<Relationship> rels); @Override Set<Relationship> detect(); }
FixedRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { return new HashSet<>(relationships); } FixedRelationshipDetector(Collection<Relationship> rels); @Override Set<Relationship> detect();  }