001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package edu.sampleu.admin.config.namespace.pending; 017 018import edu.sampleu.admin.AdminTmplMthdAftNavBase; 019import org.apache.commons.lang.RandomStringUtils; 020import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils; 021 022/** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 026public abstract class PendingBase extends AdminTmplMthdAftNavBase { 027 /** 028 * methodToCall.insertAdHocRoutePerson 029 */ 030 protected static final String ADD_PERSON_ELEMENT_NAME = "methodToCall.insertAdHocRoutePerson"; 031 032 /** 033 * newAdHocRoutePerson.id 034 */ 035 protected static final String ADD_PERSON_TEXT_ELEMENT_NAME = "newAdHocRoutePerson.id"; 036 037 /** 038 * methodToCall.toggleTab.tabAdHocRecipients 039 */ 040 protected static final String DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE = "methodToCall.toggleTab.tabAdHocRecipients"; 041 /** 042 * document.documentHeader.documentDescription 043 */ 044 protected static final String DOCUMENT_DESCRIPTION_NAME = "document.documentHeader.documentDescription"; 045 046 /** 047 * document.newMaintainableObject.code 048 */ 049 protected static final String DOCUMENT_CODE_NAME = "document.newMaintainableObject.code"; 050 051 /** 052 * document.newMaintainableObject.name 053 */ 054 protected static final String DOCUMENT_NAME = "document.newMaintainableObject.name"; 055 056 /** 057 * document.newMaintainableObject.applicationId 058 */ 059 protected static final String DOCUMENT_APPLICATIONID_NAME = "document.newMaintainableObject.applicationId"; 060 061 /** 062 * methodToCall.performLookup.(!!org.kuali.rice.kim.impl.group.GroupBo!!).(((namespaceCode:newAdHocRouteWorkgroup.recipientNamespaceCode,name:newAdHocRouteWorkgroup.recipientName))).((`newAdHocRouteWorkgroup.recipientNamespaceCode:namespaceCode,newAdHocRouteWorkgroup.recipientName:name`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor 063 */ 064 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"; 065 066 /** 067 * newAdHocRoutePerson.actionRequested 068 */ 069 protected static final String NEW_AD_HOC_ROUTE_PERSON_ACTION_REQUESTED = "newAdHocRoutePerson.actionRequested"; 070 071 /** 072 * methodToCall.route 073 */ 074 protected static final String SUBMIT_NAME = "methodToCall.route"; 075 076 protected void assertSuperGroup(String docId) throws InterruptedException { 077 // second checkbox (APPROVED) 078 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)"); 079 waitAndTypeByName("superUserAnnotation","test suaction"); 080 waitAndClickByName("methodToCall.takeSuperUserActions"); 081 if(!isTextPresent("Group1")) { 082 assertTextPresent("superuser approved in Document " + docId); 083 } else { 084 fail("Super User Approve functionality may not be working."); 085 } 086 } 087 /** 088 * {@inheritDoc} 089 * Namespace 090 * @return 091 */ 092 @Override 093 protected String getLinkLocator() { 094 return "Namespace"; 095 } 096 097 protected void fillInAddAdHocPersons(String[][] personsActions) throws Exception { 098 waitAndClickByName(DOCUMENT_AD_HOC_RECIPIENTS_TOGGLE); 099 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}