@Test
public void testCompareTo() {

    
    @org.jeasy.rules.annotation.Rule
    class MyComparableRule implements Comparable<MyComparableRule> {
        
        int comparisonCriteria;
        MyComparableRule(int comparisonCriteria) {
            this.comparisonCriteria = comparisonCriteria;
        }
        @Condition
        public boolean when() { return true; }
        @Action
        public void then() { }
        
        @Override
        public int compareTo(MyComparableRule otherRule) {
            return Integer.compare(comparisonCriteria, otherRule.comparisonCriteria);
        }
    }
    Object rule1 = new MyComparableRule(1);
    Object rule2 = new MyComparableRule(2);
    Object rule3 = new MyComparableRule(2);
    Rule proxy1 = RuleProxy.asRule(rule1);
    Rule proxy2 = RuleProxy.asRule(rule2);
    Rule proxy3 = RuleProxy.asRule(rule3);
    assertEquals(proxy1.compareTo(proxy2),-1);
    assertEquals(proxy2.compareTo(proxy1),1);
    assertEquals(proxy2.compareTo(proxy3),0);
    try {
        Rules rules = new Rules();
        rules.register(rule1, rule2);
        Rules mixedRules = new Rules(rule3);
        mixedRules.register(proxy1,proxy2);
        Rules yetAnotherRulesSet = new Rules(proxy1, proxy2);
        yetAnotherRulesSet.register(rule3);
    } catch (Exception exception) {
        fail("Should not fail with " + exception.getMessage());
    }
}