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 STStringU implements STClass1 { 28 29 public static transient SodaTest st; 30 31 public Object str; 32 33 public STStringU() { 34 } 35 36 public STStringU(String str) { 37 this.str = str; 38 } 39 40 public Object [] store() { 41 return new Object [] { 42 new STStringU(null), 43 new STStringU("aaa"), 44 new STStringU("bbb"), 45 new STStringU("dod")}; 46 } 47 48 public void testEquals() { 49 Query q = st.query(); 50 q.constrain(store()[2]); 51 st.expectOne(q, store()[2]); 52 } 53 54 public void testNotEquals() { 55 Query q = st.query(); 56 Constraint c = q.constrain(store()[2]); 57 q.descend("str").constraints().not(); 58 Object [] r = store(); 59 st.expect(q, new Object [] { r[0], r[1], r[3] }); 60 } 61 62 public void testDescendantEquals() { 63 Query q = st.query(); 64 q.constrain(new STStringU()); 65 q.descend("str").constrain("bbb"); 66 st.expectOne(q, new STStringU("bbb")); 67 } 68 69 public void testContains() { 70 Query q = st.query(); 71 Constraint c = q.constrain(new STStringU("od")); 72 q.descend("str").constraints().contains(); 73 st.expectOne(q, new STStringU("dod")); 74 } 75 76 public void testNotContains() { 77 Query q = st.query(); 78 Constraint c = q.constrain(new STStringU("od")); 79 q.descend("str").constraints().contains().not(); 80 st.expect( 81 q, 82 new Object [] { new STStringU(null), new STStringU("aaa"), new STStringU("bbb")}); 83 } 84 85 public void testLike() { 86 Query q = st.query(); 87 Constraint c = q.constrain(new STStringU("do")); 88 q.descend("str").constraints().like(); 89 st.expectOne(q, new STStringU("dod")); 90 q = st.query(); 91 c = q.constrain(new STStringU("od")); 92 q.descend("str").constraints().like(); 93 st.expectOne(q,store()[3]); 94 } 95 96 public void testNotLike() { 97 Query q = st.query(); 98 Constraint c = q.constrain(new STStringU("aaa")); 99 q.descend("str").constraints().like().not(); 100 st.expect( 101 q, 102 new Object [] { new STStringU(null), new STStringU("bbb"), new STStringU("dod")}); 103 q = st.query(); 104 c = q.constrain(new STStringU("xxx")); 105 q.descend("str").constraints().like(); 106 st.expectNone(q); 107 } 108 109 public void testIdentity() { 110 Query q = st.query(); 111 Constraint c = q.constrain(new STStringU("aaa")); 112 ObjectSet set = q.execute(); 113 STStringU identityConstraint = (STStringU) set.next(); 114 identityConstraint.str = "hihs"; 115 q = st.query(); 116 q.constrain(identityConstraint).identity(); 117 identityConstraint.str = "aaa"; 118 st.expectOne(q, new STStringU("aaa")); 119 } 120 121 public void testNotIdentity() { 122 Query q = st.query(); 123 Constraint c = q.constrain(new STStringU("aaa")); 124 ObjectSet set = q.execute(); 125 STStringU identityConstraint = (STStringU) set.next(); 126 identityConstraint.str = null; 127 q = st.query(); 128 q.constrain(identityConstraint).identity().not(); 129 identityConstraint.str = "aaa"; 130 st.expect( 131 q, 132 new Object [] { new STStringU(null), new STStringU("bbb"), new STStringU("dod")}); 133 } 134 135 public void testNull() { 136 Query q = st.query(); 137 Constraint c = q.constrain(new STStringU(null)); 138 q.descend("str").constrain(null); 139 st.expectOne(q, new STStringU(null)); 140 } 141 142 public void testNotNull() { 143 Query q = st.query(); 144 Constraint c = q.constrain(new STStringU(null)); 145 q.descend("str").constrain(null).not(); 146 st.expect( 147 q, 148 new Object [] { new STStringU("aaa"), new STStringU("bbb"), new STStringU("dod")}); 149 } 150 151 public void testConstraints() { 152 Query q = st.query(); 153 q.constrain(new STStringU("aaa")); 154 q.constrain(new STStringU("bbb")); 155 Constraints cs = q.constraints(); 156 Constraint[] csa = cs.toArray(); 157 if (csa.length != 2) { 158 st.error("Constraints not returned"); 159 } 160 } 161 162 } 163 | Popular Tags |