1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.admin.workflow;
17
18 import org.apache.commons.lang.RandomStringUtils;
19 import org.junit.Test;
20 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
21 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
22 import org.kuali.rice.testtools.selenium.WebDriverUtils;
23 import org.openqa.selenium.By;
24 import org.openqa.selenium.WebDriver;
25
26 import java.text.SimpleDateFormat;
27 import java.util.Date;
28
29
30
31
32 public class DocumentOperationAft extends WebDriverLegacyITBase {
33
34
35
36
37
38 public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Document%20Operation&channelUrl="+ WebDriverUtils
39 .getBaseUrlString()+"/kew/DocumentOperation.do";
40
41 private static String documentId = null;
42
43 @Override
44 protected String getBookmarkUrl() {
45 return BOOKMARK_URL;
46 }
47
48 @Override
49 protected void navigate() throws InterruptedException {
50 waitAndClickAdministration();
51 waitAndClickByLinkText("Document Operation");
52 }
53
54 protected void testCreateDocument() throws Exception {
55 waitForPageToLoad();
56 waitAndClickAdministration();
57 waitAndClickByLinkText("Document Type");
58 selectFrameIframePortlet();
59 waitAndClickByXpath("//a[@title='Create a new record']");
60 selectFrameIframePortlet();
61 String randomString = RandomStringUtils.randomAlphabetic(9).toUpperCase();
62 documentId = getTextByXpath("//table[@summary='document header: general information']/tbody/tr/td");
63 waitAndTypeByName("document.documentHeader.documentDescription",randomString);
64 waitAndTypeByName("document.newMaintainableObject.name",randomString);
65 waitAndTypeByName("document.newMaintainableObject.label","Label "+randomString);
66 waitAndClickByName("methodToCall.route");
67 waitForTextPresent("Document was successfully submitted.");
68 selectParentWindow();
69 waitAndClickAdministration();
70 acceptAlertIfPresent();
71 waitForPageToLoad();
72 waitAndClickByLinkText("Document Operation");
73 }
74
75 protected void testDocumentOperation() throws Exception {
76 waitForPageToLoad();
77 selectFrameIframePortlet();
78 if(documentId!=null) {
79 waitAndTypeByName("documentId", documentId);
80 waitAndClickByName("methodToCall.getDocument");
81 waitForElementPresentByXpath("//input[@src='images/buttonsmall_save.gif']");
82 assertTextPresent(
83 new String[] {"Document Actions", "Queue Document", "Queue Action Invocation", "Document ID:",
84 documentId});
85 }
86 }
87
88
89
90
91
92 protected void testDocumentOperationDisapprove() throws Exception {
93 waitAndClickMainMenu();
94 String docId = createTestEdocLite();
95 if (docId == null || "".equals(docId)) {
96 fail("Returned document id is empty or null!");
97 }
98
99 disapproveDocViaDocOpScreen(docId);
100 validateDocDisapprovedViaRouteLog(docId);
101 }
102
103
104
105
106
107
108 private void validateDocDisapprovedViaRouteLog(String docId) throws Exception {
109 jGrowl("Redirecting to portal screen");
110 driver.get(WebDriverUtils.getBaseUrlString());
111 waitAndClickDocSearch();
112 selectFrameIframePortlet();
113 waitAndTypeByName("documentId", docId);
114 waitAndClickSearch();
115 jGrowl("Clicking Route Log link.");
116 waitAndClickByXpath("//*[@id=\"row\"]/tbody/tr/td[7]/a/img");
117 assertTextPresent("DISAPPROVED");
118 }
119
120
121
122
123
124
125 private void disapproveDocViaDocOpScreen(String docId) throws Exception {
126 jGrowl("Redirecting to portal screen");
127 driver.get(WebDriverUtils.getBaseUrlString());
128 waitAndClickAdministration();
129 waitAndClickByLinkText("Document Operation");
130 selectFrameIframePortlet();
131 waitAndTypeByName("documentId", docId);
132 waitAndClickByName("methodToCall.getDocument");
133 jGrowl("Clicking Update Radio Button");
134 waitAndClickByXpath("//*[@id=\"kualiForm\"]/table/tbody/tr/td[2]/table[2]/tbody/tr[5]/td[2]/table/tbody/tr[2]/td[2]/input[1]");
135 selectByName("routeHeader.docRouteStatus", "DISAPPROVED");
136
137 jGrowl("Clicking Update Radio on Action Request");
138 waitAndClickByXpath("//*[@id=\"kualiForm\"]/table/tbody/tr/td[2]/table[2]/tbody/tr[6]/td[2]/table/tbody/tr[2]/td[2]/input[1]");
139 jGrowl("Selecting DONE status for action request.");
140 selectByName("actionRequests[0].status", "DONE");
141
142 jGrowl("Clicking delete radio on Action Item");
143 waitAndClickByXpath("//*[@id=\"kualiForm\"]/table/tbody/tr/td[2]/table[2]/tbody/tr[8]/td[2]/table/tbody/tr[2]/td[2]/input[2]");
144
145 jGrowl("Clicking the Save button.");
146 waitAndClickByXpath("//*[@id=\"kualiForm\"]/table/tbody/tr/td[2]/table[2]/tbody/tr[12]/td[2]/table/tbody/tr/th/div/input");
147 }
148
149
150
151
152
153
154 private String createTestEdocLite() throws Exception {
155 waitAndClickByLinkText("eDoc Lite");
156 selectFrameIframePortlet();
157 waitAndTypeByName("edlName", "eDoc.Example1Doctype");
158 waitAndClickSearch();
159 waitAndClickByLinkText("Create Document");
160 waitAndTypeByName("userName", "Test User");
161 waitAndTypeByName("rqstDate", getDateToday());
162 waitAndSelectByName("campus", "IUPUI");
163 waitAndTypeByName("addText", "This is a sample note.");
164 jGrowl("Click Note Save Button");
165 waitAndClickByXpath("//*[@id=\"edoclite\"]/table[2]/tbody/tr[3]/td[4]/div/img");
166 selectFrameIframePortlet();
167 jGrowl("Getting the document id.");
168 String docId = getText(By.xpath("/html/body/table[2]/tbody/tr/td[2]/table/tbody/tr[4]/td[2]"));
169 jGrowl("Document id is: " + docId);
170 jGrowl("Click Edoc Lite Save Button.");
171 waitAndClickByXpath("//*[@id=\"edoclite\"]/table[3]/tbody/tr/td/input[2]");
172 return docId;
173 }
174
175 @Test
176 public void testDocumentOperationBookmark() throws Exception {
177 testCreateDocument();
178 testDocumentOperation();
179 passed();
180 }
181
182 @Test
183 public void testDocumentOperationNav() throws Exception {
184 testCreateDocument();
185 testDocumentOperation();
186 passed();
187 }
188
189
190
191
192
193 @Test
194 public void testDocumentOperationDisapproveBookmark() throws Exception {
195 testDocumentOperationDisapprove();
196 passed();
197 }
198
199
200
201
202
203 @Test
204 public void testDocumentOperationDisapproveNav() throws Exception {
205 testDocumentOperationDisapprove();
206 passed();
207 }
208 }