01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.vendor.fixtures;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.module.vendor.bo.VendorAddress;
22: import org.kuali.module.vendor.bo.VendorDetail;
23: import org.kuali.module.vendor.bo.VendorType;
24: import org.kuali.module.vendor.fixtures.VendorTestConstants.AddressTypes;
25:
26: /**
27: * This is an enumeration of configurations of 'type codes' and 'address type codes' which should be useful for testing the code
28: * validating the implementation of the business rules involving Vendor address types.
29: */
30: public enum VendorRuleAddressTypeFixture {
31:
32: WITH_PO_TYPE_AND_PO_ADDR_TYPES(AddressTypes.poType,
33: AddressTypes.poType, true, AddressTypes.poType, false), WITH_DV_TYPE_AND_RM_ADDR_TYPES(
34: AddressTypes.dvType, AddressTypes.rmType, true,
35: AddressTypes.rmType, false), WITH_PO_TYPE_AND_RM_ADDR_TYPES(
36: AddressTypes.poType, AddressTypes.rmType, true,
37: AddressTypes.rmType, false), WITH_PO_TYPE_AND_ONE_PO_AND_ONE_RM_ADDR_TYPES(
38: AddressTypes.poType, AddressTypes.poType, true,
39: AddressTypes.rmType, true), ;
40:
41: private String typeCode;
42: private String addrTypeCode1;
43: private String addrTypeCode2;
44: private boolean defaultAddr1;
45: private boolean defaultAddr2;
46:
47: VendorRuleAddressTypeFixture(String typeCode, String addrTypeCode1,
48: boolean default1, String addrTypeCode2, boolean default2) {
49: this .typeCode = typeCode;
50: this .addrTypeCode1 = addrTypeCode1;
51: this .defaultAddr1 = default1;
52: this .addrTypeCode2 = addrTypeCode2;
53: this .defaultAddr2 = default2;
54: }
55:
56: @SuppressWarnings("deprecation")
57: public VendorDetail populateVendor(VendorDetail vndr) {
58: vndr.getVendorHeader().setVendorTypeCode(this .typeCode);
59: VendorType type = new VendorType();
60: type.setVendorAddressTypeRequiredCode(this .addrTypeCode1);
61: vndr.getVendorHeader().setVendorType(type);
62: List<VendorAddress> addrList = new ArrayList();
63: VendorAddress addr1 = new VendorAddress();
64: VendorAddress addr2 = new VendorAddress();
65: addr1.setVendorAddressTypeCode(this.addrTypeCode1);
66: addr1.setVendorDefaultAddressIndicator(this.defaultAddr1);
67: addr2.setVendorAddressTypeCode(this.addrTypeCode2);
68: addr2.setVendorDefaultAddressIndicator(this.defaultAddr2);
69: addrList.add(addr1);
70: addrList.add(addr2);
71: vndr.setVendorAddresses(addrList);
72: return vndr;
73: }
74: }
|