1 21 package com.db4o.db4ounit.common.soda.classes.typedhierarchy; 22 import com.db4o.query.*; 23 24 25 26 public class STETH1TestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase{ 27 28 public String foo1; 29 30 public STETH1TestCase(){ 31 } 32 33 public STETH1TestCase(String str){ 34 foo1 = str; 35 } 36 37 public Object [] createData() { 38 return new Object []{ 39 new STETH1TestCase(), 40 new STETH1TestCase("str1"), 41 new STETH2(), 42 new STETH2("str1", "str2"), 43 new STETH3(), 44 new STETH3("str1a", "str2", "str3"), 45 new STETH3("str1a", "str2a", null), 46 new STETH4(), 47 new STETH4("str1a", "str2", "str4"), 48 new STETH4("str1b", "str2a", "str4") 49 }; 50 } 51 52 public void testStrNull(){ 53 Query q = newQuery(); 54 q.constrain(new STETH1TestCase()); 55 q.descend("foo1").constrain(null); 56 57 expect(q, new int[] {0, 2, 4, 7}); 58 } 59 60 public void testTwoNull(){ 61 Query q = newQuery(); 62 q.constrain(new STETH1TestCase()); 63 q.descend("foo1").constrain(null); 64 q.descend("foo3").constrain(null); 65 66 expect(q, new int[] {0, 2, 4, 7}); 67 } 68 69 public void testClass(){ 70 Query q = newQuery(); 71 q.constrain(STETH2.class); 72 73 expect(q, new int[] {2, 3, 4, 5, 6, 7, 8, 9}); 74 } 75 76 public void testOrClass(){ 77 Query q = newQuery(); 78 q.constrain(STETH3.class).or(q.constrain(STETH4.class)); 79 80 expect(q, new int[] {4, 5, 6, 7, 8, 9}); 81 } 82 83 public void testAndClass(){ 84 Query q = newQuery(); 85 q.constrain(STETH1TestCase.class); 86 q.constrain(STETH4.class); 87 88 expect(q, new int[] {7, 8, 9}); 89 } 90 91 public void testParalellDescendantPaths(){ 92 Query q = newQuery(); 93 q.constrain(STETH3.class).or( 94 q.constrain(STETH4.class)); 95 q.descend("foo3").constrain("str3").or( 96 q.descend("foo4").constrain("str4")); 97 98 expect(q, new int[] {5, 8, 9}); 99 } 100 101 public void testOrObjects(){ 102 Query q = newQuery(); 103 104 q.constrain(_array[3]).or(q.constrain(_array[5])); 105 expect(q, new int[] {3, 5}); 106 } 107 108 } 109 110 | Popular Tags |