01: package org.drools.brms.modeldriven;
02:
03: import junit.framework.TestCase;
04:
05: import org.drools.brms.client.modeldriven.brl.CompositeFieldConstraint;
06: import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
07:
08: public class CompositeFieldConstraintTest extends TestCase {
09:
10: public void testCompositeType() {
11: CompositeFieldConstraint con = new CompositeFieldConstraint();
12: assertEquals(null, con.compositeJunctionType);
13: }
14:
15: public void testAddConstraint() {
16: final CompositeFieldConstraint p = new CompositeFieldConstraint();
17: final SingleFieldConstraint x = new SingleFieldConstraint("x");
18: p.addConstraint(x);
19:
20: assertEquals(1, p.constraints.length);
21: assertEquals(x, p.constraints[0]);
22:
23: final SingleFieldConstraint y = new SingleFieldConstraint("y");
24:
25: p.addConstraint(y);
26: assertEquals(2, p.constraints.length);
27: assertEquals(x, p.constraints[0]);
28: assertEquals(y, p.constraints[1]);
29:
30: }
31:
32: public void testRemoveConstraint() {
33: final CompositeFieldConstraint p = new CompositeFieldConstraint();
34: final SingleFieldConstraint x = new SingleFieldConstraint("x");
35: p.addConstraint(x);
36: final CompositeFieldConstraint y = new CompositeFieldConstraint();
37: p.addConstraint(y);
38:
39: assertEquals(2, p.constraints.length);
40:
41: p.removeConstraint(1);
42:
43: assertEquals(1, p.constraints.length);
44:
45: assertEquals(x, p.constraints[0]);
46:
47: }
48:
49: }
|