class AlternativePatternInstancePredicate {

    public boolean test(Overlap violation, Collection<Overlap> instances) {
        for (Overlap instance : instances) {
            if (violation.isInTargetOverlap(instance)) {
                return true;
            }
        }
        return false;
    }

}

class AlternativePatternInstancePredicateTest {

    @Test
    public void keepsViolation_isInstanceOfRelatedPatternButViolationOverlapExtendsInstance() {

        final TestAUGBuilder target = buildAUG().withActionNodes("a", "b", "c");
        final TestAUGBuilder violatedPattern = buildAUG().withActionNodes("a", "b", "d");
        final TestAUGBuilder satisfiedPattern = buildAUG().withActionNodes("a", "c");
        final Overlap violation = buildOverlap(violatedPattern, target).withNodes("a", "b").build();
        final Overlap instance = buildOverlap(satisfiedPattern, target).withNodes("a", "c").build();
        final AlternativePatternInstancePredicate filter = new AlternativePatternInstancePredicate();

        assertFalse(filter.test(violation, Collections.singleton(instance)));
    }

}