View Javadoc

1   /**
2    * Copyright 2004-2012 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.hr.time.batch;
17  
18  import org.junit.Assert;
19  import org.junit.Before;
20  import org.junit.Test;
21  import org.kuali.hr.test.KPMETestCase;
22  import org.kuali.hr.time.batch.service.BatchJobService;
23  import org.kuali.hr.time.service.base.TkServiceLocator;
24  import org.kuali.hr.time.util.TkConstants;
25  
26  public class BatchJobTest extends KPMETestCase {
27  
28  	private static final String BATCH_JOB_NAME = "testJob";
29  	private Long ibjId;
30  	private BatchJobService bjService;
31  
32  	@Before
33      public void setUp() throws Exception {
34      	super.setUp();
35      	bjService = TkServiceLocator.getBatchJobService();
36      }
37  	private void creatAndSaveBatchJob(){
38  		InitiateBatchJob ibj = new InitiateBatchJob("5");
39  		ibj.setBatchJobName(BATCH_JOB_NAME);
40  		ibj.setBatchJobStatus(TkConstants.BATCH_JOB_ENTRY_STATUS.SCHEDULED);
41  		ibj.setTimeElapsed(new Long(123));
42  		ibj.setHrPyCalendarEntryId("1234");
43  
44  		bjService.saveBatchJob(ibj);
45  
46  		ibjId = ibj.getTkBatchJobId();
47  	}
48  
49  	@Test
50  	public void testSavingAndRetrievingBatchJob() throws Exception {
51  		creatAndSaveBatchJob();
52  		BatchJob bj = (BatchJob) bjService.getBatchJob(ibjId);
53  		Assert.assertTrue("Batch Job Name not right", bj.getBatchJobName().equals(BATCH_JOB_NAME));
54  	}
55  }