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.util.List;
19  
20  import org.joda.time.DateTime;
21  import org.junit.Assert;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.kuali.kpme.core.CoreUnitTestCase;
25  import org.kuali.kpme.core.IntegrationTest;
26  import org.kuali.kpme.core.job.service.JobService;
27  import org.kuali.kpme.core.service.HrServiceLocator;
28  import org.kuali.kpme.core.util.TKUtils;
29  
30  @IntegrationTest
31  public class JobServiceImplTest extends CoreUnitTestCase {
32  
33  	public static final String TEST_USER = "admin";
34  
35  	JobService jobService = null;
36  	
37  
38  	@Before
39  	public void setUp() throws Exception {
40  		super.setUp();
41  		jobService=HrServiceLocator.getJobService();
42  	}
43  	
44  	@Test
45  	public void testGetJobs() {
46  		DateTime payPeriodEndDate = new DateTime(2010,7,30,1,0,0,0, TKUtils.getSystemDateTimeZone());
47  		List<Job> jobs = jobService.getJobs(TEST_USER, payPeriodEndDate.toLocalDate());
48  		Assert.assertNotNull("Jobs was null", jobs);
49  		Assert.assertEquals("Incorrect number of jobs", 2, jobs.size());
50  	}
51  	
52  	@Test
53  	public void testGetMaxJob() {
54  		Job aJob = jobService.getMaxJob("admin");
55  		Assert.assertNotNull("Max Job should not be null", aJob);
56  		Assert.assertEquals("Max job number of admin should be 30", new Long("30"), aJob.getJobNumber());
57  	}
58  	
59  	@Test
60  	public void testSearchJobs() throws Exception {
61  		List<Job> allResults = HrServiceLocator.getJobService().getJobs("admin", null, null, null, null, null, null, null, null, null, "Y", "N");
62  		Assert.assertEquals("Search returned the wrong number of results.", 9, allResults.size());
63  		
64  		List<Job> restrictedResults = HrServiceLocator.getJobService().getJobs("testuser6", null, null, null, null, null, null, null, null, null, "Y", "N");
65  		Assert.assertEquals("Search returned the wrong number of results.", 5, restrictedResults.size());
66  	}
67  	
68  }