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.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   * This class needs refactored - the name job test implies that it should unit test on the Job object, especially considering it's package location.
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;//id entered in the bootstrap SQL
47  	private static Long jobNumber = 5L;//number entered in the bootstrap SQL
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  		// KPME-2252
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 		 * This test is conducted in JobServiceImplTest.java
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 		//Confirming the save and fetch
119 		//save an object and confirm that it can be fetched
120 	}
121 }
122