View Javadoc

1   package edu.samplu.admin.config.namespace.pending;
2   
3   import edu.samplu.admin.test.AdminTmplMthdSTNavBase;
4   import edu.samplu.common.ITUtil;
5   import org.apache.commons.lang.RandomStringUtils;
6   
7   /**
8    * @author Kuali Rice Team (rice.collab@kuali.org)
9    */
10  
11  public abstract class PendingBase extends AdminTmplMthdSTNavBase {
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 + " " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits());
114         String randomFour = RandomStringUtils.randomAlphabetic(4).toLowerCase();
115         waitAndTypeByName(DOCUMENT_CODE_NAME, codeNameBase + randomFour);
116         waitAndTypeByName(DOCUMENT_NAME, nameBase + randomFour);
117         waitAndTypeByName(DOCUMENT_APPLICATIONID_NAME, appId);
118     }
119 
120     protected String submitAndLookupDoc() throws InterruptedException {
121         waitAndClickByName(SUBMIT_NAME);
122         String docId= waitForDocId();
123         switchToWindow("Kuali Portal Index");
124         waitAndClickDocSearch();
125         selectFrameIframePortlet();
126         waitAndTypeByName("documentId",docId);
127         waitAndClickByXpath(SEARCH_XPATH);
128         if(!isTextPresent("No values match this search.")) {
129             waitAndClickByLinkText(docId);
130             switchToWindow("Kuali :: Namespace");
131         } else {
132             fail("Previous Document may have routing problem so the latest Document is not able to submit correctly.");
133         }
134         return docId;
135     }
136 
137     protected void assertSuperPerson(String user, String action, String docId) throws InterruptedException {
138         waitAndClickByName("selectedActionRequests");
139         waitAndTypeByName("superUserAnnotation","test suaction");
140         waitAndClickByName("methodToCall.takeSuperUserActions");
141 
142         Thread.sleep(1000);
143         if(!isTextPresent(user)) {
144             assertTextPresent("superuser " + action + " in Document " + docId);
145         } else {
146             fail("Super User Approve functionality may not be working.");
147         }
148     }
149 }