1 package org.drools.reteoo.impl;
2
3 import junit.framework.TestCase;
4
5 import org.drools.rule.Declaration;
6 import org.drools.semantics.java.ClassObjectType;
7
8 import java.util.Map;
9
10 public class ReteTupleTest extends TestCase
11 {
12 private Declaration rootDecl;
13 private Declaration otherDecl;
14 private Object rootObj;
15 private Object otherObj;
16
17 public ReteTupleTest(String name)
18 {
19 super( name );
20 }
21
22 public void setUp()
23 {
24 this.rootDecl = new Declaration( new ClassObjectType( Object.class ),
25 "rootObj" );
26
27 this.otherDecl = new Declaration( new ClassObjectType( Object.class ),
28 "rootObj" );
29
30 this.rootObj = new Object();
31
32 this.otherObj = new Object();
33 }
34
35 public void tearDown()
36 {
37 this.rootDecl = null;
38 this.otherDecl = null;
39
40 this.rootObj = null;
41 this.otherObj = null;
42 }
43
44 public void testConstruct_WithKey()
45 {
46 ReteTuple tuple = new ReteTuple( this.rootDecl,
47 this.rootObj );
48
49 assertSame( this.rootObj,
50 tuple.get( this.rootDecl ) );
51
52 assertTrue( tuple.getKey().containsDeclaration( this.rootDecl ) );
53 assertTrue( tuple.getKey().containsRootFactObject( this.rootObj ) );
54 }
55
56 public void testDependsOn()
57 {
58 ReteTuple tuple = new ReteTuple( this.rootDecl,
59 this.rootObj );
60
61 tuple.putOtherColumn( this.otherDecl,
62 this.otherObj );
63
64 assertTrue( tuple.dependsOn( this.rootObj ) );
65 assertTrue( ! tuple.dependsOn( this.otherObj ) );
66 }
67
68 public void testGetOtherColumns()
69 {
70 ReteTuple tuple = new ReteTuple( this.rootDecl,
71 this.rootObj );
72
73 tuple.putOtherColumn( this.otherDecl,
74 this.otherObj );
75
76 Map otherCols = tuple.getOtherColumns();
77
78 assertEquals( 1,
79 otherCols.size() );
80
81 assertTrue( otherCols.containsKey( this.otherDecl ) );
82 assertTrue( ! otherCols.containsKey( this.rootDecl ) );
83
84 assertSame( this.otherObj,
85 otherCols.get( this.otherDecl ) );
86 }
87
88 }
This page was automatically generated by Maven