001    package edu.sampleu.admin.config.namespace.pending;
002    
003    import edu.sampleu.admin.AdminTmplMthdAftNavBase;
004    import org.apache.commons.lang.RandomStringUtils;
005    import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
006    
007    /**
008     * @author Kuali Rice Team (rice.collab@kuali.org)
009     */
010    
011    public abstract class PendingBase extends AdminTmplMthdAftNavBase {
012        /**
013         * methodToCall.insertAdHocRoutePerson
014         */
015        protected static final String ADD_PERSON_ELEMENT_NAME = "methodToCall.insertAdHocRoutePerson";
016    
017        /**
018         * newAdHocRoutePerson.id
019         */
020        protected static final String ADD_PERSON_TEXT_ELEMENT_NAME = "newAdHocRoutePerson.id";
021    
022        /**
023         * methodToCall.toggleTab.tabAdHocRecipients
024         */
025        protected static final String DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE = "methodToCall.toggleTab.tabAdHocRecipients";
026        /**
027         * document.documentHeader.documentDescription
028         */
029        protected static final String DOCUMENT_DESCRIPTION_NAME = "document.documentHeader.documentDescription";
030    
031        /**
032         * document.newMaintainableObject.code
033         */
034        protected static final String DOCUMENT_CODE_NAME = "document.newMaintainableObject.code";
035    
036        /**
037         * document.newMaintainableObject.name
038         */
039        protected static final String DOCUMENT_NAME = "document.newMaintainableObject.name";
040    
041        /**
042         * document.newMaintainableObject.applicationId
043         */
044        protected static final String DOCUMENT_APPLICATIONID_NAME = "document.newMaintainableObject.applicationId";
045    
046        /**
047         * methodToCall.performLookup.(!!org.kuali.rice.kim.impl.group.GroupBo!!).(((namespaceCode:newAdHocRouteWorkgroup.recipientNamespaceCode,name:newAdHocRouteWorkgroup.recipientName))).((`newAdHocRouteWorkgroup.recipientNamespaceCode:namespaceCode,newAdHocRouteWorkgroup.recipientName:name`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor
048         */
049        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";
050    
051        /**
052         * newAdHocRoutePerson.actionRequested
053         */
054        protected static final String NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED = "newAdHocRoutePerson.actionRequested";
055    
056        /**
057         * methodToCall.route
058         */
059        protected static final String SUBMIT_NAME = "methodToCall.route";
060    
061        protected void assertSuperGroup(String docId) throws InterruptedException {
062            // second checkbox (APPROVED)
063            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)");
064            waitAndTypeByName("superUserAnnotation","test suaction");
065            waitAndClickByName("methodToCall.takeSuperUserActions");
066            if(!isTextPresent("Group1")) {
067                assertTextPresent("superuser approved in Document " + docId);
068            } else {
069                fail("Super User Approve functionality may not be working.");
070            }
071        }
072            /**
073            * {@inheritDoc}
074            * Namespace
075            * @return
076            */
077        @Override
078        protected String getLinkLocator() {
079            return "Namespace";
080        }
081    
082        protected void fillInAddAdHocPersons(String[][] personsActions) throws Exception {
083            waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
084    
085            for (String[] personAction: personsActions) {
086                waitAndTypeByName(ADD_PERSON_TEXT_ELEMENT_NAME, personAction[0]);
087                if (personAction.length > 1) {
088                    selectByName(NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED, personAction[1]);
089                }
090                waitAndClickByName(ADD_PERSON_ELEMENT_NAME);
091                Thread.sleep(1000);
092            }
093        }
094    
095        protected void fillInAdHocGroups(String[][] groupsActions) throws Exception {
096            waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE);
097            for (String[] groupAction: groupsActions) {
098                waitAndClickByName(NAME_LOOKUP_COMPONENT_NAME);
099                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    }