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.ld.document.validation.impl;
20  
21  import org.kuali.kfs.coa.businessobject.Account;
22  import org.kuali.kfs.coa.businessobject.SubFundGroup;
23  import org.kuali.kfs.module.ld.LaborKeyConstants;
24  import org.kuali.kfs.module.ld.businessobject.ErrorCertification;
25  import org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine;
26  import org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine;
27  import org.kuali.kfs.module.ld.document.SalaryExpenseTransferDocument;
28  import org.kuali.kfs.module.ld.document.service.impl.SalaryExpenseTransferTransactionAgeServiceImpl;
29  import org.kuali.kfs.sys.ConfigureContext;
30  import org.kuali.kfs.sys.businessobject.UniversityDate;
31  import org.kuali.kfs.sys.context.KualiTestBase;
32  import org.kuali.kfs.sys.context.SpringContext;
33  import org.kuali.kfs.sys.context.TestUtils;
34  import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEventBase;
35  import org.kuali.kfs.sys.service.UniversityDateService;
36  import org.kuali.kfs.sys.service.impl.KfsParameterConstants;
37  import org.kuali.kfs.sys.service.impl.UniversityDateServiceImpl;
38  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
39  import org.kuali.rice.krad.util.GlobalVariables;
40  
41  /**
42   * The unit tests for methods in SalaryExpenseTransferErrorCertificationValidation. Note that this validation also depends on
43   * methods in SalaryExpenseTransferTransactionAgeService.
44   *
45   * @see org.kuali.kfs.module.ld.document.validation.impl.SalaryExpenseTransferErrorCertificationValidation
46   */
47  
48  @ConfigureContext
49  public class SalaryExpenseTransferErrorCertificationValidationTest extends KualiTestBase {
50      private static final String DEFAULT_PARM_FISCAL_PERIODS = "3";
51      private static final String DEFAULT_PARM_SUBFUND = "FEDERA=2";
52      private static final String YOUNGER_FISCAL_PER = "11";
53      private static final String OLDER_FISCAL_PER = "7";
54      private static final String FISCAL_PERIOD_FOR_REGULAR_TEST = "13";    // July
55      private static final String YOUNGER_FISCAL_PER_FOR_FY_TEST = "13";
56      private static final String OLDER_FISCAL_PER_FOR_FY_TEST = "12";
57      private static final String FISCAL_PERIOD_FOR_FY_TEST = "3";          // September
58      private static final String NON_PARM_SUBFUND = "AG";
59      private static final String PARM_SUBFUND = "FEDERA";
60  
61      private SalaryExpenseTransferErrorCertificationValidation validation;
62      private SalaryExpenseTransferTransactionAgeServiceImpl salaryExpenseTransferTransactionAgeService;
63      private MyUniversityDateService universityDateService;
64      private UniversityDateService oldDateService;
65      private SalaryExpenseTransferDocument stDoc;
66      private MyAttributedDocumentEvent event;
67      private ErrorCertification errorCertification;
68  
69      private enum TabState {
70          FULL, PARTIAL, EMPTY
71      };
72  
73      private enum CrossFY {
74          YES, NO
75      }
76  
77      @Override
78      public void setUp() throws Exception {
79          super.setUp();
80          validation = new SalaryExpenseTransferErrorCertificationValidation();
81          salaryExpenseTransferTransactionAgeService = new SalaryExpenseTransferTransactionAgeServiceImpl();
82          universityDateService = new MyUniversityDateService();
83          oldDateService = salaryExpenseTransferTransactionAgeService.getUniversityDateService();
84  
85          salaryExpenseTransferTransactionAgeService.setUniversityDateService(universityDateService);
86          validation.setParameterService(SpringContext.getBean(ParameterService.class));
87          validation.setSalaryExpenseTransferTransactionAgeService(salaryExpenseTransferTransactionAgeService);
88          stDoc = new SalaryExpenseTransferDocument();
89          event = new MyAttributedDocumentEvent(stDoc);
90          errorCertification = new ErrorCertification();
91          errorCertification.setDocumentNumber("1");
92          stDoc.setErrorCertification(errorCertification);
93          TestUtils.setSystemParameter(KfsParameterConstants.LABOR_DOCUMENT.class, SalaryExpenseTransferDocumentRuleConstants.DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED, DEFAULT_PARM_FISCAL_PERIODS);
94          TestUtils.setSystemParameter(KfsParameterConstants.LABOR_DOCUMENT.class, SalaryExpenseTransferDocumentRuleConstants.ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND, DEFAULT_PARM_SUBFUND);
95      }
96  
97      @Override
98      public void tearDown() throws Exception {
99          super.tearDown();
100         this.salaryExpenseTransferTransactionAgeService.setUniversityDateService(oldDateService);
101     }
102 
103     /**
104      * Create errorCertification object for use in the test validations. Based on an enum, can specify how complete the fields are.
105      *
106      * @param tabState
107      */
108     public void setUpErrorCertificationObject(TabState tabState) {
109         switch (tabState) {
110             case FULL:
111                 errorCertification.setErrorCorrectionReason("test reason");
112                 errorCertification.setErrorDescription("test desc");
113                 errorCertification.setExpenditureDescription("test description");
114                 errorCertification.setExpenditureProjectBenefit("test benefit");
115                 break;
116             case PARTIAL:
117                 errorCertification.setErrorCorrectionReason("test reason");
118                 errorCertification.setErrorDescription("test desc");
119                 errorCertification.setExpenditureDescription("");
120                 errorCertification.setExpenditureProjectBenefit("");
121                 break;
122             case EMPTY:
123                 errorCertification.setErrorCorrectionReason("");
124                 errorCertification.setErrorDescription("");
125                 errorCertification.setExpenditureDescription("");
126                 errorCertification.setExpenditureProjectBenefit("");
127                 break;
128         }
129     }
130 
131     /**
132      * Sets the current fiscal period of the university date in our custom UniversityDateService. Required because some tests are
133      * based around crossing the current fiscal year.
134      *
135      * @param crossFiscalYear
136      */
137     public void setCustomUniversityDateFiscalPeriod(CrossFY crossFiscalYear) {
138         switch (crossFiscalYear) {
139             case YES:
140                 salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().setUniversityFiscalAccountingPeriod(FISCAL_PERIOD_FOR_FY_TEST);
141                 break;
142             case NO:
143                 salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().setUniversityFiscalAccountingPeriod(FISCAL_PERIOD_FOR_REGULAR_TEST);
144                 break;
145         }
146     }
147 
148     /**
149      * Test the case where the source accounting line is "younger" and the error certification tab is empty. This is based on fiscal
150      * periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The source accounting line will
151      * use the current year and will be set to YOUNGER_FISCAL_PER. The validation will use the UniversityDateService that is defined
152      * in this test class set to FISCAL_PERIOD_FOR_REGULAR_TEST.
153      */
154     public void testSourceAccountingLine() {
155         // create a source accounting line
156         ExpenseTransferSourceAccountingLine sourceAccountingLine = new ExpenseTransferSourceAccountingLine();
157         sourceAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear());
158         sourceAccountingLine.setPayrollEndDateFiscalPeriodCode(YOUNGER_FISCAL_PER);
159 
160         stDoc.addSourceAccountingLine(sourceAccountingLine);
161 
162         setCustomUniversityDateFiscalPeriod(CrossFY.NO);
163 
164         // modify error certification's state as empty
165         setUpErrorCertificationObject(TabState.EMPTY);
166 
167         validation.validate(event);
168 
169         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
170         assertFalse("Unexpected requirement of Error Certification Tab.", hasError);
171     }
172 
173     /**
174      * Test the case where the source accounting line is "older" and the error certification tab is empty. This is based on the
175      * fiscal periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The source accounting
176      * line will use the current year, but will be set to OLDER_FISCAL_PER. The validation will use the UniversityDateService that
177      * is defined in this test class set to FISCAL_PERIOD_FOR_REGULAR_TEST.
178      */
179     public void testOlderSourceAccountingLine() {
180         // create a source accounting line
181         ExpenseTransferSourceAccountingLine sourceAccountingLine = new ExpenseTransferSourceAccountingLine();
182         sourceAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear());
183         sourceAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER);
184 
185         stDoc.addSourceAccountingLine(sourceAccountingLine);
186 
187         setCustomUniversityDateFiscalPeriod(CrossFY.NO);
188 
189         // modify error certification's state as empty
190         setUpErrorCertificationObject(TabState.EMPTY);
191 
192         validation.validate(event);
193 
194         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
195         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
196     }
197 
198     /**
199      * Test the case where the source accounting line is in previous fiscal year, is "older", and the error certification tab is
200      * empty. This is based on the fiscal year and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter.
201      * The source accounting line will use the previous year and will be set to OLDER_FISCAL_PER. The validation will use the
202      * UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_FY_TEST.
203      */
204     public void testPriorYearOlderSourceAccountingLine() {
205         // create a source accounting line
206         ExpenseTransferSourceAccountingLine sourceAccountingLine = new ExpenseTransferSourceAccountingLine();
207         sourceAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear() - 1);
208         sourceAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER_FOR_FY_TEST);
209 
210         stDoc.addSourceAccountingLine(sourceAccountingLine);
211 
212         setCustomUniversityDateFiscalPeriod(CrossFY.YES);
213 
214         // modify error certification's state as empty
215         setUpErrorCertificationObject(TabState.EMPTY);
216 
217         validation.validate(event);
218 
219         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
220         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
221     }
222 
223     /**
224      * Test the case where the source accounting line is in the previous fiscal year, is "younger", and the error certification tab
225      * is empty. This will test the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter and the fact that
226      * fiscal year should not matter. The source accounting line will use the previous year and will be set to YOUNGER_FISCAL_PER.
227      * The validation will use the UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_FY_TEST.
228      */
229     public void testPriorYearYoungerSourceAccountingLine() {
230         // create a source accounting line
231         ExpenseTransferSourceAccountingLine sourceAccountingLine = new ExpenseTransferSourceAccountingLine();
232         sourceAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear() - 1);
233         sourceAccountingLine.setPayrollEndDateFiscalPeriodCode(YOUNGER_FISCAL_PER_FOR_FY_TEST);
234 
235         stDoc.addSourceAccountingLine(sourceAccountingLine);
236 
237         setCustomUniversityDateFiscalPeriod(CrossFY.YES);
238 
239         // modify error certification's state as empty
240         setUpErrorCertificationObject(TabState.EMPTY);
241 
242         validation.validate(event);
243 
244         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
245         assertFalse("Error Certification Tab is required, but shouldn't be.", hasError);
246     }
247 
248     /**
249      * Test the case where the target accounting line is "younger" and the error certification tab is empty. This is based on the
250      * fiscal periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The target accounting
251      * line will use the current year and will be set to YOUNGER_FISCAL_PER. It will also have a sub fund that is not in the
252      * contribution approved ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the
253      * UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_REGULAR_TEST.
254      */
255     public void testTargetAccountingLine() {
256         Account account = new Account();
257         SubFundGroup subFundGroup = new SubFundGroup();
258         subFundGroup.setSubFundGroupCode(NON_PARM_SUBFUND);
259         account.setSubFundGroup(subFundGroup);
260 
261         // create a target accounting line for testing in set object
262         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
263         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear());
264         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(YOUNGER_FISCAL_PER);
265         targetAccountingLine.setAccount(account);
266 
267         stDoc.addTargetAccountingLine(targetAccountingLine);
268 
269         setCustomUniversityDateFiscalPeriod(CrossFY.NO);
270 
271         // modify error certification's state as empty
272         setUpErrorCertificationObject(TabState.EMPTY);
273 
274         validation.validate(event);
275 
276         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
277         assertFalse("Unexpected requirement of Error Certification Tab.", hasError);
278     }
279 
280     /**
281      * Test the case where the target accounting line is "older" and the error certification tab is empty. This is based on the
282      * fiscal periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The target accounting
283      * line will use the current year and will be set to OLDER_FISCAL_PER. It will also have a sub fund that is not in the
284      * contribution approved ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the
285      * UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_REGULAR_TEST.
286      */
287     public void testOlderTargetAccountingLine() {
288         Account account = new Account();
289         SubFundGroup subFundGroup = new SubFundGroup();
290         subFundGroup.setSubFundGroupCode(NON_PARM_SUBFUND);
291         account.setSubFundGroup(subFundGroup);
292 
293         // create a target accounting line for testing in set object
294         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
295         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear());
296         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER);
297         targetAccountingLine.setAccount(account);
298 
299         stDoc.addTargetAccountingLine(targetAccountingLine);
300 
301         setCustomUniversityDateFiscalPeriod(CrossFY.NO);
302 
303         // modify error certification's state as empty
304         setUpErrorCertificationObject(TabState.EMPTY);
305 
306         validation.validate(event);
307 
308         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
309         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
310     }
311 
312     /**
313      * Test the case where the target accounting line is in previous fiscal year, is "older", and the error certification tab is empty. This
314      * is based on the fiscal periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The
315      * target accounting line will use the previous year and will be set to OLDER_FISCAL_PER_FOR_FY_TEST. It will also have a sub fund that is
316      * not in the contribution approved ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the
317      * UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_FY_TEST.
318      */
319     public void testPriorYearOlderTargetAccountingLine() {
320         Account account = new Account();
321         SubFundGroup subFundGroup = new SubFundGroup();
322         subFundGroup.setSubFundGroupCode(NON_PARM_SUBFUND);
323         account.setSubFundGroup(subFundGroup);
324 
325         // create a target accounting line for testing in set object
326         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
327         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear() - 1);
328         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER_FOR_FY_TEST);
329         targetAccountingLine.setAccount(account);
330 
331         stDoc.addTargetAccountingLine(targetAccountingLine);
332 
333         setCustomUniversityDateFiscalPeriod(CrossFY.YES);
334 
335         // modify error certification's state as empty
336         setUpErrorCertificationObject(TabState.EMPTY);
337 
338         validation.validate(event);
339 
340         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
341         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
342     }
343 
344     /**
345      * Test the case where the target accounting line is in previous fiscal year, is "younger", and the error certification tab is empty. This
346      * is based on the fiscal periods and the DEFAULT_NUMBER_OF_FISCAL_PERIODS_ERROR_CERTIFICATION_TAB_REQUIRED parameter. The
347      * target accounting line will use the previous year and will be set to YOUNGER_FISCAL_PER_FOR_FY_TEST. It will also have a sub fund that is
348      * not in the contribution approved ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the
349      * UniversityDateService that is defined in this test class set to FISCAL_PERIOD_FOR_FY_TEST.
350      */
351     public void testPriorYearYoungerTargetAccountingLine() {
352         Account account = new Account();
353         SubFundGroup subFundGroup = new SubFundGroup();
354         subFundGroup.setSubFundGroupCode(NON_PARM_SUBFUND);
355         account.setSubFundGroup(subFundGroup);
356 
357         // create a target accounting line for testing in set object
358         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
359         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear() - 1);
360         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(YOUNGER_FISCAL_PER_FOR_FY_TEST);
361         targetAccountingLine.setAccount(account);
362 
363         stDoc.addTargetAccountingLine(targetAccountingLine);
364 
365         setCustomUniversityDateFiscalPeriod(CrossFY.YES);
366 
367         // modify error certification's state as empty
368         setUpErrorCertificationObject(TabState.EMPTY);
369 
370         validation.validate(event);
371 
372         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
373         assertFalse("Unexpected requirement of Error Certification Tab.", hasError);
374     }
375 
376     /**
377      * Test the case where the target accounting line is "older", has a subfund in the contribution approved
378      * ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter, and the error certification tab is empty. This is based on
379      * the fiscal periods and the ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The target accounting line will use
380      * the current year and will be set to OLDER_FISCAL_PER. It will also have a sub fund that is in the contribution approved
381      * ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the UniversityDateService that is defined
382      * in this test class set to FISCAL_PERIOD_FOR_REGULAR_TEST.
383      */
384     public void testOlderSubFundTargetAccountingLine() {
385         Account account = new Account();
386         SubFundGroup subFundGroup = new SubFundGroup();
387         subFundGroup.setSubFundGroupCode(PARM_SUBFUND);
388         account.setSubFundGroup(subFundGroup);
389 
390         // create a target accounting line for testing in set object
391         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
392         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear());
393         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER);
394         targetAccountingLine.setAccount(account);
395 
396         stDoc.addTargetAccountingLine(targetAccountingLine);
397 
398         setCustomUniversityDateFiscalPeriod(CrossFY.NO);
399 
400         // modify error certification's state as empty
401         setUpErrorCertificationObject(TabState.EMPTY);
402 
403         validation.validate(event);
404 
405         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
406         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
407     }
408 
409     /**
410      * Test the case where the target accounting line is from the previous fiscal year, has a subfund in the contribution approved
411      * ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter, and the error certification tab is empty. This is based on
412      * the fiscal periods and the ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The target accounting line will use
413      * the previous year and will be set to OLDER_FISCAL_PER. It will also have a sub fund that is in the contribution approved
414      * ERROR_CERTIFICATION_DEFAULT_OVERRIDE_BY_SUB_FUND parameter. The validation will use the UniversityDateService that is defined
415      * in this test class set to FISCAL_PERIOD_FOR_FY_TEST.
416      */
417     public void testPriorYearSubFundTargetAccountingLine() {
418         Account account = new Account();
419         SubFundGroup subFundGroup = new SubFundGroup();
420         subFundGroup.setSubFundGroupCode(PARM_SUBFUND);
421         account.setSubFundGroup(subFundGroup);
422 
423         // create a target accounting line for testing in set object
424         ExpenseTransferTargetAccountingLine targetAccountingLine = new ExpenseTransferTargetAccountingLine();
425         targetAccountingLine.setPayrollEndDateFiscalYear(salaryExpenseTransferTransactionAgeService.getUniversityDateService().getCurrentUniversityDate().getUniversityFiscalYear() - 1);
426         targetAccountingLine.setPayrollEndDateFiscalPeriodCode(OLDER_FISCAL_PER_FOR_FY_TEST);
427         targetAccountingLine.setAccount(account);
428 
429         stDoc.addTargetAccountingLine(targetAccountingLine);
430 
431         setCustomUniversityDateFiscalPeriod(CrossFY.YES);
432 
433         // modify error certification's state as empty
434         setUpErrorCertificationObject(TabState.EMPTY);
435 
436         validation.validate(event);
437 
438         boolean hasError = GlobalVariables.getMessageMap().doesPropertyHaveError(LaborKeyConstants.ErrorCertification.ERROR_ERROR_CERT_KEY);
439         assertTrue("Error Certification Tab isn't required, but should be.", hasError);
440     }
441 
442     /**
443      * Fake the current university date for this test.
444      */
445     static class MyUniversityDateService extends UniversityDateServiceImpl {
446         @Override
447         public UniversityDate getCurrentUniversityDate() {
448             UniversityDate universityDate = SpringContext.getBean(UniversityDateService.class).getCurrentUniversityDate();
449             return universityDate;
450         }
451     }
452 
453     static class MyAttributedDocumentEvent extends AttributedDocumentEventBase {
454         public MyAttributedDocumentEvent(SalaryExpenseTransferDocument d) {
455             super("", "", d);
456         }
457     }
458 }