1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.accrual.service;
17
18 import java.sql.Date;
19 import java.text.SimpleDateFormat;
20
21 import org.joda.time.DateTime;
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.kuali.hr.lm.accrual.PrincipalAccrualRan;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.service.base.TkServiceLocator;
27 import org.kuali.hr.time.util.TKUtils;
28 import org.kuali.hr.time.util.TkConstants;
29
30 public class PrincipalAccrualRanServiceTest extends KPMETestCase {
31
32 @Test
33 public void testUpdateInfo() {
34
35
36
37 PrincipalAccrualRan par = TkServiceLocator.getPrincipalAccrualRanService().getLastPrincipalAccrualRan("testUser");
38 Assert.assertNotNull("There should be one entry in PrincipalAccrualRan table for 'testUser'", par);
39 Date aDate = new Date(par.getLastRanTs().getTime());
40 SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
41 Assert.assertTrue("Date of the original entry in PrincipalAccrualRan for 'testUser' should be 05/01/2012"
42 , formatter.format(aDate).equals("05/01/2012"));
43
44 Date startDate = new Date((new DateTime(2012, 2, 20, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
45 Date endDate = new Date((new DateTime(2012, 5, 3, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
46
47 boolean rerunFlag = TkServiceLocator.getLeaveAccrualService().statusChangedSinceLastRun("testUser");
48 Assert.assertTrue("Status should be changed for 'testUser'", rerunFlag);
49
50 TkServiceLocator.getLeaveAccrualService().runAccrual("testUser", startDate, endDate, true);
51 par = TkServiceLocator.getPrincipalAccrualRanService().getLastPrincipalAccrualRan("testUser");
52 aDate = new Date(par.getLastRanTs().getTime());
53 Assert.assertTrue("Date of the original entry in PrincipalAccrualRan for 'testUser' should be current date"
54 , formatter.format(aDate).equals(formatter.format(TKUtils.getCurrentDate())));
55
56 }
57
58 }