public void testScoredPrefixSelectorOrdering() {
Element elem = new SimpleElement(1);
elem.setTerms(new String[] {"ibm", "global", "business", "services"});
elem.setTimestamp(System.currentTimeMillis());
SelectorContext ctx = new SelectorContext();
Selector<Element> selector1, selector2;
double score1, score2;
// case 1
selector1 = new ScoredPrefixSelector<Element>("ibm", "global");
selector2 = new ScoredPrefixSelector<Element>("global", "ibm");
ctx.clear();
selector1.select(elem, ctx);
score1 = ctx.getScore();
ctx.clear();
selector2.select(elem, ctx);
score2 = ctx.getScore();
assertTrue(score1 > score2);
// case 2
selector1 = new ScoredPrefixSelector<Element>("global", "business");
selector2 = new ScoredPrefixSelector<Element>("business", "global");
ctx.clear();
selector1.select(elem, ctx);
score1 = ctx.getScore();
ctx.clear();
selector2.select(elem, ctx);
score2 = ctx.getScore();
assertTrue(score1 > score2);
// case 3
selector1 = new ScoredPrefixSelector<Element>("global", "services");
selector2 = new ScoredPrefixSelector<Element>("services", "global");
ctx.clear();
selector1.select(elem, ctx);
score1 = ctx.getScore();
ctx.clear();
selector2.select(elem, ctx);
score2 = ctx.getScore();
assertTrue(score1 > score2);
// case 4
selector1 = new ScoredPrefixSelector<Element>("ibm", "services");
selector2 = new ScoredPrefixSelector<Element>("services", "ibm");
ctx.clear();
selector1.select(elem, ctx);
score1 = ctx.getScore();
ctx.clear();
selector2.select(elem, ctx);
score2 = ctx.getScore();
assertTrue(score1 > score2);
// case 5
selector1 = new ScoredPrefixSelector<Element>("ibm", "global", "business", "services");
selector2 = new ScoredPrefixSelector<Element>("ibm", "business", "global", "services");
ctx.clear();
selector1.select(elem, ctx);
score1 = ctx.getScore();
ctx.clear();
selector2.select(elem, ctx);
score2 = ctx.getScore();
assertTrue(score1 > score2);
}