MissingCatchNoViolationPredicate implements ViolationPredicate { @Override public Optional<Boolean> apply(Overlap overlap) { return isMissingCatchOnly(overlap) || isMissingThrowOnly(overlap) ? Optional.of(false) : Optional.empty(); }  @Override Optional<Boolean> apply(Overlap overlap);  }
@Test public void missingCatchNoViolation() { TestAUGBuilder pattern = buildAUG().withActionNodes("mayFail()", "<catch>").withDataNode("SomeException") .withEdge("mayFail()", THROW, "SomeException") .withEdge("SomeException", PARAMETER, "<catch>"); TestAUGBuilder target = buildAUG().withActionNodes("mayFail()"); TestOverlapBuilder overlap = buildOverlap(pattern, target).withNodes("mayFail()"); Optional<Boolean> decision = new MissingCatchNoViolationPredicate().apply(overlap.build()); assertThat(decision, is(Optional.of(false))); }
@Test public void missingThrowNoViolation() { TestAUGBuilder pattern = buildAUG().withActionNodes("mayFail()").withDataNode("SomeException") .withEdge("mayFail()", THROW, "SomeException"); TestAUGBuilder target = buildAUG().withActionNodes("mayFail()"); TestOverlapBuilder overlap = buildOverlap(pattern, target).withNodes("mayFail()"); Optional<Boolean> decision = new MissingCatchNoViolationPredicate().apply(overlap.build()); assertThat(decision, is(Optional.of(false))); }