View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ar.document.validation.impl;
20  
21  import static org.kuali.kfs.sys.fixture.UserNameFixture.khuntley;
22  
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  import org.kuali.kfs.coa.businessobject.Chart;
27  import org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail;
28  import org.kuali.kfs.sys.ConfigureContext;
29  import org.kuali.kfs.sys.context.KualiTestBase;
30  import org.kuali.kfs.sys.context.SpringContext;
31  import org.kuali.rice.krad.service.BusinessObjectService;
32  
33  @ConfigureContext(session = khuntley)
34  public class CustomerInvoiceDetailChartCodeReceivableValidationTest extends KualiTestBase {
35      
36      private CustomerInvoiceDetailChartCodeReceivableValidation validation;
37      
38      private static final String VALID_CHART_OF_ACCOUNTS_CODE = "UA";
39      
40      @Override
41      protected void setUp() throws Exception {
42          super.setUp();
43          validation = new CustomerInvoiceDetailChartCodeReceivableValidation();
44          validation.setCustomerInvoiceDetail(new CustomerInvoiceDetail());
45          validation.getCustomerInvoiceDetail().setChartOfAccountsCode(VALID_CHART_OF_ACCOUNTS_CODE);
46      }
47  
48      @Override
49      protected void tearDown() throws Exception {
50          validation = null;
51          super.tearDown();
52      }    
53      
54      public void testDoesChartCodeHaveReceivableObjectCode_True(){
55          assertTrue(validation.validate(null));
56      }
57      
58      public void testDoesChartCodeHaveReceivableObjectCode_False(){
59       
60          //Blank out receivable object code for chart.
61          Map<String,String> criteria = new HashMap<String,String>();
62          criteria.put("chartOfAccountsCode", VALID_CHART_OF_ACCOUNTS_CODE);
63          
64          Chart chart = (Chart)SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Chart.class, criteria);
65          chart.setFinAccountsReceivableObjCode("");
66          
67          assertFalse(validation.validate(null));
68      }
69  
70  }
71