001    /**
002     * Copyright 2005-2011 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     */
016    
017    package edu.samplu.admin.test;
018    
019    import static org.junit.Assert.assertEquals;
020    
021    import org.junit.Test;
022    
023    import edu.samplu.common.AdminMenuLegacyITBase;
024    import edu.samplu.common.ITUtil;
025    
026    /**
027     * @author Kuali Rice Team (rice.collab@kuali.org)
028     */
029    public class PermissionLegacyIT extends AdminMenuLegacyITBase {
030    
031        String docId;
032        String permissionName;
033    
034        @Override
035        protected String getLinkLocator() {
036            return "Permission";
037        }
038        
039        @Test
040        public void testPerson() throws Exception {
041            super.gotoCreateNew();
042            waitForPageToLoad();
043            Thread.sleep(2000);
044            /*assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']",
045                    "save button does not exist on the page");*/
046            waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
047            docId = getTextByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
048            waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
049            waitForPageToLoad();
050            assertElementPresentByXpath("//div[contains(.,'Document Description (Description) is a required field.')]/img[@alt='error']");
051            waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Adding Permission removeme");
052            waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
053            waitForPageToLoad();
054            assertElementPresentByXpath("//div[@class='error']");
055            assertElementPresentByXpath("//div[contains(.,'Template (Template) is a required field.')]/img[@alt='error']");
056            assertElementPresentByXpath("//div[contains(.,'Permission Namespace (Permission Namespace) is a required field.')]/img[@alt='error']");
057            assertElementPresentByXpath("//div[contains(.,'Permission Name (Permission Name) is a required field.')]/img[@alt='error']");
058            System.out.println("------------------------------------Validation Test Successful--------------------------");
059            
060            
061            selectOptionByName("document.newMaintainableObject.templateId", "36");
062            selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-SYS");
063            permissionName = "removeme" + ITUtil.DTS_TWO;
064            waitAndTypeByName("document.newMaintainableObject.name", permissionName);
065            waitAndTypeByName("document.newMaintainableObject.description", "namespaceCode=KR*");
066            checkByName("document.newMaintainableObject.active");
067            waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
068            waitForPageToLoad();
069            assertElementPresentByXpath("//div[contains(div,'Document was successfully saved.')]");
070            assertEquals("SAVED", getTextByXpath("//table[@class='headerinfo']//tr[1]/td[2]"));
071            waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
072            waitForPageToLoad();
073            assertElementPresentByXpath("//div[contains(div,'Document was successfully submitted.')]",
074                    "Document is not submitted successfully");
075            assertEquals("ENROUTE", getTextByXpath("//table[@class='headerinfo']//tr[1]/td[2]"));
076            System.out.println("------------------------------------Permission document submitted successfully--------------------------");
077            
078            selectTopFrame();
079            super.gotoMenuLinkLocator();
080            waitForPageToLoad();
081            waitAndTypeByName("name", permissionName);
082            waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
083            isElementPresentByLinkText(permissionName);
084            System.out.println("----------------------------------Lookup successful-----------------------------");
085            
086            waitAndClickByLinkText("edit");
087            waitForPageToLoad();
088            Thread.sleep(2000);
089            waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Editing Permission removeme");
090            uncheckByName("document.newMaintainableObject.active");
091            waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
092            waitForPageToLoad();
093            assertElementPresentByXpath("//div[contains(div,'Document was successfully submitted.')]",
094                    "Document is not submitted successfully");
095            System.out.println("------------------------------------Inactivation of Permission successfull--------------------------");
096            
097            selectTopFrame();
098            super.gotoMenuLinkLocator();
099            waitForPageToLoad();
100            waitAndTypeByName("name", permissionName);
101            waitAndClickByXpath("//input[@title='Active Indicator - No']");
102            waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
103            isElementPresentByLinkText(permissionName);
104            
105    
106            
107        }
108    
109    }