1 21 package com.db4o.test.legacy.soda.ordered; 22 23 24 import com.db4o.query.*; 25 import com.db4o.test.legacy.soda.*; 26 27 public class STOIntegerWT implements STClass{ 28 29 public static transient SodaTest st; 30 31 Integer i_int; 32 33 public STOIntegerWT(){ 34 } 35 36 private STOIntegerWT(int a_int){ 37 i_int = new Integer (a_int); 38 } 39 40 public Object [] store() { 41 return new Object []{ 42 new STOIntegerWT(1001), 43 new STOIntegerWT(99), 44 new STOIntegerWT(1), 45 new STOIntegerWT(909), 46 new STOIntegerWT(1001), 47 new STOIntegerWT(0), 48 new STOIntegerWT(1010), 49 new STOIntegerWT() 50 }; 51 } 52 53 public void testAscending() { 54 Query q = st.query(); 55 q.constrain(STOIntegerWT.class); 56 q.descend("i_int").orderAscending(); 57 Object [] r = store(); 58 st.expectOrdered(q, new Object [] { r[5], r[2], r[1], r[3], r[0], r[4], r[6], r[7] }); 59 } 60 61 public void testDescending() { 62 Query q = st.query(); 63 q.constrain(STOIntegerWT.class); 64 q.descend("i_int").orderDescending(); 65 Object [] r = store(); 66 st.expectOrdered(q, new Object [] { r[6], r[4], r[0], r[3], r[1], r[2], r[5], r[7] }); 67 } 68 69 public void testAscendingGreater(){ 70 Query q = st.query(); 71 q.constrain(STOIntegerWT.class); 72 Query qInt = q.descend("i_int"); 73 qInt.constrain(new Integer (100)).greater(); 74 qInt.orderAscending(); 75 Object [] r = store(); 76 st.expectOrdered(q, new Object [] {r[3], r[0], r[4], r[6]}); 77 } 78 } 79 80 | Popular Tags |