01: package org.drools.decisiontable.parser;
02:
03: import junit.framework.TestCase;
04:
05: public class RhsBuilderTest extends TestCase {
06:
07: public void testConsBuilding() {
08: RhsBuilder builder = new RhsBuilder("foo");
09: builder.addTemplate(1, "setFoo($param)");
10: builder.addCellValue(1, "42");
11:
12: assertEquals("foo.setFoo(42);", builder.getResult());
13:
14: builder.clearValues();
15: builder.addCellValue(1, "33");
16: assertEquals("foo.setFoo(33);", builder.getResult());
17: }
18:
19: public void testClassicMode() {
20: RhsBuilder builder = new RhsBuilder("");
21: builder.addTemplate(1, "p.setSomething($param);");
22: builder.addTemplate(2, "drools.clearAgenda();");
23:
24: builder.addCellValue(1, "42");
25:
26: assertEquals("p.setSomething(42);", builder.getResult());
27:
28: builder.addCellValue(2, "Y");
29: assertEquals("p.setSomething(42);\ndrools.clearAgenda();",
30: builder.getResult());
31: }
32:
33: public void testEmptyCellData() {
34: RhsBuilder builder = new RhsBuilder("Foo");
35: builder.addTemplate(1, "p.setSomething($param);");
36: assertFalse(builder.hasValues());
37: }
38:
39: }
|