1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.quicklinks;
17
18 import org.junit.Test;
19 import org.kuali.rice.core.api.util.KeyValue;
20 import org.kuali.rice.kew.quicklinks.service.QuickLinksService;
21 import org.kuali.rice.kew.service.KEWServiceLocator;
22 import org.kuali.rice.kew.test.KEWTestCase;
23 import org.kuali.rice.test.BaselineTestCase;
24 import org.kuali.rice.test.SQLDataLoader;
25
26 import java.util.List;
27
28 import static org.junit.Assert.*;
29
30
31
32
33
34
35 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
36 public class QuickLinksServiceTest extends KEWTestCase {
37 private static String principalId = "admin";
38 private static String badPrincipalId = "joeshmoe";
39
40 private QuickLinksService service;
41
42 @Override
43 protected void loadTestData() throws Exception {
44 new SQLDataLoader("classpath:org/kuali/rice/kew/quicklinks/actionItem.sql", ";").runSql();
45 new SQLDataLoader("classpath:org/kuali/rice/kew/quicklinks/documentRoute.sql", ";").runSql();
46 new SQLDataLoader("classpath:org/kuali/rice/kew/quicklinks/documentType.sql", ";").runSql();
47 new SQLDataLoader("classpath:org/kuali/rice/kew/quicklinks/userOption.sql", ";").runSql();
48 }
49
50 @Override
51 protected void setUpAfterDataLoad() throws Exception {
52 service = (QuickLinksService) KEWServiceLocator.getService(KEWServiceLocator.QUICK_LINKS_SERVICE);
53 }
54
55 @Test
56 public void testGetActionListStats() {
57 List<ActionListStats> actionListStats = service.getActionListStats(principalId);
58 assertNotNull("No collection returned", actionListStats);
59 assertTrue("No test data", actionListStats.size() > 0);
60 assertEquals("Wrong number of Action List Stats", 3, actionListStats.size());
61 ActionListStats als = actionListStats.get(0);
62 assertEquals("Wrong count", 1, als.getCount());
63 assertEquals("Wrong Type Label", "Add/modify EDEN workgroup", als.getDocumentTypeLabelText());
64 assertEquals("Wrong Type name", "EDENSERVICE-DOCS.WKGRPREQ", als.getDocumentTypeName());
65 als = actionListStats.get(2);
66 assertEquals("Wrong count", 4, als.getCount());
67 assertEquals("Wrong Type Label", "Travel Request", als.getDocumentTypeLabelText());
68 assertEquals("Wrong Type name", "TravelRequest", als.getDocumentTypeName());
69
70 actionListStats = service.getActionListStats(badPrincipalId);
71 assertNotNull("No collection returned", actionListStats);
72 assertFalse("Found test data", actionListStats.size() > 0);
73 }
74
75 @Test
76 public void testGetWatchedDocuments() {
77 List<WatchedDocument> watchedDocuments = service.getWatchedDocuments(principalId);
78 assertNotNull("No collection returned", watchedDocuments);
79 assertTrue("No test data", watchedDocuments.size() > 0);
80 assertEquals("Wrong number of Watched Documents", 28, watchedDocuments.size());
81
82 WatchedDocument wd = watchedDocuments.get(0);
83 assertEquals("Wrong header id", "2694", wd.getDocumentHeaderId());
84 assertEquals("Wrong status code", "ENROUTE", wd.getDocumentStatusCode());
85 assertEquals("Wrong document title", "Travel Doc 2 - esdf", wd.getDocumentTitle());
86
87 wd = watchedDocuments.get(27);
88 assertEquals("Wrong header id", "2120", wd.getDocumentHeaderId());
89 assertEquals("Wrong status code", "ENROUTE", wd.getDocumentStatusCode());
90 assertEquals("Wrong document title", "Routing workgroup CreatinAGroup123", wd.getDocumentTitle());
91
92 watchedDocuments = service.getWatchedDocuments(badPrincipalId);
93 assertNotNull("No collection returned", watchedDocuments);
94 assertFalse("Found test data", watchedDocuments.size() > 0);
95 }
96
97 @Test
98 public void testGetRecentSearches() {
99 List<KeyValue> recentSearches = service.getRecentSearches(principalId);
100 assertNotNull("No collection returned", recentSearches);
101 assertTrue("No test data", recentSearches.size() > 0);
102 assertEquals("Wrong number of Recent Searches", 5, recentSearches.size());
103
104 KeyValue kv = recentSearches.get(0);
105 assertEquals("Wrong key", "DocSearch.LastSearch.Holding4", kv.getKey());
106 assertEquals("Wrong value", "Created=12/22/2008..;", kv.getValue().trim());
107
108 kv = recentSearches.get(4);
109 assertEquals("Wrong key", "DocSearch.LastSearch.Holding0", kv.getKey());
110 assertEquals("Wrong value", "Created=11/04/2008..;", kv.getValue().trim());
111
112 recentSearches = service.getRecentSearches(badPrincipalId);
113 assertNotNull("No collection returned", recentSearches);
114 assertFalse("Found test data", recentSearches.size() > 0);
115 }
116
117 @Test
118 public void testGetNamedSearches() {
119 List<KeyValue> namedSearches = service.getNamedSearches(principalId);
120 assertNotNull("No collection returned", namedSearches);
121 assertTrue("No test data", namedSearches.size() > 0);
122 assertEquals("Wrong number of Named Searches", 3, namedSearches.size());
123
124 KeyValue kv = namedSearches.get(0);
125 assertEquals("Wrong key", "DocSearch.NamedSearch.FindAlumni", kv.getKey());
126 assertEquals("Wrong value", "FindAlumni", kv.getValue());
127
128 kv = namedSearches.get(2);
129 assertEquals("Wrong key", "DocSearch.NamedSearch.FindStudent", kv.getKey());
130 assertEquals("Wrong value", "FindStudent", kv.getValue());
131
132 namedSearches = service.getRecentSearches(badPrincipalId);
133 assertNotNull("No collection returned", namedSearches);
134 assertFalse("Found test data", namedSearches.size() > 0);
135 }
136
137 @Test
138 public void testGetInitiatedDocumentTypesList() {
139 List<InitiatedDocumentType> initiatedDocumentTypesList = service.getInitiatedDocumentTypesList(principalId);
140 assertNotNull("No collection returned", initiatedDocumentTypesList);
141 assertTrue("No test data", initiatedDocumentTypesList.size() > 0);
142 assertEquals("Wrong number of Document Types List", 8, initiatedDocumentTypesList.size());
143
144 InitiatedDocumentType idt = initiatedDocumentTypesList.get(0);
145 assertEquals("Wrong Type Label Text", "Add/modify EDEN workgroup", idt.getDocumentTypeLabelText());
146 assertEquals("Wrong Type Name", "EDENSERVICE-DOCS.WKGRPREQ", idt.getDocumentTypeName());
147
148 idt = initiatedDocumentTypesList.get(7);
149 assertEquals("Wrong Type Label Text", "Travel Request", idt.getDocumentTypeLabelText());
150 assertEquals("Wrong Type Name", "TravelRequest", idt.getDocumentTypeName());
151
152
153 initiatedDocumentTypesList = service.getInitiatedDocumentTypesList(badPrincipalId);
154 assertNotNull("No collection returned", initiatedDocumentTypesList);
155 assertFalse("Found test data", initiatedDocumentTypesList.size() > 0);
156 }
157 }