ViolationSupportWeightFunction implements ViolationWeightFunction { @Override public double getWeight(Overlap violation, Overlaps overlaps, Model model) { return 1.0 / overlaps.getNumberOfEqualViolations(violation); }  @Override double getWeight(Overlap violation, Overlaps overlaps, Model model); @Override String getFormula(Overlap violation, Overlaps overlaps, Model model); @Override String getId();  }
@Test public void withoutEqualViolations() { ViolationWeightFunction weightFunction = new ViolationSupportWeightFunction(); double weight = weightFunction.getWeight(violation, overlaps, null); assertThat(weight, is(1.0)); }
@Test public void calculatesViolationSupportWeight_anEqualViolation() { TestAUGBuilder anotherTarget = buildAUG().withActionNode("a"); Overlap anEqualViolation = buildOverlap(patternBuilder, anotherTarget).withNode("a", "a").build(); overlaps.addViolation(anEqualViolation); ViolationWeightFunction weightFunction = new ViolationSupportWeightFunction(); double weight = weightFunction.getWeight(violation, overlaps, null); assertThat(weight, is(0.5)); }