1 21 package com.db4o.test.legacy.soda.wrapper.untyped; 22 23 import com.db4o.*; 24 import com.db4o.query.*; 25 import com.db4o.test.legacy.soda.*; 26 27 public class STByteWU implements STClass{ 28 29 final static String DESCENDANT = "i_byte"; 30 31 public static transient SodaTest st; 32 33 Object i_byte; 34 35 public STByteWU(){ 36 } 37 38 private STByteWU(byte a_byte){ 39 i_byte = new Byte (a_byte); 40 } 41 42 public Object [] store() { 43 return new Object []{ 44 new STByteWU((byte)0), 45 new STByteWU((byte)1), 46 new STByteWU((byte)99), 47 new STByteWU((byte)113), 48 }; 49 } 50 51 public void testEquals(){ 52 Query q = st.query(); 53 q.constrain(new STByteWU((byte)0)); 54 st.expectOne(q, store()[0]); 55 } 56 57 public void testNotEquals(){ 58 Query q = st.query(); 59 Object [] r = store(); 60 Constraint c = q.constrain(r[0]); 61 q.descend(DESCENDANT).constraints().not(); 62 st.expect(q, new Object [] {r[1], r[2], r[3]}); 63 } 64 65 public void testGreater(){ 66 Query q = st.query(); 67 Constraint c = q.constrain(new STByteWU((byte)9)); 68 q.descend(DESCENDANT).constraints().greater(); 69 Object [] r = store(); 70 st.expect(q, new Object [] {r[2], r[3]}); 71 } 72 73 public void testSmaller(){ 74 Query q = st.query(); 75 Constraint c = q.constrain(new STByteWU((byte)1)); 76 q.descend(DESCENDANT).constraints().smaller(); 77 st.expectOne(q, store()[0]); 78 } 79 80 public void testContains(){ 81 Query q = st.query(); 82 Constraint c = q.constrain(new STByteWU((byte)9)); 83 q.descend(DESCENDANT).constraints().contains(); 84 Object [] r = store(); 85 st.expect(q, new Object [] {r[2]}); 86 } 87 88 public void testNotContains(){ 89 Query q = st.query(); 90 Constraint c = q.constrain(new STByteWU((byte)0)); 91 q.descend(DESCENDANT).constraints().contains().not(); 92 Object [] r = store(); 93 st.expect(q, new Object [] {r[1], r[2], r[3]}); 94 } 95 96 public void testLike(){ 97 Query q = st.query(); 98 Constraint c = q.constrain(new STByteWU((byte)11)); 99 q.descend(DESCENDANT).constraints().like(); 100 st.expectOne(q, new STByteWU((byte)113)); 101 q = st.query(); 102 c = q.constrain(new STByteWU((byte)10)); 103 q.descend(DESCENDANT).constraints().like(); 104 st.expectNone(q); 105 } 106 107 public void testNotLike(){ 108 Query q = st.query(); 109 Constraint c = q.constrain(new STByteWU((byte)1)); 110 q.descend(DESCENDANT).constraints().like().not(); 111 Object [] r = store(); 112 st.expect(q, new Object [] {r[0], r[2]}); 113 } 114 115 public void testIdentity(){ 116 Query q = st.query(); 117 Constraint c = q.constrain(new STByteWU((byte)1)); 118 ObjectSet set = q.execute(); 119 STByteWU identityConstraint = (STByteWU)set.next(); 120 identityConstraint.i_byte = new Byte ((byte)102); 121 q = st.query(); 122 q.constrain(identityConstraint).identity(); 123 identityConstraint.i_byte = new Byte ((byte)1); 124 st.expectOne(q,store()[1]); 125 } 126 127 public void testNotIdentity(){ 128 Query q = st.query(); 129 Constraint c = q.constrain(new STByteWU((byte)1)); 130 ObjectSet set = q.execute(); 131 STByteWU identityConstraint = (STByteWU)set.next(); 132 identityConstraint.i_byte = new Byte ((byte)102); 133 q = st.query(); 134 q.constrain(identityConstraint).identity().not(); 135 identityConstraint.i_byte = new Byte ((byte)1); 136 Object [] r = store(); 137 st.expect(q, new Object [] {r[0], r[2], r[3]}); 138 } 139 140 public void testConstraints(){ 141 Query q = st.query(); 142 q.constrain(new STByteWU((byte)1)); 143 q.constrain(new STByteWU((byte)0)); 144 Constraints cs = q.constraints(); 145 Constraint[] csa = cs.toArray(); 146 if(csa.length != 2){ 147 st.error("Constraints not returned"); 148 } 149 } 150 151 public void testNull(){ 152 153 } 154 155 public void testEvaluation(){ 156 Query q = st.query(); 157 q.constrain(new STByteWU()); 158 q.constrain(new Evaluation() { 159 public void evaluate(Candidate candidate) { 160 STByteWU sts = (STByteWU)candidate.getObject(); 161 candidate.include((((Byte )sts.i_byte).byteValue() + 2) > 100); 162 } 163 }); 164 Object [] r = store(); 165 st.expect(q, new Object [] {r[2], r[3]}); 166 } 167 168 } 169 170 | Popular Tags |