1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml2.env;
18
19 import org.apache.commons.scxml2.model.State;
20 import org.apache.commons.scxml2.model.Transition;
21 import org.junit.Assert;
22 import org.junit.Test;
23
24 public class LogUtilsTest {
25
26 @Test
27 public void testGetTTPathParentNull() {
28 State target = new State();
29 target.setId("ID");
30
31 Assert.assertEquals("/ID", LogUtils.getTTPath(target));
32 }
33
34 @Test
35 public void testGetTTPathParent() {
36 State target = new State();
37 target.setId("ID");
38
39 State parent1 = new State();
40 parent1.setId("parent1");
41
42 State parent2 = new State();
43 parent2.setId("parent2");
44
45 parent1.setParent(parent2);
46 target.setParent(parent1);
47
48 Assert.assertEquals("/parent2/parent1/ID", LogUtils.getTTPath(target));
49 }
50
51 @Test
52 public void testTransToString() {
53 State targetTo = new State();
54 targetTo.setId("TO");
55
56 State targetFrom = new State();
57 targetFrom.setId("FROM");
58
59 Transition transition = new Transition();
60 transition.setCond("condition");
61 transition.setEvent("event happened");
62
63 Assert.assertEquals( "(event = event happened, cond = condition, from = /FROM, to = /TO)",
64 LogUtils.transToString(targetFrom, targetTo, transition, transition.getEvent()));
65 }
66
67 }