1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.job;
17
18 import java.sql.Time;
19 import java.sql.Timestamp;
20 import java.util.List;
21
22 import junit.framework.Assert;
23
24 import org.joda.time.DateTime;
25 import org.joda.time.LocalDate;
26 import org.junit.Ignore;
27 import org.junit.Test;
28 import org.kuali.kpme.core.CoreUnitTestCase;
29 import org.kuali.kpme.core.IntegrationTest;
30 import org.kuali.kpme.core.api.job.Job;
31 import org.kuali.kpme.core.calendar.CalendarBo;
32 import org.kuali.kpme.core.calendar.entry.CalendarEntryBo;
33 import org.kuali.kpme.core.paytype.PayTypeBo;
34 import org.kuali.kpme.core.service.HrServiceLocator;
35 import org.kuali.kpme.core.util.TKUtils;
36 import org.kuali.rice.krad.service.KRADServiceLocator;
37
38
39
40
41
42
43 @IntegrationTest
44 public class JobTest extends CoreUnitTestCase {
45
46 private static final String CALENDAR_GROUP = "BWN-CAL";
47 private static Long jobId = 23L;
48 private static Long jobNumber = 5L;
49 public static final String TEST_USER = "admin";
50
51
52 @Test
53 public void testInsertPayCalendar() throws Exception {
54 CalendarBo payCalendar = new CalendarBo();
55 payCalendar.setHrCalendarId("1001");
56 payCalendar.setCalendarName(CALENDAR_GROUP);
57
58 payCalendar.setFlsaBeginDay("Sun");
59 payCalendar.setFlsaBeginTime(Time.valueOf("0:00:00"));
60 payCalendar.setCalendarDescriptions("Test Description");
61
62 KRADServiceLocator.getBusinessObjectService().save(payCalendar);
63 Assert.assertTrue(HrServiceLocator.getCalendarService().getCalendar(payCalendar.getHrCalendarId()) != null);
64
65 }
66
67 @Test
68 public void testInsertPayCalendarDates() throws Exception {
69 CalendarEntryBo payCalendarDates = new CalendarEntryBo();
70 payCalendarDates.setHrCalendarEntryId("1001");
71 payCalendarDates.setHrCalendarId("1001");
72
73 DateTime beginPeriodDateTime = new DateTime(2010, 7, 1, 0, 0, 0);
74 DateTime endPeriodDateTime = new DateTime(2010, 7, 15, 0, 0, 0);
75
76 payCalendarDates.setBeginPeriodFullDateTime(beginPeriodDateTime);
77 payCalendarDates.setEndPeriodFullDateTime(endPeriodDateTime);
78 payCalendarDates.setCalendarName(CALENDAR_GROUP);
79
80 KRADServiceLocator.getBusinessObjectService().save(payCalendarDates);
81 Assert.assertTrue(HrServiceLocator.getCalendarEntryService().getCalendarEntry(payCalendarDates.getHrCalendarEntryId()) != null);
82
83 }
84
85 @Test
86 public void testInsertPayType() throws Exception {
87 PayTypeBo payType = new PayTypeBo();
88 payType.setHrPayTypeId("1001");
89 payType.setPayType("BW");
90 payType.setRegEarnCode("RGN");
91 payType.setEffectiveLocalDate(LocalDate.now());
92 payType.setTimestamp(new Timestamp(System.currentTimeMillis()));
93
94
95 payType.setFlsaStatus("NE");
96 payType.setPayFrequency("M");
97 payType.setUserPrincipalId("admin");
98
99 payType = (PayTypeBo) KRADServiceLocator.getBusinessObjectService().save(payType);
100 Assert.assertTrue(HrServiceLocator.getPayTypeService().getPayType(payType.getPayType(), payType.getEffectiveLocalDate()) != null);
101 KRADServiceLocator.getBusinessObjectService().delete(payType);
102 }
103
104 @Ignore
105 @Test
106 public void testGetJobs() {
107
108
109
110 DateTime payPeriodEndDate = new DateTime(2010,7,30,1,0,0,0, TKUtils.getSystemDateTimeZone());
111 List<Job> jobs = HrServiceLocator.getJobService().getJobs(TEST_USER, payPeriodEndDate.toLocalDate());
112 Assert.assertNotNull("Jobs was null", jobs);
113 Assert.assertEquals("Incorrect number of jobs", 2, jobs.size());
114 }
115
116
117 @Test
118 public void testSaveAndFetchObject() throws Exception{
119
120
121 }
122 }
123