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.ec.document;
20  
21  import java.util.List;
22  import java.util.Properties;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetail;
26  import org.kuali.kfs.module.ec.testdata.EffortTestDataPropertyConstants;
27  import org.kuali.kfs.sys.ConfigureContext;
28  import org.kuali.kfs.sys.TestDataPreparator;
29  import org.kuali.kfs.sys.context.KualiTestBase;
30  
31  @ConfigureContext
32  public class EffortCertificationDocumentTest extends KualiTestBase {
33  
34      private Properties properties, message;
35      private String detailFieldNames, documentFieldNames;
36      private String deliminator;
37  
38      /**
39       * Constructs a EffortCertificationDetailBuildServiceTest.java.
40       */
41      public EffortCertificationDocumentTest() {
42          super();
43          String messageFileName = EffortTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/message.properties";
44          String propertiesFileName = EffortTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/effortCertificationDocument.properties";
45  
46          properties = TestDataPreparator.loadPropertiesFromClassPath(propertiesFileName);
47          message = TestDataPreparator.loadPropertiesFromClassPath(messageFileName);
48  
49          deliminator = properties.getProperty("deliminator");
50  
51          detailFieldNames = properties.getProperty("detailFieldNames");
52          documentFieldNames = properties.getProperty("documentFieldNames");
53      }
54  
55      public void testGetEffortCertificationDetailWithMaxPayrollAmount_MultipleResults() throws Exception {
56          String testTarget = "getEffortCertificationDetailWithMaxPayrollAmount.multipleResults.";
57  
58          EffortCertificationDocument document = this.buildDocument(testTarget);
59          List<EffortCertificationDetail> detailLineWithMaxPayrollAmount = document.getEffortCertificationDetailWithMaxPayrollAmount();
60  
61          int numberOfExpectedDetail = Integer.valueOf(StringUtils.trim(properties.getProperty(testTarget + "numOfExpectedDetail")));
62  
63          assertEquals(numberOfExpectedDetail, detailLineWithMaxPayrollAmount.size());
64      }
65  
66      public void testGetEffortCertificationDetailWithMaxPayrollAmount_SingleResult() throws Exception {
67          String testTarget = "getEffortCertificationDetailWithMaxPayrollAmount.singleResult.";
68  
69          EffortCertificationDocument document = this.buildDocument(testTarget);
70          List<EffortCertificationDetail> detailLineWithMaxPayrollAmount = document.getEffortCertificationDetailWithMaxPayrollAmount();
71  
72          int numberOfExpectedDetail = Integer.valueOf(StringUtils.trim(properties.getProperty(testTarget + "numOfExpectedDetail")));
73  
74          assertEquals(numberOfExpectedDetail, detailLineWithMaxPayrollAmount.size());
75      }
76  
77      @SuppressWarnings("unchecked")
78      private EffortCertificationDocument buildDocument(String testTarget) {
79          EffortCertificationDocument document = TestDataPreparator.buildTestDataObject(EffortCertificationDocument.class, properties, testTarget + "document", documentFieldNames, deliminator);
80          List<EffortCertificationDetail> detailLines = this.buildDetailLine(testTarget);
81          document.setEffortCertificationDetailLines(detailLines);
82          return document;
83      }
84  
85      private List<EffortCertificationDetail> buildDetailLine(String testTarget) {
86          int numberOfDetail = Integer.valueOf(properties.getProperty(testTarget + "numOfDetail"));
87          return TestDataPreparator.buildTestDataList(EffortCertificationDetail.class, properties, testTarget + "detail", detailFieldNames, deliminator, numberOfDetail);
88      }
89  }