1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }