1
2 package org.drools.reteoo.impl;
3
4 import org.drools.AssertionException;
5 import org.drools.rule.Declaration;
6 import org.drools.spi.Tuple;
7 import org.drools.semantics.java.ClassObjectType;
8
9 import junit.framework.TestCase;
10
11 import java.util.List;
12 import java.util.Set;
13
14 public class ParameterNodeImplTest extends TestCase
15 {
16 private Declaration decl;
17
18 public ParameterNodeImplTest(String name)
19 {
20 super( name );
21 }
22
23 public void setUp()
24 {
25 this.decl = new Declaration( new ClassObjectType( String.class ),
26 "object" );
27 }
28
29 public void tearDown()
30 {
31 this.decl = null;
32 }
33
34 /*** A ParameterNode MUST create a new tuple with a column
35 * based upon the initialization Declaration, containing
36 * the incoming Object as its value, and propagate it.
37 */
38 public void testAssertObject()
39 {
40 Object object1 = new String( "cheese" );
41
42 ParameterNodeImpl node = new ParameterNodeImpl( null,
43 this.decl );
44
45 InstrumentedTupleSink sink = new InstrumentedTupleSink();
46
47 node.setTupleSink( sink );
48
49 try
50 {
51 node.assertObject( object1,
52 null );
53
54 List asserted = sink.getAssertedTuples();
55
56 assertEquals( 1,
57 asserted.size() );
58
59 Tuple tuple = (Tuple) asserted.get( 0 );
60
61 assertSame( object1,
62 tuple.get( this.decl ) );
63 }
64 catch (AssertionException e)
65 {
66 fail( e.toString() );
67 }
68 }
69
70 /*** A ParameterNode MUST return a set consisting of
71 * the initialization Declaration as its only member
72 * for getParamterDeclarations().
73 */
74 public void testGetTupleDeclarations()
75 {
76 ParameterNodeImpl node = new ParameterNodeImpl( null,
77 this.decl );
78
79 Set decls = node.getTupleDeclarations();
80
81 assertEquals( 1,
82 decls.size() );
83
84 assertTrue( decls.contains( this.decl ) );
85 }
86 }
This page was automatically generated by Maven