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.service;
17:
18: import org.kuali.kfs.context.KualiTestBase;
19: import org.kuali.kfs.context.SpringContext;
20: import org.kuali.kfs.service.ParameterService;
21: import org.kuali.module.vendor.VendorConstants;
22: import org.kuali.module.vendor.VendorParameterConstants;
23: import org.kuali.module.vendor.bo.VendorDetail;
24: import org.kuali.test.ConfigureContext;
25:
26: @ConfigureContext
27: public class TaxNumberServiceTest extends KualiTestBase {
28:
29: private TaxNumberService taxNumberService;
30: private final String nullString = null;
31: private final String emptyString = "";
32: private final String first3Zero = "000123456";
33: private final String first3Six = "666123456";
34: private final String notAllNumber = "000234a2f";
35: private final String middle2Zero = "123004567";
36: private final String last4Zero = "123450000";
37: private final String validTaxNumber = "123456789";
38: private final String validTaxNumberDashed = "123-45-6789";
39: private final String allZero = "000000000";
40: private final String tenDigits = "1234567890";
41: private final String twoDigits = "12";
42:
43: protected void setUp() throws Exception {
44: super .setUp();
45: taxNumberService = SpringContext
46: .getBean(TaxNumberService.class);
47: }
48:
49: protected void tearDown() throws Exception {
50: super .tearDown();
51: }
52:
53: public void testIsValidTaxNumber_notAllowedTaxNumber() {
54: String[] notAllowedTaxNumbers = getNotAllowedTaxNumbers();
55: for (int i = 0; i < notAllowedTaxNumbers.length; i++) {
56: assertFalse(taxNumberService.isValidTaxNumber(
57: notAllowedTaxNumbers[i],
58: VendorConstants.TAX_TYPE_SSN));
59: }
60: }
61:
62: private String[] getNotAllowedTaxNumbers() {
63: String[] notAllowedTaxNumbers = SpringContext.getBean(
64: ParameterService.class).getParameterValues(
65: VendorDetail.class,
66: VendorParameterConstants.PURAP_NOT_ALLOWED_TAX_NUMBERS)
67: .toArray(new String[] {});
68: return notAllowedTaxNumbers;
69: }
70: }
|