diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 23:02:22 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 23:02:22 +0000 |
commit | 1e814b1df1670f0a19a77d55848fe6f836fa4e6b (patch) | |
tree | 8034c1d82fe8214b1035992881694ef64620641b /src/test/java/com/amazon/carbonado | |
parent | b523f10dcac0a265edfd74ce78d83bf079ead8da (diff) |
OrderingScore supports automatic ordering direction when unspecified.
Diffstat (limited to 'src/test/java/com/amazon/carbonado')
-rw-r--r-- | src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java index 91b5676..ecacf9a 100644 --- a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java +++ b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java @@ -543,4 +543,46 @@ public class TestOrderingScore extends TestCase { assertEquals("+doubleProp", score.getHandledOrderings().get(1).toString());
assertEquals("+longProp", score.getRemainderOrderings().get(0).toString());
}
+
+ public void testUnspecifiedDirection() throws Exception {
+ // Tests that an originally unspecified ordering direction is determined.
+ final StorableIndex<StorableTestBasic> ix;
+ List<OrderedProperty<StorableTestBasic>> ops;
+ OrderingScore score;
+ Filter<StorableTestBasic> filter;
+
+ ix = makeIndex(StorableTestBasic.class, "id", "intProp", "doubleProp");
+ ops = makeOrderings(StorableTestBasic.class, "~intProp", "-doubleProp");
+ filter = Filter.filterFor(StorableTestBasic.class, "id = ?");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(true, score.shouldReverseOrder());
+
+ assertEquals("-intProp", score.getHandledOrderings().get(0).toString());
+ assertEquals("-doubleProp", score.getHandledOrderings().get(1).toString());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "intProp", "~doubleProp");
+
+ score = OrderingScore.evaluate(ix, null, ops);
+ assertEquals(3, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(false, score.shouldReverseOrder());
+
+ assertEquals("+id", score.getHandledOrderings().get(0).toString());
+ assertEquals("+intProp", score.getHandledOrderings().get(1).toString());
+ assertEquals("+doubleProp", score.getHandledOrderings().get(2).toString());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp", "~doubleProp");
+
+ score = OrderingScore.evaluate(ix, null, ops);
+ assertEquals(3, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(true, score.shouldReverseOrder());
+
+ assertEquals("-id", score.getHandledOrderings().get(0).toString());
+ assertEquals("-intProp", score.getHandledOrderings().get(1).toString());
+ assertEquals("-doubleProp", score.getHandledOrderings().get(2).toString());
+ }
}
|