001/**
002 * Copyright 2005-2016 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.kim.api.location;
017
018import edu.sampleu.admin.AdminTmplMthdAftNavBlanketAppBase;
019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020import org.kuali.rice.testtools.selenium.WebDriverUtils;
021
022import java.util.Arrays;
023import java.util.List;
024
025/**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public class LocationCountryAft extends AdminTmplMthdAftNavBlanketAppBase {
029
030    public static final List<String> COUNTRY_CODES = Arrays.asList(
031            new String[] {"AW", "AG", "AF", "DZ", "AZ", "AL", "AM", "AD", "AO", "AS", "AR", "AU", "BF", "AT", "AI",
032                    "AQ", "BH", "BB", "BW", "BM", "BE", "BS", "BD", "BZ", "BA", "BO", "MM", "BJ", "BY", "SB", "BL",
033                    "BR", "MF", "BT", "BG", "BV", "BN", "BI", "CA", "KH", "TD", "LK", "CG", "CD", "CN", "CL", "KY",
034                    "CC", "CM", "KM", "CO", "MP", "GS", "CR", "CF", "CU", "CV", "CK", "CY", "DK", "DJ", "DM", "DO",
035                    "EC", "EG", "IE", "GQ", "EE", "ER", "SV", "ET", "TL", "CZ", "FK", "GF", "FI", "FJ", "FM", "FO",
036                    "PF", "AX", "FR", "TF", "GM", "GA", "GE", "GH", "GI", "GD", "GG", "GL", "DE", "GP", "GU", "GR",
037                    "GT", "GN", "GY", "PS", "HT", "HK", "HM", "HN", "HR", "HU", "IS", "ID", "IM", "IN", "IO", "IR",
038                    "IL", "IT", "CI", "IQ", "JP", "JE", "JM", "JO", "KE", "KG", "KP", "KI", "KR", "CX", "KW", "KZ",
039                    "LA", "LB", "LV", "LT", "LR", "SK", "LI", "LS", "LU", "LY", "MG", "MQ", "MO", "MD", "YT", "MN",
040                    "MS", "MW", "MK", "ML", "MC", "MA", "MU", "UM", "MR", "MT", "OM", "MV", "ME", "MX", "MY", "MZ",
041                    "AN", "NC", "NU", "NF", "NE", "VU", "NG", "NL", "NO", "NP", "NR", "SR", "NI", "NZ", "ZZ", "PY",
042                    "PN", "PE", "PK", "PL", "PA", "PT", "PG", "PW", "GW", "QA", "RE", "MH", "RO", "PH", "PR", "RU",
043                    "RW", "SA", "PM", "KN", "SC", "ZA", "SN", "SH", "SI", "SL", "SM", "SG", "SO", "ES", "RS", "LC",
044                    "SD", "SJ", "SE", "SY", "CH", "AE", "TT", "TH", "TJ", "TC", "TK", "TO", "TG", "ST", "TN", "TR",
045                    "TV", "TW", "TM", "TZ", "UG", "GB", "UA", "US", "UY", "UZ", "VC", "VE", "VG", "VN", "VI", "VA",
046                    "NA", "WF", "EH", "WS", "SZ", "YE", "ZM", "ZW"});
047
048    /**
049     * ITUtil.PORTAL + "?channelTitle=Country&channelUrl=" 
050     * + WebDriverUtils.getBaseUrlString() + ITUtil.KNS_LOOKUP_METHOD + "org.kuali.rice.location.impl.country.CountryBo&docFormKey=88888888&returnLocation=" +
051     * ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK;
052     */
053    public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Country&channelUrl="
054            + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KNS_LOOKUP_METHOD +
055            "org.kuali.rice.location.impl.country.CountryBo&docFormKey=88888888&returnLocation=" +
056            AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK ;
057
058    @Override
059    protected String getBookmarkUrl() {
060        return BOOKMARK_URL;
061    }
062
063    /**
064     * {@inheritDoc}
065     * Country
066     * @return
067     */
068    @Override
069    protected String getLinkLocator() {
070        return "Country";
071    }
072
073    @Override
074    protected void createNewEnterDetails() throws InterruptedException {
075        // Make sure we don't use an existing country abbreviation
076        getDescriptionUnique(); // trigger creating of uniqueString
077        while (COUNTRY_CODES.contains(uniqueString.substring(5, 7).toUpperCase())) {
078            uniqueString = null;
079            getDescriptionUnique(); // trigger creating of uniqueString
080        }
081
082        waitForElementPresentByName("document.documentHeader.documentDescription");
083
084        jiraAwareClearAndTypeByName("document.documentHeader.documentDescription", getDescriptionUnique());
085        jiraAwareClearAndTypeByName("document.newMaintainableObject.code", uniqueString.substring(5, 7));
086        jiraAwareClearAndTypeByName("document.newMaintainableObject.name", "name" + uniqueString);
087    }
088
089    @Override
090    protected void createNewLookupDetails() throws InterruptedException {
091        createNewEnterDetails(); // no required lookups
092    }
093}