001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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: package org.kuali.module.vendor.fixtures;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.kuali.kfs.KFSConstants;
022: import org.kuali.kfs.bo.Country;
023: import org.kuali.kfs.bo.State;
024: import org.kuali.module.vendor.bo.VendorAddress;
025: import org.kuali.module.vendor.fixtures.VendorTestConstants.StatesZips;
026:
027: public enum VendorRuleAddressStateZipFixture {
028:
029: BOTH_US_BOTH_STATES_BOTH_ZIPS(
030: KFSConstants.COUNTRY_CODE_UNITED_STATES,
031: StatesZips.stateCd, StatesZips.zipCode,
032: KFSConstants.COUNTRY_CODE_UNITED_STATES,
033: StatesZips.stateCd, StatesZips.zipCode), BOTH_US_WITHOUT_STATES_WITHOUT_ZIPS(
034: KFSConstants.COUNTRY_CODE_UNITED_STATES, null, null,
035: KFSConstants.COUNTRY_CODE_UNITED_STATES, null, null), BOTH_US_EMPTY_STATES_EMPTY_ZIPS(
036: KFSConstants.COUNTRY_CODE_UNITED_STATES, "", "",
037: KFSConstants.COUNTRY_CODE_UNITED_STATES, "", ""), BOTH_US_BOTH_STATES_ONE_ZIP_ONE_NULL(
038: KFSConstants.COUNTRY_CODE_UNITED_STATES,
039: StatesZips.stateCd, StatesZips.zipCode,
040: KFSConstants.COUNTRY_CODE_UNITED_STATES,
041: StatesZips.stateCd, null), BOTH_US_BOTH_STATES_ONE_ZIP_ONE_EMPTY(
042: KFSConstants.COUNTRY_CODE_UNITED_STATES,
043: StatesZips.stateCd, StatesZips.zipCode,
044: KFSConstants.COUNTRY_CODE_UNITED_STATES,
045: StatesZips.stateCd, ""), WITHOUT_US_BOTH_STATES_WITHOUT_ZIPS(
046: "", StatesZips.stateCd, null, "", StatesZips.stateCd, null), WITHOUT_US_BOTH_STATES_EMPTY_ZIPS(
047: "", StatesZips.stateCd, "", "", StatesZips.stateCd, ""), WITHOUT_US_BOTH_STATES_BOTH_ZIPS(
048: "", StatesZips.stateCd, StatesZips.zipCode, "",
049: StatesZips.stateCd, StatesZips.zipCode), ;
050:
051: private State state = new State();
052: private Country country = new Country();
053: private String country1;
054: private String stateCd1;
055: private String zip1;
056: private String country2;
057: private String stateCd2;
058: private String zip2;
059:
060: private VendorRuleAddressStateZipFixture(String country1,
061: String stateCd1, String zip1, String country2,
062: String stateCd2, String zip2) {
063: this .country1 = country1;
064: this .stateCd1 = stateCd1;
065: this .zip1 = zip1;
066: this .country2 = country2;
067: this .stateCd2 = stateCd2;
068: this .zip2 = zip2;
069: }
070:
071: /**
072: * This method does the setup for the tests which examine the implementation of the requirement that, if a vendor address's
073: * country is the United States, the address must have a state and a zip code.
074: *
075: * @param country1 Any String, really, but possibly a country value from KFSConstants.
076: * @param zip1 Also any String, intended to be a Zip code.
077: * @param country2 Country for the second address of the collection
078: * @param zip2 Zip code for the second address of the collection
079: * @return A List<VendorAddress>, appropriately populated with countries and zip codes.
080: */
081: @SuppressWarnings("deprecation")
082: public List<VendorAddress> populateAddresses() {
083: List<VendorAddress> addrList = new ArrayList();
084: VendorAddress addr1 = new VendorAddress();
085: VendorAddress addr2 = new VendorAddress();
086: state.setPostalStateCode(stateCd1);
087: country.setPostalCountryCode(country1);
088: addr1.setVendorCountry(country);
089: addr1.setVendorState(state);
090: addr1.setVendorZipCode(zip1);
091: country.setPostalCountryCode(country2);
092: addr2.setVendorCountry(country);
093: state.setPostalStateCode(stateCd2);
094: addr2.setVendorState(state);
095: addr2.setVendorZipCode(zip2);
096: addrList.add(addr1);
097: addrList.add(addr2);
098: return addrList;
099: }
100: }
|