View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.admin.config.namespace.pending;
17  
18  import edu.sampleu.admin.AdminTmplMthdAftNavBase;
19  import org.apache.commons.lang.RandomStringUtils;
20  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  
26  public abstract class PendingBase extends AdminTmplMthdAftNavBase {
27      /**
28       * methodToCall.insertAdHocRoutePerson
29       */
30      protected static final String ADD_PERSON_ELEMENT_NAME = "methodToCall.insertAdHocRoutePerson";
31  
32      /**
33       * newAdHocRoutePerson.id
34       */
35      protected static final String ADD_PERSON_TEXT_ELEMENT_NAME = "newAdHocRoutePerson.id";
36  
37      /**
38       * methodToCall.toggleTab.tabAdHocRecipients
39       */
40      protected static final String DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE = "methodToCall.toggleTab.tabAdHocRecipients";
41      /**
42       * document.documentHeader.documentDescription
43       */
44      protected static final String DOCUMENT_DESCRIPTION_NAME = "document.documentHeader.documentDescription";
45  
46      /**
47       * document.newMaintainableObject.code
48       */
49      protected static final String DOCUMENT_CODE_NAME = "document.newMaintainableObject.code";
50  
51      /**
52       * document.newMaintainableObject.name
53       */
54      protected static final String DOCUMENT_NAME = "document.newMaintainableObject.name";
55  
56      /**
57       * document.newMaintainableObject.applicationId
58       */
59      protected static final String DOCUMENT_APPLICATIONID_NAME = "document.newMaintainableObject.applicationId";
60  
61      /**
62       * methodToCall.performLookup.(!!org.kuali.rice.kim.impl.group.GroupBo!!).(((namespaceCode:newAdHocRouteWorkgroup.recipientNamespaceCode,name:newAdHocRouteWorkgroup.recipientName))).((`newAdHocRouteWorkgroup.recipientNamespaceCode:namespaceCode,newAdHocRouteWorkgroup.recipientName:name`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor
63       */
64      protected static final String NAME_LOOKUP_COMPONENT_NAME ="methodToCall.performLookup.(!!org.kuali.rice.kim.impl.group.GroupBo!!).(((namespaceCode:newAdHocRouteWorkgroup.recipientNamespaceCode,name:newAdHocRouteWorkgroup.recipientName))).((`newAdHocRouteWorkgroup.recipientNamespaceCode:namespaceCode,newAdHocRouteWorkgroup.recipientName:name`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor";
65  
66      /**
67       * newAdHocRoutePerson.actionRequested
68       */
69      protected static final String NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED = "newAdHocRoutePerson.actionRequested";
70  
71      /**
72       * methodToCall.route
73       */
74      protected static final String SUBMIT_NAME = "methodToCall.route";
75  
76      protected void assertSuperGroup(String docId) throws InterruptedException {
77          // second checkbox (APPROVED)
78          waitAndClick("#tab-SuperUserAction-div > div:nth-child(2) > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > input:nth-child(1)");
79          waitAndTypeByName("superUserAnnotation","test suaction");
80          waitAndClickByName("methodToCall.takeSuperUserActions");
81          if(!isTextPresent("Group1")) {
82              assertTextPresent("superuser approved in Document " + docId);
83          } else {
84              fail("Super User Approve functionality may not be working.");
85          }
86      }
87          /**
88          * {@inheritDoc}
89          * Namespace
90          * @return
91          */
92      @Override
93      protected String getLinkLocator() {
94          return "Namespace";
95      }
96  
97      protected void fillInAddAdHocPersons(String[][] personsActions) throws Exception {
98          waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
99  
100         for (String[] personAction: personsActions) {
101             waitAndTypeByName(ADD_PERSON_TEXT_ELEMENT_NAME, personAction[0]);
102             if (personAction.length > 1) {
103                 selectByName(NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED, personAction[1]);
104             }
105             waitAndClickByName(ADD_PERSON_ELEMENT_NAME);
106             Thread.sleep(1000);
107         }
108     }
109 
110     protected void fillInAdHocGroups(String[][] groupsActions) throws Exception {
111         waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
112         for (String[] groupAction: groupsActions) {
113             waitAndClickByName(NAME_LOOKUP_COMPONENT_NAME);
114             waitAndTypeByName("name", groupAction[0]);
115             waitAndClickByXpath(SEARCH_XPATH);
116             waitAndClickByLinkText("return value");
117             if (groupAction.length > 1) {
118                 selectByName("newAdHocRouteWorkgroup.actionRequested", groupAction[1]);
119             }
120             waitAndClickByName("methodToCall.insertAdHocRouteWorkgroup");
121             Thread.sleep(1000);
122         }
123     }
124 
125     protected void fillInNamespaceOverview(String descBase, String codeNameBase, String nameBase, String appId) throws Exception {
126         selectFrameIframePortlet();
127         waitAndCreateNew();
128         waitAndTypeByName(DOCUMENT_DESCRIPTION_NAME, descBase + " " + AutomatedFunctionalTestUtils
129                 .createUniqueDtsPlusTwoRandomCharsNot9Digits());
130         String randomFour = RandomStringUtils.randomAlphabetic(4).toLowerCase();
131         waitAndTypeByName(DOCUMENT_CODE_NAME, codeNameBase + randomFour);
132         waitAndTypeByName(DOCUMENT_NAME, nameBase + randomFour);
133         waitAndTypeByName(DOCUMENT_APPLICATIONID_NAME, appId);
134     }
135 
136     protected String submitAndLookupDoc() throws InterruptedException {
137         waitAndClickByName(SUBMIT_NAME);
138         String docId= waitForDocId();
139         switchToWindow("Kuali Portal Index");
140         waitAndClickDocSearch();
141         selectFrameIframePortlet();
142         waitAndTypeByName("documentId", docId);
143         waitAndClickByXpath(SEARCH_XPATH);
144         waitForTextPresent("One item retrieved.", "Previous Document may have routing problem so the latest Document is not able to submit correctly.");
145         waitAndClickByLinkText(docId);
146         switchToWindow("Kuali :: Namespace");
147         return docId;
148     }
149 
150     protected void assertSuperPerson(String user, String action, String docId) throws InterruptedException {
151         waitAndClickByName("selectedActionRequests");
152         waitAndTypeByName("superUserAnnotation","test suaction");
153         waitAndClickByName("methodToCall.takeSuperUserActions");
154 
155         Thread.sleep(1000);
156         if(!isTextPresent(user)) {
157             assertTextPresent("superuser " + action + " in Document " + docId);
158         } else {
159             fail("Super User Approve functionality may not be working.");
160         }
161     }
162 }