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