001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.labor;
017:
018: import java.util.Calendar;
019:
020: import org.kuali.core.service.PersistenceService;
021: import org.kuali.kfs.context.SpringContext;
022: import org.kuali.module.gl.bo.OriginEntrySource;
023: import org.kuali.module.labor.service.LaborScrubberService;
024: import org.kuali.test.ConfigureContext;
025:
026: @ConfigureContext
027: public class LaborScrubberServiceTest extends LaborOriginEntryTestBase {
028: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
029: .getLogger(LaborScrubberServiceTest.class);
030:
031: private LaborScrubberService laborScrubberService = null;
032:
033: @Override
034: protected void setUp() throws Exception {
035: super .setUp();
036:
037: LOG.debug("setUp() started");
038:
039: laborScrubberService = SpringContext
040: .getBean(LaborScrubberService.class);
041: laborScrubberService.setDateTimeService(dateTimeService);
042: persistenceService = SpringContext
043: .getBean(PersistenceService.class);
044:
045: // Get the test date time service so we can specify the date/time of the run
046: Calendar c = Calendar.getInstance();
047: c.set(Calendar.DAY_OF_MONTH, 1);
048: c.set(Calendar.MONTH, Calendar.JANUARY);
049: c.set(Calendar.YEAR, 2006);
050:
051: // since the cutoff time is set to 10am (KFSP1/Scrubber+cutoff+time+configuration)
052: // we want to ensure that the time is always after that time so the cutoff algorithm is not invoked
053: c.set(Calendar.HOUR_OF_DAY, 23);
054: c.set(Calendar.MINUTE, 59);
055: c.set(Calendar.SECOND, 59);
056:
057: date = c.getTime();
058: dateTimeService.setCurrentDate(date);
059: }
060:
061: public void testDemerger() throws Exception {
062: String[] inputTransactions = {
063: "2026BA6044900-----2400---ACEX06BT PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50D2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA",
064: "2007BA6044900-----2400---ACEX06BT PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50C2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA",
065: "2026BA6044900-----2400---ACEX06ST PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50C2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA",
066: "2007BA6044900-----2400---ACEX06ST PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50C2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA" };
067:
068: EntryHolder[] outputTransactions = {
069: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
070: inputTransactions[0]),
071: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
072: inputTransactions[1]),
073: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
074: inputTransactions[2]),
075: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
076: inputTransactions[3]),
077: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
078: inputTransactions[0]),
079: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
080: inputTransactions[1]),
081: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
082: inputTransactions[2]),
083: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
084: inputTransactions[3]) };
085:
086: scrub(inputTransactions);
087: assertOriginEntries(4, outputTransactions);
088:
089: }
090:
091: public void testValidEntries() throws Exception {
092: String[] inputTransactions = {
093: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50D2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA",
094: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000200014789----------KUALI TEST DESCRIPTION +000000000003329.27D2006-12-22 2006-12-222006-12-31000082.322007060000649044 000REGS12PAE 16 M001010207 IU IUBLA",
095: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000300015213----------KUALI TEST DESCRIPTION +000000000002716.89D2006-12-22 2006-12-222006-12-31000084.862007060000683206 000REGS12PAE 13 M001010207 IU IUBLA",
096: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000400017659----------KUALI TEST DESCRIPTION +000000000001620.08D2006-12-22 2006-12-222006-12-31000041.382007060001316908 000REGS12PAE 13 M001010207 IU IUBLA",
097: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000500019196----------KUALI TEST DESCRIPTION +000000000005106.15D2006-12-22 2006-12-222006-12-31000104.932007060001368813 000REGS12PAE 19 M001010207 IU IUBLA",
098: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000600022120----------KUALI TEST DESCRIPTION +000000000003071.10D2006-12-22 2006-12-222006-12-31000106.752007060001773996 000REGS12PAE 12 M001010207 IU IUBLA",
099: "2007BA6044900-----2400---ACEX07PAY PLM04013107 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50D2007-01-25 2007-01-252007-01-31000184.002007070000149952 001REGS12PAE 11 M004013107 IU IUBLA",
100: "2007BA6044900-----2400---ACEX07PAY PLM04013107 0000200014789----------KUALI TEST DESCRIPTION +000000000003329.27D2007-01-25 2007-01-252007-01-31000090.162007070000649044 000REGS12PAE 16 M004013107 IU IUBLA",
101: "2007BA6044900-----2400---ACEX07PAY PLM04013107 0000300015213----------KUALI TEST DESCRIPTION +000000000002716.89D2007-01-25 2007-01-252007-01-31000092.942007070000683206 000REGS12PAE 13 M004013107 IU IUBLA",
102: "2007BA6044900-----2400---ACEX07PAY PLM04013107 0000400017659----------KUALI TEST DESCRIPTION +000000000001620.08D2007-01-25 2007-01-252007-01-31000045.322007070001316908 000REGS12PAE 13 M004013107 IU IUBLA" };
103:
104: EntryHolder[] outputTransactions = {
105: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
106: inputTransactions[0]),
107: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
108: inputTransactions[1]),
109: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
110: inputTransactions[2]),
111: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
112: inputTransactions[3]),
113: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
114: inputTransactions[4]),
115: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
116: inputTransactions[5]),
117: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
118: inputTransactions[6]),
119: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
120: inputTransactions[7]),
121: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
122: inputTransactions[8]),
123: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
124: inputTransactions[9]),
125: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
126: inputTransactions[0]),
127: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
128: inputTransactions[1]),
129: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
130: inputTransactions[2]),
131: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
132: inputTransactions[3]),
133: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
134: inputTransactions[4]),
135: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
136: inputTransactions[5]),
137: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
138: inputTransactions[6]),
139: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
140: inputTransactions[7]),
141: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
142: inputTransactions[8]),
143: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
144: inputTransactions[9]), };
145:
146: scrub(inputTransactions);
147: assertOriginEntries(4, outputTransactions);
148:
149: }
150:
151: public void testBlankFiscalYear() throws Exception {
152: String[] inputTransactions = { " BA6044900-----2400---ACEX06PAY PLBLANKFISC 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50D2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA" };
153: EntryHolder[] outputTransactions = {
154: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
155: inputTransactions[0]),
156: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
157: inputTransactions[0]) };
158:
159: scrub(inputTransactions);
160: assertOriginEntries(4, outputTransactions);
161:
162: }
163:
164: public void testInvalidObjectCode() throws Exception {
165: String[] inputTransactions = {
166: "2000BA6044906-----2400---ACEX06PAY PLCLOSEFISC 0000300015213----------KUALI TEST DESCRIPTION +000000000002716.89D2006-12-22 2006-12-222006-12-31000084.862007060000683206 000REGS12PAE 13 M001010207 IU IUBLA",
167: "2000BA6044906-----2400---ACEX06PAY PLCLOSEFISC 0000400017659----------KUALI TEST DESCRIPTION +000000000001620.08D2006-12-22 2006-12-222006-12-31000041.382007060001316908 000REGS12PAE 13 M001010207 IU IUBLA" };
168: EntryHolder[] outputTransactions = {
169: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
170: inputTransactions[0]),
171: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
172: inputTransactions[1]),
173: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
174: inputTransactions[0]),
175: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
176: inputTransactions[1]) };
177:
178: scrub(inputTransactions);
179: assertOriginEntries(4, outputTransactions);
180:
181: }
182:
183: public void testInvalidFiscalYear() throws Exception {
184: String[] inputTransactions = {
185: "2026BA6044913-----2400---ACEX06PAY PLINVALFISC 0000500019196----------KUALI TEST DESCRIPTION +000000000005106.15D2006-12-22 2006-12-222006-12-31000104.932007060001368813 000REGS12PAE 19 M001010207 IU IUBLA",
186: "2026BA6044913-----2400---ACEX06PAY PLINVALFISC 0000600022120----------KUALI TEST DESCRIPTION +000000000003071.10D2006-12-22 2006-12-222006-12-31000106.752007060001773996 000REGS12PAE 12 M001010207 IU IUBLA" };
187: EntryHolder[] outputTransactions = {
188: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
189: inputTransactions[0]),
190: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
191: inputTransactions[1]),
192: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
193: inputTransactions[0]),
194: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
195: inputTransactions[1]) };
196:
197: scrub(inputTransactions);
198: assertOriginEntries(4, outputTransactions);
199:
200: }
201:
202: public void testInvalid() throws Exception {
203: String[] inputTransactions = {
204: "2007 1031400-----2400---ACEX07PAY PLBLANKCHAR 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50D2007-01-25 2007-01-252007-01-31000184.002007070000149952 001REGS12PAE 11 M004013107 IU IUBLA",
205: "2007 1031400-----2400---ACEX07PAY PLBLANKCHAR 0000200014789----------KUALI TEST DESCRIPTION +000000000003329.27D2007-01-25 2007-01-252007-01-31000090.162007070000649044 000REGS12PAE 16 M004013107 IU IUBLA" };
206: EntryHolder[] outputTransactions = {
207: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
208: inputTransactions[0]),
209: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
210: inputTransactions[1]),
211: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
212: inputTransactions[0]),
213: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
214: inputTransactions[1]) };
215:
216: scrub(inputTransactions);
217: assertOriginEntries(4, outputTransactions);
218:
219: }
220:
221: public void testInvalidDebitCreditCode() throws Exception {
222: String[] inputTransactions = {
223: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003493.50X2006-12-22 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA",
224: "2007BA6044900-----2400---ACEX06PAY PLM01010207 0000100009529----------KUALI TEST DESCRIPTION +000000000003495.50X2006-12-25 2006-12-222006-12-31000168.002007060000149952 001REGS12PAE 11 M001010207 IU IUBLA" };
225:
226: EntryHolder[] outputTransactions = {
227: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
228: inputTransactions[0]),
229: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
230: inputTransactions[1]),
231: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
232: inputTransactions[0]),
233: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_ERROR,
234: inputTransactions[1]) };
235:
236: scrub(inputTransactions);
237: assertOriginEntries(4, outputTransactions);
238: }
239:
240: public void testA2balanceTypeAcceptClosedFiscalPeriod()
241: throws Exception {
242: String[] inputTransactions = { "2005BL1031400-----5772---A2EX06PAYEPLPRENC-07 00002MTFRING ----------KUALI TEST DESCRIPTION +000000000028988.60C2006-12-14 D2006-12-14 000000.00200706-----------000 M037113006 " };
243:
244: EntryHolder[] outputTransactions = {
245: new EntryHolder(OriginEntrySource.LABOR_BACKUP,
246: inputTransactions[0]),
247: new EntryHolder(OriginEntrySource.LABOR_SCRUBBER_VALID,
248: inputTransactions[0]) };
249:
250: scrub(inputTransactions);
251: assertOriginEntries(4, outputTransactions);
252: }
253:
254: private void scrub(String[] inputTransactions) {
255: clearOriginEntryTables();
256: loadInputTransactions(OriginEntrySource.LABOR_BACKUP,
257: inputTransactions, date);
258: persistenceService.clearCache();
259: laborScrubberService.scrubEntries();
260: }
261: }
|