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