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