View Javadoc
1   /**
2    * Copyright 2005-2016 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.main;
17  
18  import org.apache.commons.lang.RandomStringUtils;
19  import org.codehaus.plexus.util.StringUtils;
20  import org.junit.Test;
21  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
22  import org.kuali.rice.testtools.selenium.WebDriverUtils;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class TermMaintenanceEditCopyAft extends MainTmplMthdSTNavBase {
28  
29      /**
30       * ITUtil.PORTAL + "?Term%20Lookup&channelUrl=" + WebDriverUtils.getBaseUrlString() +
31       *  "/kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.repository.TermBo&returnLocation=" +
32       *  ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK;
33       */
34      public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Term%20Lookup&channelUrl=" + WebDriverUtils.getBaseUrlString()
35              + "/kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.repository.TermBo&returnLocation="
36              + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
37  
38      @Override
39      protected String getBookmarkUrl() {
40          return BOOKMARK_URL;
41      }
42  
43      /**
44       * {@inheritDoc}
45       * Term Lookup
46       * @return
47       */
48      @Override
49      protected String getLinkLocator() {
50          return "Term Lookup";
51      }
52  
53      protected void testCopyEditExistingTermWithParameter() throws InterruptedException {
54          // Copy an existing term to test copy and to ensure we don't edit term T1000
55          copyExistingTermWithParameter();
56  
57          // Edit a term
58          selectTopFrame();
59          waitAndClickByLinkText("Main Menu", "");
60          waitAndClickByLinkText("Term Lookup", "");
61          selectFrameIframePortlet();
62          waitAndTypeByName("lookupCriteria[id]", "1*");
63          waitAndClickByXpath("//button[contains(text(),'Search')]");
64          waitAndClickEdit();
65  
66          waitForTextPresent("campusSize");
67          waitForTextPresent("java.lang.Integer");
68          waitForElementPresentByXpath("//label[contains(text(),'Specification Description')]/span[contains(text(),'Size in # of students of the campus')]");
69          clearTextByName("document.newMaintainableObject.dataObject.description");
70          String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
71          waitAndTypeByName("document.newMaintainableObject.dataObject.description", "Edit Term - New ID "
72                  + StringUtils.substring(randomCode, 0, 4));
73          clearTextByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]");
74          waitAndTypeByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]",randomCode);
75          submitSuccessfully();
76          waitForTextPresent(randomCode);
77      }
78  
79      protected void copyExistingTermWithParameter() throws InterruptedException {
80          selectFrameIframePortlet();
81          waitAndTypeByName("lookupCriteria[id]", "T1000");
82          waitAndClickByXpath("//button[contains(text(),'Search')]");
83          waitAndClickCopy();
84          waitForTextPresent("BL");
85          String newRandomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
86          clearTextByName("document.newMaintainableObject.dataObject.description");
87          waitAndTypeByName("document.newMaintainableObject.dataObject.description", "Copy Term - Short ID "
88                  + StringUtils.substring(newRandomCode, 0, 4));
89          clearTextByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]");
90          waitAndTypeByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]", newRandomCode);
91          submitSuccessfully();
92          waitForTextPresent(newRandomCode);
93      }
94  
95      @Test
96      public void testCopyEditExistingTermWithParameterBookmark() throws Exception {
97          testCopyEditExistingTermWithParameter();
98          passed();
99      }
100 
101     @Test
102     public void testCopyEditExistingTermWithParameterNav() throws Exception {
103         testCopyEditExistingTermWithParameter();
104         passed();
105     }
106 }