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.main;
017
018import org.apache.commons.lang.RandomStringUtils;
019import org.codehaus.plexus.util.StringUtils;
020import org.junit.Test;
021import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
022import org.kuali.rice.testtools.selenium.WebDriverUtils;
023
024/**
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 */
027public class TermMaintenanceEditCopyAft extends MainTmplMthdSTNavBase {
028
029    /**
030     * ITUtil.PORTAL + "?Term%20Lookup&channelUrl=" + WebDriverUtils.getBaseUrlString() +
031     *  "/kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.repository.TermBo&returnLocation=" +
032     *  ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK;
033     */
034    public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Term%20Lookup&channelUrl=" + WebDriverUtils.getBaseUrlString()
035            + "/kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.repository.TermBo&returnLocation="
036            + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
037
038    @Override
039    protected String getBookmarkUrl() {
040        return BOOKMARK_URL;
041    }
042
043    /**
044     * {@inheritDoc}
045     * Term Lookup
046     * @return
047     */
048    @Override
049    protected String getLinkLocator() {
050        return "Term Lookup";
051    }
052
053    protected void testCopyEditExistingTermWithParameter() throws InterruptedException {
054        // Copy an existing term to test copy and to ensure we don't edit term T1000
055        copyExistingTermWithParameter();
056
057        // Edit a term
058        selectTopFrame();
059        waitAndClickByLinkText("Main Menu", "");
060        waitAndClickByLinkText("Term Lookup", "");
061        selectFrameIframePortlet();
062        waitAndTypeByName("lookupCriteria[id]", "1*");
063        waitAndClickByXpath("//button[contains(text(),'Search')]");
064        waitAndClickEdit();
065
066        waitForTextPresent("campusSize");
067        waitForTextPresent("java.lang.Integer");
068        waitForElementPresentByXpath("//label[contains(text(),'Specification Description')]/span[contains(text(),'Size in # of students of the campus')]");
069        clearTextByName("document.newMaintainableObject.dataObject.description");
070        String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
071        waitAndTypeByName("document.newMaintainableObject.dataObject.description", "Edit Term - New ID "
072                + StringUtils.substring(randomCode, 0, 4));
073        clearTextByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]");
074        waitAndTypeByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]",randomCode);
075        submitSuccessfully();
076        waitForTextPresent(randomCode);
077    }
078
079    protected void copyExistingTermWithParameter() throws InterruptedException {
080        selectFrameIframePortlet();
081        waitAndTypeByName("lookupCriteria[id]", "T1000");
082        waitAndClickByXpath("//button[contains(text(),'Search')]");
083        waitAndClickCopy();
084        waitForTextPresent("BL");
085        String newRandomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
086        clearTextByName("document.newMaintainableObject.dataObject.description");
087        waitAndTypeByName("document.newMaintainableObject.dataObject.description", "Copy Term - Short ID "
088                + StringUtils.substring(newRandomCode, 0, 4));
089        clearTextByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]");
090        waitAndTypeByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]", newRandomCode);
091        submitSuccessfully();
092        waitForTextPresent(newRandomCode);
093    }
094
095    @Test
096    public void testCopyEditExistingTermWithParameterBookmark() throws Exception {
097        testCopyEditExistingTermWithParameter();
098        passed();
099    }
100
101    @Test
102    public void testCopyEditExistingTermWithParameterNav() throws Exception {
103        testCopyEditExistingTermWithParameter();
104        passed();
105    }
106}