View Javadoc

1   /**
2    * Copyright 2004-2012 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.hr.time.timecollection.rule;
17  
18  import java.sql.Date;
19  import java.sql.Timestamp;
20  import java.util.Calendar;
21  
22  import org.junit.Assert;
23  import org.junit.Test;
24  import org.kuali.hr.test.KPMETestCase;
25  import org.kuali.hr.time.collection.rule.TimeCollectionRule;
26  import org.kuali.hr.time.service.base.TkServiceLocator;
27  import org.kuali.rice.krad.service.KRADServiceLocator;
28  
29  public class TimeCollectionRuleTest extends KPMETestCase{
30  
31  	@Test
32  	public void testTimeCollectionRuleFetch() throws Exception{
33  		loadData();
34  		TimeCollectionRule timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT",
35  												1234L, new Date(System.currentTimeMillis()));
36  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
37  
38  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME",
39  				1234L, new Date(System.currentTimeMillis()));
40  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
41  
42  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT",
43  				234L, new Date(System.currentTimeMillis()));
44  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
45  
46  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME",
47  				234L, new Date(System.currentTimeMillis()));
48  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
49  	}
50  
51  	private void loadData()
52  	{
53  		TimeCollectionRule timeCollectionRule = new TimeCollectionRule();
54  		timeCollectionRule.setDept("TEST-DEPT");
55  		timeCollectionRule.setWorkArea(1234L);
56  		timeCollectionRule.setEffectiveDate(new Date(System.currentTimeMillis()));
57  		timeCollectionRule.setActive(true);
58  		timeCollectionRule.setTimestamp(new Timestamp(Calendar.getInstance().getTimeInMillis()));
59  		KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule);
60  
61  		TimeCollectionRule timeCollectionRule2 = new TimeCollectionRule();
62  		timeCollectionRule2.setDept("TEST-ME");
63  		timeCollectionRule2.setWorkArea(234L);
64  		timeCollectionRule2.setEffectiveDate(new Date(System.currentTimeMillis()));
65  		timeCollectionRule2.setActive(true);
66  		timeCollectionRule2.setTimestamp(new Timestamp(Calendar.getInstance().getTimeInMillis()));
67  		KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule2);
68  	}
69  }