View Javadoc

1   package edu.sampleu.admin.config.namespace.pending;
2   
3   import edu.sampleu.admin.AdminTmplMthdAftNavBase;
4   import org.apache.commons.lang.RandomStringUtils;
5   import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
6   
7   /**
8    * @author Kuali Rice Team (rice.collab@kuali.org)
9    */
10  
11  public abstract class PendingBase extends AdminTmplMthdAftNavBase {
12      /**
13       * methodToCall.insertAdHocRoutePerson
14       */
15      protected static final String ADD_PERSON_ELEMENT_NAME = "methodToCall.insertAdHocRoutePerson";
16  
17      /**
18       * newAdHocRoutePerson.id
19       */
20      protected static final String ADD_PERSON_TEXT_ELEMENT_NAME = "newAdHocRoutePerson.id";
21  
22      /**
23       * methodToCall.toggleTab.tabAdHocRecipients
24       */
25      protected static final String DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE = "methodToCall.toggleTab.tabAdHocRecipients";
26      /**
27       * document.documentHeader.documentDescription
28       */
29      protected static final String DOCUMENT_DESCRIPTION_NAME = "document.documentHeader.documentDescription";
30  
31      /**
32       * document.newMaintainableObject.code
33       */
34      protected static final String DOCUMENT_CODE_NAME = "document.newMaintainableObject.code";
35  
36      /**
37       * document.newMaintainableObject.name
38       */
39      protected static final String DOCUMENT_NAME = "document.newMaintainableObject.name";
40  
41      /**
42       * document.newMaintainableObject.applicationId
43       */
44      protected static final String DOCUMENT_APPLICATIONID_NAME = "document.newMaintainableObject.applicationId";
45  
46      /**
47       * methodToCall.performLookup.(!!org.kuali.rice.kim.impl.group.GroupBo!!).(((namespaceCode:newAdHocRouteWorkgroup.recipientNamespaceCode,name:newAdHocRouteWorkgroup.recipientName))).((`newAdHocRouteWorkgroup.recipientNamespaceCode:namespaceCode,newAdHocRouteWorkgroup.recipientName:name`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor
48       */
49      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";
50  
51      /**
52       * newAdHocRoutePerson.actionRequested
53       */
54      protected static final String NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED = "newAdHocRoutePerson.actionRequested";
55  
56      /**
57       * methodToCall.route
58       */
59      protected static final String SUBMIT_NAME = "methodToCall.route";
60  
61      protected void assertSuperGroup(String docId) throws InterruptedException {
62          // second checkbox (APPROVED)
63          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)");
64          waitAndTypeByName("superUserAnnotation","test suaction");
65          waitAndClickByName("methodToCall.takeSuperUserActions");
66          if(!isTextPresent("Group1")) {
67              assertTextPresent("superuser approved in Document " + docId);
68          } else {
69              fail("Super User Approve functionality may not be working.");
70          }
71      }
72          /**
73          * {@inheritDoc}
74          * Namespace
75          * @return
76          */
77      @Override
78      protected String getLinkLocator() {
79          return "Namespace";
80      }
81  
82      protected void fillInAddAdHocPersons(String[][] personsActions) throws Exception {
83          waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
84  
85          for (String[] personAction: personsActions) {
86              waitAndTypeByName(ADD_PERSON_TEXT_ELEMENT_NAME, personAction[0]);
87              if (personAction.length > 1) {
88                  selectByName(NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED, personAction[1]);
89              }
90              waitAndClickByName(ADD_PERSON_ELEMENT_NAME);
91              Thread.sleep(1000);
92          }
93      }
94  
95      protected void fillInAdHocGroups(String[][] groupsActions) throws Exception {
96          waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
97          for (String[] groupAction: groupsActions) {
98              waitAndClickByName(NAME_LOOKUP_COMPONENT_NAME);
99              waitAndTypeByName("name", groupAction[0]);
100             waitAndClickByXpath(SEARCH_XPATH);
101             waitAndClickByLinkText("return value");
102             if (groupAction.length > 1) {
103                 selectByName("newAdHocRouteWorkgroup.actionRequested", groupAction[1]);
104             }
105             waitAndClickByName("methodToCall.insertAdHocRouteWorkgroup");
106             Thread.sleep(1000);
107         }
108     }
109 
110     protected void fillInNamespaceOverview(String descBase, String codeNameBase, String nameBase, String appId) throws Exception {
111         selectFrameIframePortlet();
112         waitAndCreateNew();
113         waitAndTypeByName(DOCUMENT_DESCRIPTION_NAME, descBase + " " + AutomatedFunctionalTestUtils
114                 .createUniqueDtsPlusTwoRandomCharsNot9Digits());
115         String randomFour = RandomStringUtils.randomAlphabetic(4).toLowerCase();
116         waitAndTypeByName(DOCUMENT_CODE_NAME, codeNameBase + randomFour);
117         waitAndTypeByName(DOCUMENT_NAME, nameBase + randomFour);
118         waitAndTypeByName(DOCUMENT_APPLICATIONID_NAME, appId);
119     }
120 
121     protected String submitAndLookupDoc() throws InterruptedException {
122         waitAndClickByName(SUBMIT_NAME);
123         String docId= waitForDocId();
124         switchToWindow("Kuali Portal Index");
125         waitAndClickDocSearch();
126         selectFrameIframePortlet();
127         waitAndTypeByName("documentId",docId);
128         waitAndClickByXpath(SEARCH_XPATH);
129         if(!isTextPresent("No values match this search.")) {
130             waitAndClickByLinkText(docId);
131             switchToWindow("Kuali :: Namespace");
132         } else {
133             fail("Previous Document may have routing problem so the latest Document is not able to submit correctly.");
134         }
135         return docId;
136     }
137 
138     protected void assertSuperPerson(String user, String action, String docId) throws InterruptedException {
139         waitAndClickByName("selectedActionRequests");
140         waitAndTypeByName("superUserAnnotation","test suaction");
141         waitAndClickByName("methodToCall.takeSuperUserActions");
142 
143         Thread.sleep(1000);
144         if(!isTextPresent(user)) {
145             assertTextPresent("superuser " + action + " in Document " + docId);
146         } else {
147             fail("Super User Approve functionality may not be working.");
148         }
149     }
150 }