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