001/**
002 * Copyright 2005-2013 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.samplu.krad.demo.lookupviews.lookup.conditionalcriteria;
017
018import edu.samplu.common.Failable;
019import edu.samplu.common.SmokeTestBase;
020
021/**
022 * @author Kuali Rice Team (rice.collab@kuali.org)
023 */
024public class DemoLookUpConditionalCriteriaAbstractSmokeTestBase extends SmokeTestBase {
025
026    /**
027     * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true
028     */
029    public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true";
030    
031    /**
032     *  lookupCriteria[number]
033     */
034    private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
035    
036    /**
037     *  Search
038     */
039    private static final String SEARCH="Search";
040    
041    /**
042     *  lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
043     */
044    private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
045    
046    /**
047     *  Not read only. Date input field present.
048     */
049    private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
050    
051    /**
052     *  Date Created:
053     */
054    private static final String DATE_CREATED_MESSAGE="Date Created:";
055    
056    /**
057     *  Date Created is a required field.
058     */
059    private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
060    
061    @Override
062    public String getBookmarkUrl() {
063        return BOOKMARK_URL;
064    }
065
066    @Override
067    protected void navigate() throws Exception {
068        waitAndClickById("Demo-DemoLink", "");
069        waitAndClickByLinkText("Lookup Conditional Criteria");
070    }
071
072    protected void testLookUpConditionalCriteria() throws InterruptedException {
073        //Case 1 - Date field required by number a1
074        //It requires "Search" to be clicked twice, for showing message.
075        waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
076        waitAndClickButtonByText(SEARCH);
077        waitAndClickButtonByText(SEARCH);
078        Thread.sleep(3000);
079        assertTextPresent(DATE_REQUIRED_MESSAGE);
080        
081        //Case 2 - Date field read only by number a2
082        clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
083        waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a2");
084        waitAndClickButtonByText(SEARCH);
085        Thread.sleep(3000);
086        if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME))
087        {
088            fail(FAILURE_MESSAGE);
089        }
090        
091        //Case 3 - Date field hide by number a3
092        clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
093        waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a3");
094        waitAndClickButtonByText(SEARCH);
095        Thread.sleep(3000);
096        assertTextNotPresent(DATE_CREATED_MESSAGE);
097    }
098
099    public void testLookUpConditionalCriteriaBookmark(Failable failable) throws Exception {
100        testLookUpConditionalCriteria();
101        passed();
102    }
103
104    public void testLookUpConditionalCriteriaNav(Failable failable) throws Exception {
105        testLookUpConditionalCriteria();
106        passed();
107    }
108}