01: package org.drools.lang.descr;
02:
03: import java.util.List;
04:
05: import junit.framework.TestCase;
06:
07: public class PackageDescrTest extends TestCase {
08:
09: public void testAttributeOverriding() {
10: PackageDescr desc = new PackageDescr("foo");
11:
12: AttributeDescr at1 = new AttributeDescr("foo", "bar");
13: AttributeDescr at2 = new AttributeDescr("foo2", "default");
14:
15: desc.addAttribute(at1);
16: desc.addAttribute(at2);
17:
18: RuleDescr rule = new RuleDescr("abc");
19: rule.addAttribute(new AttributeDescr("foo", "overridden"));
20:
21: desc.addRule(rule);
22:
23: List pkgAts = desc.getAttributes();
24: assertEquals("bar", ((AttributeDescr) pkgAts.get(0)).getValue());
25: assertEquals("default", ((AttributeDescr) pkgAts.get(1))
26: .getValue());
27:
28: List ruleAts = rule.getAttributes();
29: assertEquals("overridden", ((AttributeDescr) ruleAts.get(0))
30: .getValue());
31: assertEquals("default", ((AttributeDescr) ruleAts.get(1))
32: .getValue());
33:
34: }
35:
36: }
|