PatternViolationsWeightFunction implements ViolationWeightFunction { @Override public double getWeight(Overlap violation, Overlaps overlaps, Model model) { return 1.0 / overlaps.getViolationsOfSamePattern(violation).size(); }  @Override double getWeight(Overlap violation, Overlaps overlaps, Model model); @Override String getFormula(Overlap violation, Overlaps overlaps, Model model); @Override String getId();  }
@Test public void withViolationOfOtherPattern() { overlaps.addViolation(someOverlap(somePattern(), someAUG())); ViolationWeightFunction weightFunction = new PatternViolationsWeightFunction(); double weight = weightFunction.getWeight(violation, overlaps, null); assertThat(weight, is(1.0)); }
@Test public void withoutOtherViolationOfPattern() { ViolationWeightFunction weightFunction = new PatternViolationsWeightFunction(); double weight = weightFunction.getWeight(violation, overlaps, null); assertThat(weight, is(1.0)); }
@Test public void withOtherViolationOfSamePattern() { overlaps.addViolation(someOverlap(aPattern, someAUG())); ViolationWeightFunction weightFunction = new PatternViolationsWeightFunction(); double weight = weightFunction.getWeight(violation, overlaps, null); assertThat(weight, is(0.5)); }