MissingAssignmentNoViolationPredicate implements ViolationPredicate { @Override public Optional<Boolean> apply(Overlap overlap) { if (missesOnlyAssignmentsAndExclusiveAssignmentParameters(overlap)) return Optional.of(false); else return Optional.empty(); }  @Override Optional<Boolean> apply(Overlap overlap);  }
@Test public void considersMissingAssignmentNoViolation() { TestAUGBuilder pattern = buildAUG().withActionNodes("C.m()", "=").withEdge("C.m()", SELECTION, "="); TestAUGBuilder target = buildAUG().withActionNode("C.m()"); TestOverlapBuilder violation = buildOverlap(pattern, target).withNode("C.m()"); Optional<Boolean> decision = new MissingAssignmentNoViolationPredicate().apply(violation.build()); assertThat(decision, is(Optional.of(false))); }
@Test public void considersMissingAssignmentWithParameterNoViolation() { TestAUGBuilder pattern = buildAUG().withActionNodes("C.m()", "=").withDataNode("D") .withEdge("C.m()", SELECTION, "=").withEdge("D", PARAMETER, "="); TestAUGBuilder target = buildAUG().withActionNode("C.m()"); TestOverlapBuilder violation = buildOverlap(pattern, target).withNode("C.m()"); Optional<Boolean> decision = new MissingAssignmentNoViolationPredicate().apply(violation.build()); assertThat(decision, is(Optional.of(false))); }
@Test public void doesNotDecideAboutMissingAssignmentAndMissingEdge() { TestAUGBuilder pattern = buildAUG().withActionNodes("A.b()", "C.m()", "=") .withEdge("A.b()", ORDER, "C.m()").withEdge("C.m()", SELECTION, "="); TestAUGBuilder target = buildAUG().withActionNodes("A.b()", "C.m()"); TestOverlapBuilder violation = buildOverlap(pattern, target).withNodes("A.b()", "C.m()"); Optional<Boolean> decision = new MissingAssignmentNoViolationPredicate().apply(violation.build()); assertThat(decision, is(Optional.empty())); }