01: package info.jtrac.domain;
02:
03: import info.jtrac.domain.Field;
04: import info.jtrac.domain.Role;
05: import info.jtrac.domain.State;
06: import info.jtrac.util.XmlUtils;
07:
08: import javax.naming.Name;
09: import junit.framework.TestCase;
10: import org.dom4j.Document;
11:
12: public class RoleTest extends TestCase {
13:
14: public void testConstructFromXml() {
15: Document d = XmlUtils.parse("<role name='TESTER'>"
16: + "<state status='1'>" + "<transition status='2'/>"
17: + "<transition status='3'/>"
18: + "<field name='cusInt01' mask='1'/>"
19: + "<field name='cusInt02' mask='2'/>" + "</state>"
20: + "<state status='2'>" + "<transition status='3'/>"
21: + "<field name='cusInt03' mask='1'/>"
22: + "<field name='cusInt04' mask='2'/>"
23: + "</state></role>");
24: Role role = new Role(d.getRootElement());
25: assertEquals("TESTER", role.getName());
26: assertEquals(2, role.getStates().size());
27: State s1 = role.getStates().get(1);
28: assertEquals(2, s1.getTransitions().size());
29: assertTrue(s1.getTransitions().contains(2));
30: assertTrue(s1.getTransitions().contains(3));
31: assertEquals(2, s1.getFields().size());
32: assertEquals(new Integer(1), s1.getFields().get(
33: Field.Name.CUS_INT_01));
34: assertEquals(new Integer(2), s1.getFields().get(
35: Field.Name.CUS_INT_02));
36: }
37: }
|