View Javadoc

1   /**
2    * Copyright 2004-2014 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.time.rule.collection;
17  
18  import org.joda.time.LocalDate;
19  import org.junit.Assert;
20  import org.junit.Test;
21  import org.kuali.kpme.core.IntegrationTest;
22  import org.kuali.kpme.core.util.TKUtils;
23  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
24  import org.kuali.kpme.tklm.time.rules.timecollection.TimeCollectionRule;
25  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
26  import org.kuali.rice.krad.service.KRADServiceLocator;
27  
28  @IntegrationTest
29  public class TimeCollectionRuleTest extends TKLMIntegrationTestCase{
30  
31  	@Test
32  	public void testTimeCollectionRuleFetch() throws Exception{
33  		loadData();
34  		TimeCollectionRule timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT",
35  												1234L, "%", LocalDate.now());
36  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
37  
38  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME",
39  				1234L, "%", LocalDate.now());
40  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
41  
42  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT",
43  				234L, "%", LocalDate.now());
44  		Assert.assertTrue("Time collection rule present" , timeCollection!=null);
45  
46  		timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME",
47  				234L, "%", LocalDate.now());
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.setEffectiveLocalDate(LocalDate.now());
57  		timeCollectionRule.setActive(true);
58  		timeCollectionRule.setPayType("%");
59  		timeCollectionRule.setTimestamp(TKUtils.getCurrentTimestamp());
60  		KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule);
61  
62  		TimeCollectionRule timeCollectionRule2 = new TimeCollectionRule();
63  		timeCollectionRule2.setDept("TEST-ME");
64  		timeCollectionRule2.setWorkArea(234L);
65  		timeCollectionRule2.setEffectiveLocalDate(LocalDate.now());
66  		timeCollectionRule2.setActive(true);
67  		timeCollectionRule2.setPayType("%");
68  		timeCollectionRule2.setTimestamp(TKUtils.getCurrentTimestamp());
69  		KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule2);
70  	}
71  }