1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.ld.batch.service.impl;
20
21 import java.util.Arrays;
22 import java.util.Date;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Properties;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.kuali.kfs.gl.batch.service.PostTransaction;
29 import org.kuali.kfs.gl.businessobject.OriginEntryGroup;
30 import org.kuali.kfs.module.ld.businessobject.LaborGeneralLedgerEntry;
31 import org.kuali.kfs.module.ld.service.LaborGeneralLedgerEntryService;
32 import org.kuali.kfs.module.ld.service.LaborOriginEntryGroupService;
33 import org.kuali.kfs.module.ld.testdata.LaborTestDataPropertyConstants;
34 import org.kuali.kfs.sys.ConfigureContext;
35 import org.kuali.kfs.sys.ObjectUtil;
36 import org.kuali.kfs.sys.TestDataPreparator;
37 import org.kuali.kfs.sys.context.KualiTestBase;
38 import org.kuali.kfs.sys.context.SpringContext;
39 import org.kuali.rice.core.api.datetime.DateTimeService;
40 import org.kuali.rice.krad.service.BusinessObjectService;
41
42 @ConfigureContext
43 public class LaborGLLedgerEntryPosterTest extends KualiTestBase {
44
45 private Properties properties;
46 private String fieldNames;
47 private String deliminator;
48 private List<String> keyFieldList;
49 private Map fieldValues;
50 private OriginEntryGroup group1;
51 private Date today;
52
53 private BusinessObjectService businessObjectService;
54 private PostTransaction laborGLLedgerEntryPoster;
55 private LaborOriginEntryGroupService originEntryGroupService;
56 private LaborGeneralLedgerEntryService laborGeneralLedgerEntryService;
57
58 @Override
59 public void setUp() throws Exception {
60 super.setUp();
61
62 String messageFileName = LaborTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/message.properties";
63 String propertiesFileName = LaborTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/laborGLLedgerEntryPoster.properties";
64
65 properties = TestDataPreparator.loadPropertiesFromClassPath(propertiesFileName);
66
67 fieldNames = properties.getProperty("fieldNames");
68 deliminator = properties.getProperty("deliminator");
69 keyFieldList = Arrays.asList(StringUtils.split(fieldNames, deliminator));
70
71 laborGLLedgerEntryPoster = SpringContext.getBean(PostTransaction.class,"laborGLLedgerEntryPoster");
72 businessObjectService = SpringContext.getBean(BusinessObjectService.class);
73 originEntryGroupService = SpringContext.getBean(LaborOriginEntryGroupService.class);
74 laborGeneralLedgerEntryService = SpringContext.getBean(LaborGeneralLedgerEntryService.class);
75 DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
76
77
78
79 today = dateTimeService.getCurrentDate();
80
81 LaborGeneralLedgerEntry cleanup = new LaborGeneralLedgerEntry();
82 ObjectUtil.populateBusinessObject(cleanup, properties, "dataCleanup", fieldNames, deliminator);
83 fieldValues = ObjectUtil.buildPropertyMap(cleanup, Arrays.asList(StringUtils.split(fieldNames, deliminator)));
84 businessObjectService.deleteMatching(LaborGeneralLedgerEntry.class, fieldValues);
85 }
86
87 public void testPost() throws Exception {
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 }
121 }