1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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 }