01: package org.drools.eclipse.editors.outline;
02:
03: import junit.framework.TestCase;
04:
05: import org.drools.eclipse.core.DroolsElement;
06: import org.drools.eclipse.core.Function;
07: import org.drools.eclipse.core.Package;
08: import org.drools.eclipse.core.RuleSet;
09: import org.drools.eclipse.editors.AbstractRuleEditor;
10: import org.drools.eclipse.editors.outline.RuleContentOutlinePage;
11:
12: public class RuleContentOutlineTest extends TestCase {
13:
14: public void testNodeBuild() {
15: RuleContentOutlinePage page = new RuleContentOutlinePage(null);
16: String source = "package test;\nexpander foobar.dsl\nimport foo\nfunction void smeg(s) {\n \n}\n";
17: page.populatePackageTreeNode(source);
18: RuleSet ruleSet = page.getRuleSet();
19: Package p = ruleSet.getPackage("test");
20: assertNotNull(p);
21: DroolsElement[] nodes = p.getChildren();
22:
23: for (int i = 0; i < nodes.length; i++) {
24: if (nodes[i] instanceof Function) {
25: Function func = (Function) nodes[i];
26: assertEquals("smeg()", func.getFunctionName());
27:
28: }
29: }
30:
31: source = "package test;\n function String foo(String bar) {";
32: page.populatePackageTreeNode(source);
33: p = ruleSet.getPackage("test");
34: assertNotNull(p);
35: Function func = (Function) p.getChildren()[0];
36: assertEquals("foo()", func.getFunctionName());
37:
38: }
39:
40: }
|