@Test
public void ranksViolations() {

    Overlap violation1 = someOverlap();
    Overlap violation2 = someOverlap();
    Overlaps overlaps = new Overlaps();
    overlaps.addViolation(violation1);
    overlaps.addViolation(violation2);
    Model model = context.mock(Model.class);
    ViolationWeightFunction weightFunction = context.mock(ViolationWeightFunction.class);
    context.checking(new Expectations() {{
        allowing(weightFunction).getWeight(violation1, overlaps, model); will(returnValue(0.5));
        allowing(weightFunction).getFormula(violation1, overlaps, model); will(returnValue("0.5"));
        allowing(weightFunction).getWeight(violation2, overlaps, model); will(returnValue(0.7));
        allowing(weightFunction).getFormula(violation2, overlaps, model); will(returnValue("0.7"));
    }});
    ViolationRankingStrategy strategy = new WeightRankingStrategy(weightFunction);
    final List<Violation> violations = strategy.rankViolations(overlaps, model);
    assertThat(violations, contains(
            new Violation(violation2, 0.7, "0.7"),
            new Violation(violation1, 0.5, "0.5")));
}