summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/amazon/carbonado/qe/TestOrderingList.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/qe/TestOrderingList.java b/src/test/java/com/amazon/carbonado/qe/TestOrderingList.java
index b696984..ea9bc10 100644
--- a/src/test/java/com/amazon/carbonado/qe/TestOrderingList.java
+++ b/src/test/java/com/amazon/carbonado/qe/TestOrderingList.java
@@ -107,4 +107,104 @@ public class TestOrderingList extends TestCase {
} catch (IllegalArgumentException e) {
}
}
+
+ public void testImmutable() throws Exception {
+ List<OrderedProperty<StorableTestBasic>> list =
+ OrderingList.get(StorableTestBasic.class, "~date");
+ try {
+ list.set(0, list.get(0).reverse());
+ fail();
+ } catch (UnsupportedOperationException e) {
+ }
+ }
+
+ public void testConcatList() throws Exception {
+ OrderingList<StorableTestBasic> list_1 =
+ OrderingList.get(StorableTestBasic.class, "date", "-intProp", "~stringProp");
+
+ OrderingList<StorableTestBasic> list_2 =
+ OrderingList.get(StorableTestBasic.class, "longProp", "doubleProp");
+
+ OrderingList<StorableTestBasic> list_3 = list_1.concat(list_2);
+
+ assertEquals(5, list_3.size());
+ assertEquals("+date", list_3.get(0).toString());
+ assertEquals("-intProp", list_3.get(1).toString());
+ assertEquals("~stringProp", list_3.get(2).toString());
+ assertEquals("+longProp", list_3.get(3).toString());
+ assertEquals("+doubleProp", list_3.get(4).toString());
+
+ OrderingList<StorableTestBasic> list_4 =
+ OrderingList.get(StorableTestBasic.class,
+ "+date", "-intProp", "~stringProp", "longProp", "+doubleProp");
+
+ assertEquals(list_3, list_4);
+ assertTrue(list_3 == list_4);
+ }
+
+ public void testReverseDirections() throws Exception {
+ OrderingList<StorableTestBasic> list_1 =
+ OrderingList.get(StorableTestBasic.class, "date", "-intProp", "~stringProp");
+
+ list_1 = list_1.reverseDirections();
+
+ assertEquals(3, list_1.size());
+ assertEquals("-date", list_1.get(0).toString());
+ assertEquals("+intProp", list_1.get(1).toString());
+ assertEquals("~stringProp", list_1.get(2).toString());
+
+ OrderingList<StorableTestBasic> list_2 =
+ OrderingList.get(StorableTestBasic.class, "-date", "intProp", "~stringProp");
+
+ assertEquals(list_1, list_2);
+ assertTrue(list_1 == list_2);
+ }
+
+ public void testReplace() throws Exception {
+ OrderingList<StorableTestBasic> list_1 =
+ OrderingList.get(StorableTestBasic.class, "date", "-intProp", "~stringProp");
+
+ OrderedProperty<StorableTestBasic> op_0 = list_1.get(0);
+ OrderedProperty<StorableTestBasic> op_1 = list_1.get(1);
+ OrderedProperty<StorableTestBasic> op_2 = list_1.get(2);
+
+ list_1 = list_1.replace(0, op_1);
+ list_1 = list_1.replace(1, op_2);
+ list_1 = list_1.replace(2, op_0);
+
+ assertEquals(3, list_1.size());
+ assertEquals("-intProp", list_1.get(0).toString());
+ assertEquals("~stringProp", list_1.get(1).toString());
+ assertEquals("+date", list_1.get(2).toString());
+
+ OrderingList<StorableTestBasic> list_2 =
+ OrderingList.get(StorableTestBasic.class, "-intProp", "~stringProp", "+date");
+
+ assertEquals(list_1, list_2);
+ assertTrue(list_1 == list_2);
+ }
+
+ public void testAsArray() throws Exception {
+ OrderingList<StorableTestBasic> list =
+ OrderingList.get(StorableTestBasic.class, "date", "intProp", "stringProp");
+
+ OrderedProperty<StorableTestBasic>[] array = list.asArray();
+
+ assertEquals(3, array.length);
+ assertEquals("+date", array[0].toString());
+ assertEquals("+intProp", array[1].toString());
+ assertEquals("+stringProp", array[2].toString());
+ }
+
+ public void testAsStringArray() throws Exception {
+ OrderingList<StorableTestBasic> list =
+ OrderingList.get(StorableTestBasic.class, "date", "intProp", "stringProp");
+
+ String[] array = list.asStringArray();
+
+ assertEquals(3, array.length);
+ assertEquals("+date", array[0]);
+ assertEquals("+intProp", array[1]);
+ assertEquals("+stringProp", array[2]);
+ }
}