1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.util;
17
18 import org.junit.Test;
19 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24
25 import static org.junit.Assert.assertEquals;
26
27
28
29
30
31
32 public class UtilitiesTest {
33
34
35
36
37 @Test
38 public void RouteLogActionRequestSorterTest_AR1_Active() {
39 ActionRequestValue ar1 = new ActionRequestValue();
40 ActionRequestValue ar2 = new ActionRequestValue();
41
42 ar1.setActionRequestId("Test1");
43 ar1.setRouteLevel(1);
44 ar1.setStatus("A");
45
46 ar2.setActionRequestId("Test2");
47 ar2.setRouteLevel(1);
48 ar2.setStatus("I");
49
50 List<ActionRequestValue> actionRequestValues = new ArrayList<ActionRequestValue>();
51 actionRequestValues.add(ar1);
52 actionRequestValues.add(ar2);
53
54 Collections.sort(actionRequestValues, new Utilities.RouteLogActionRequestSorter());
55
56 assertEquals("Test1", actionRequestValues.get(0).getActionRequestId());
57 }
58
59
60
61
62 @Test
63 public void RouteLogActionRequestSorterTest_AR2_Active() {
64 ActionRequestValue ar1 = new ActionRequestValue();
65 ActionRequestValue ar2 = new ActionRequestValue();
66
67 ar1.setActionRequestId("Test1");
68 ar1.setRouteLevel(1);
69 ar1.setStatus("I");
70
71 ar2.setActionRequestId("Test2");
72 ar2.setRouteLevel(1);
73 ar2.setStatus("A");
74
75 List<ActionRequestValue> actionRequestValues = new ArrayList<ActionRequestValue>();
76 actionRequestValues.add(ar1);
77 actionRequestValues.add(ar2);
78
79 Collections.sort(actionRequestValues, new Utilities.RouteLogActionRequestSorter());
80
81 assertEquals("Test2", actionRequestValues.get(0).getActionRequestId());
82 }
83
84
85
86
87
88 @Test
89 public void RouteLogActionRequestSorterTest_Both_Active() {
90 ActionRequestValue ar1 = new ActionRequestValue();
91 ActionRequestValue ar2 = new ActionRequestValue();
92 ActionRequestValue ar3 = new ActionRequestValue();
93
94 ar1.setActionRequestId("Test1");
95 ar1.setRouteLevel(1);
96 ar1.setStatus("A");
97 ar1.setPriority(1);
98
99 ar2.setActionRequestId("Test2");
100 ar2.setRouteLevel(1);
101 ar2.setStatus("A");
102 ar2.setPriority(2);
103
104 ar3.setActionRequestId("Test3");
105 ar3.setRouteLevel(1);
106 ar3.setStatus("I");
107
108 List<ActionRequestValue> actionRequestValues = new ArrayList<ActionRequestValue>();
109 actionRequestValues.add(ar1);
110 actionRequestValues.add(ar2);
111 actionRequestValues.add(ar3);
112
113 Collections.sort(actionRequestValues, new Utilities.RouteLogActionRequestSorter());
114
115 assertEquals("Test1", actionRequestValues.get(0).getActionRequestId());
116 assertEquals("Test2", actionRequestValues.get(1).getActionRequestId());
117 assertEquals("Test3", actionRequestValues.get(2).getActionRequestId());
118 }
119 }