1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.travel.application;
17
18 import org.apache.commons.lang.RandomStringUtils;
19 import org.junit.Test;
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21 import org.kuali.rice.testtools.selenium.WebDriverUtils;
22
23
24
25
26 public class DemoTravelCompanyCompletionRequestAft extends WebDriverLegacyITBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/maintenance?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelCompany";
32
33 private static final String DOC_HANDLER_URL = "/kew/DocHandler.do?command=displayDocSearchView&docId=";
34 private static final String USER1_PRINCIPAL_NAME = "user1";
35 private static final String ADMIN_PRINCIPAL_NAME = "admin";
36
37 private static final String FINAL = "FINAL";
38 private static final String CANCELED = "CANCELED";
39
40 private static final String COMPLETE = "Complete";
41 private static final String UCANCEL = "ucancel";
42 private static final String CANCEL = "Cancel";
43 private static final String APPROVE = "Approve";
44 private static final String DISAPPROVE = "Disapprove";
45 private static final String BLANKET_APPROVE = "Blanket Approve";
46 private static final String SUPER_USER_ACTIONS = "Super User Actions";
47
48 public static final String DESCRIPTION_FIELD = "document.documentHeader.documentDescription";
49 public static final String COMPANY_NAME_FIELD = "document.newMaintainableObject.dataObject.travelCompanyName";
50
51 @Override
52 public String getBookmarkUrl() {
53 return BOOKMARK_URL;
54 }
55
56 protected void navigate() throws Exception {
57 waitAndClickDemoLink();
58 waitAndClickByLinkText("Travel Company Lookup");
59 waitAndClickByLinkText("Create New");
60 }
61
62 @Override
63 public String getUserName() {
64 if ((testName.getMethodName().equals("testDemoTravelCompanyCompletionRequestForAdminBookmark"))||
65 (testName.getMethodName().equals("testDemoTravelCompanyCompletionRequestForAdminNav"))) {
66 return USER1_PRINCIPAL_NAME;
67 } else {
68 return super.getUserName();
69 }
70 }
71
72 private void openTravelCompanyDoc(String documentNumber, String principalName) throws Exception {
73 open(getBaseUrlString() + "/portal.do");
74 impersonateUser(principalName);
75
76 open(getBaseUrlString() + DOC_HANDLER_URL + documentNumber);
77 }
78
79 protected void travelAccountCreateDocument(String principalName) throws Exception {
80 waitAndTypeByName(DESCRIPTION_FIELD,"Travel Company Super User Test");
81 String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
82 waitAndTypeByName(COMPANY_NAME_FIELD, "Company Name " + randomCode);
83
84 waitAndClickByLinkText("Ad Hoc Recipients");
85 waitAndTypeByName("newCollectionLines['document.adHocRoutePersons'].actionRequested", "Complete");
86 waitAndTypeByName("newCollectionLines['document.adHocRoutePersons'].id", principalName);
87 jGrowl("Click Add button");
88 waitAndClickById("Uif-AdHocPersonCollection_add");
89 waitForElementPresentByXpath(
90 "//div[@data-parent=\"Uif-AdHocPersonCollection\"]/div/span[contains(text(), principalName]");
91 waitAndClickByLinkText("Ad Hoc Recipients");
92
93 waitAndClickSubmitByText();
94 waitAndClickConfirmSubmitOk();
95 waitForProgress("Loading...", WebDriverUtils.configuredImplicityWait() * 4);
96 waitForTextPresent("Document was successfully submitted.", WebDriverUtils.configuredImplicityWait() * 2);
97 }
98
99 protected void testDemoTravelCompanyCompletionRequestForAdmin() throws Exception {
100 String documentNumber = waitForDocIdKrad();
101
102 travelAccountCreateDocument(ADMIN_PRINCIPAL_NAME);
103
104 openTravelCompanyDoc(documentNumber, ADMIN_PRINCIPAL_NAME);
105
106
107 waitAndTypeByName(COMPANY_NAME_FIELD, " Extra");
108
109
110
111 Thread.sleep(3000);
112 waitAndClickByLinkText(SUPER_USER_ACTIONS);
113 verifyButtons();
114 waitAndClickButtonByText(COMPLETE);
115 waitForProgress("Loading...", WebDriverUtils.configuredImplicityWait() * 8);
116
117 ReloadAndCheckDocStatus(FINAL);
118 }
119
120 protected void testDemoTravelCompanyCompletionRequestForUser1() throws Exception {
121 String documentNumber = waitForDocIdKrad();
122
123 travelAccountCreateDocument(USER1_PRINCIPAL_NAME);
124
125
126 waitAndClickByLinkText(SUPER_USER_ACTIONS);
127 waitForTextPresent(APPROVE);
128 waitForTextPresent(DISAPPROVE);
129
130 openTravelCompanyDoc(documentNumber, USER1_PRINCIPAL_NAME);
131
132
133 waitAndTypeByName(COMPANY_NAME_FIELD, " Extra");
134
135 assertTextNotPresent(SUPER_USER_ACTIONS);
136 verifyButtons();
137
138 waitAndClickButtonByText(COMPLETE);
139 waitForProgress("Loading...", WebDriverUtils.configuredImplicityWait() * 8);
140
141 ReloadAndCheckDocStatus(FINAL);
142 }
143
144 protected void testDemoTravelCompanyCompletionRequestForUser1Cancel() throws Exception {
145 String documentNumber = waitForDocIdKrad();
146
147 travelAccountCreateDocument(USER1_PRINCIPAL_NAME);
148
149 openTravelCompanyDoc(documentNumber, USER1_PRINCIPAL_NAME);
150
151 Thread.sleep(2000);
152 verifyButtons();
153
154 waitAndClickById(UCANCEL);
155 waitAndClickByXpath("//div[@data-parent='ConfirmCancelDialog']/button[contains(text(),'OK')]");
156 Thread.sleep(2000);
157
158 openTravelCompanyDoc(documentNumber, USER1_PRINCIPAL_NAME);
159 assertTextPresent(CANCELED);
160 }
161
162 private void ReloadAndCheckDocStatus(String docStatus) throws Exception {
163 waitAndClickButtonByText("Reload");
164 waitForProgressLoading();
165 waitForTextPresent("Document was successfully reloaded.");
166 assertTextPresent(docStatus);
167 }
168
169 private void verifyButtons() throws Exception {
170 Thread.sleep(3000);
171 assertTextNotPresent(APPROVE);
172 assertTextNotPresent(DISAPPROVE);
173 assertTextNotPresent(BLANKET_APPROVE);
174 assertTextPresent(CANCEL);
175 assertTextPresent(COMPLETE);
176 }
177
178 @Test
179 public void testDemoTravelCompanyCompletionRequestForUser1Bookmark() throws Exception {
180 testDemoTravelCompanyCompletionRequestForUser1();
181 passed();
182 }
183
184 @Test
185 public void testDemoTravelCompanyCompletionRequestForUser1Nav() throws Exception {
186 testDemoTravelCompanyCompletionRequestForUser1();
187 passed();
188 }
189
190 @Test
191 public void testDemoTravelCompanyCompletionRequestForAdminBookmark() throws Exception {
192 testDemoTravelCompanyCompletionRequestForAdmin();
193 passed();
194 }
195
196 @Test
197 public void testDemoTravelCompanyCompletionRequestForAdminNav() throws Exception {
198 testDemoTravelCompanyCompletionRequestForAdmin();
199 passed();
200 }
201
202 @Test
203 public void testDemoTravelCompanyCompletionRequestForUser1CancelBookmark() throws Exception {
204 testDemoTravelCompanyCompletionRequestForUser1Cancel();
205 passed();
206 }
207
208 @Test
209 public void testDemoTravelCompanyCompletionRequestForUser1CancelNav() throws Exception {
210 testDemoTravelCompanyCompletionRequestForUser1Cancel();
211 passed();
212 }
213 }