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