| 1 21 package com.db4o.db4ounit.common.soda.experiments; 22 import com.db4o.*; 23 import com.db4o.query.*; 24 25 26 public class STIdentityEvaluationTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase{ 27 28 public Object [] createData() { 29 30 Helper helperA = new Helper("aaa"); 31 32 return new Object [] { 33 new STIdentityEvaluationTestCase(null), 34 new STIdentityEvaluationTestCase(helperA), 35 new STIdentityEvaluationTestCase(helperA), 36 new STIdentityEvaluationTestCase(helperA), 37 new STIdentityEvaluationTestCase(new HelperDerivate("bbb")), 38 new STIdentityEvaluationTestCase(new Helper("dod")) 39 }; 40 } 41 42 public Helper helper; 43 44 public STIdentityEvaluationTestCase(){ 45 } 46 47 public STIdentityEvaluationTestCase(Helper h){ 48 this.helper = h; 49 } 50 51 public void test(){ 52 Query q = newQuery(); 53 54 q.constrain(new Helper("aaa")); 55 ObjectSet os = q.execute(); 56 Helper helperA = (Helper)os.next(); 57 q = newQuery(); 58 q.constrain(STIdentityEvaluationTestCase.class); 59 q.descend("helper").constrain(helperA).identity(); 60 q.constrain(new Evaluation() { 61 public void evaluate(Candidate candidate) { 62 candidate.include(true); 63 } 64 }); 65 expect(q, new int[] {1, 2, 3}); 66 } 67 68 public void testMemberClassConstraint(){ 69 Query q = newQuery(); 70 71 q.constrain(STIdentityEvaluationTestCase.class); 72 q.descend("helper").constrain(HelperDerivate.class); 73 expect(q, new int[] {4}); 74 } 75 76 public static class Helper{ 77 78 public String hString; 79 80 public Helper(){ 81 } 82 83 public Helper(String str){ 84 hString = str; 85 } 86 } 87 88 public static class HelperDerivate extends Helper{ 89 public HelperDerivate(){ 90 } 91 92 public HelperDerivate(String str){ 93 super(str); 94 } 95 96 } 97 98 } 99 | Popular Tags |