View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.tklm.leave.accrual;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.LocalDate;
20  import org.joda.time.format.DateTimeFormat;
21  import org.joda.time.format.DateTimeFormatter;
22  import org.junit.Assert;
23  import org.junit.Ignore;
24  import org.junit.Test;
25  import org.kuali.kpme.core.IntegrationTest;
26  import org.kuali.kpme.core.util.TKUtils;
27  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
28  import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
29  
30  @Ignore
31  @IntegrationTest
32  public class PrincipalAccrualRanServiceTest extends TKLMIntegrationTestCase {
33  	
34  	/**
35  	 * 
36  	 * Test fails. This test uses data that materializes during the test suite lifecycle - likely from AccrualServiceTest.
37  	 * 
38  	 * Must manually enter a last ran entry, then run an accrual, so that the location of this test in the suites sequence does not
39  	 * affect results.
40  	 */
41  	@Test
42  	public void testUpdateInfo() {
43  		// the database has an entry for principalId testUser dated 2012-05-01
44  		// run accrual service for testUser
45  		// the principalAccrualRan entry in database should be changed to today's timestamp
46  		PrincipalAccrualRan par = LmServiceLocator.getPrincipalAccrualRanService().getLastPrincipalAccrualRan("testUser");
47  		Assert.assertNotNull("There should be one entry in PrincipalAccrualRan table for 'testUser'", par);
48  		DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd/yyyy");
49  		Assert.assertTrue("Date of the original entry in PrincipalAccrualRan for 'testUser' should be 05/01/2012"
50  				, formatter.print(par.getLastRanDateTime()).equals("05/01/2012"));
51  		
52  		DateTime startDate = new DateTime(2012, 2, 20, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
53  		DateTime endDate = new DateTime(2012, 5, 3, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
54  		
55  		boolean rerunFlag = LmServiceLocator.getLeaveAccrualService().statusChangedSinceLastRun("testUser");
56  		Assert.assertTrue("Status should be changed for 'testUser'", rerunFlag);
57  
58          LmServiceLocator.getLeaveAccrualService().runAccrual("testUser", startDate, endDate, true);
59          par = LmServiceLocator.getPrincipalAccrualRanService().getLastPrincipalAccrualRan("testUser");
60  		Assert.assertTrue("Date of the original entry in PrincipalAccrualRan for 'testUser' should be current date"
61  				, formatter.print(par.getLastRanDateTime()).equals(formatter.print(LocalDate.now())));
62  		
63  	}
64  
65  }