1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.batch;
17
18 import java.text.DateFormat;
19 import java.text.SimpleDateFormat;
20 import java.util.Date;
21
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.batch.service.BatchJobService;
27 import org.kuali.hr.time.calendar.CalendarEntries;
28 import org.kuali.hr.time.service.base.TkServiceLocator;
29 import org.kuali.hr.time.util.TkConstants;
30
31 public class BatchJobTest extends KPMETestCase {
32
33 private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yy");
34 private static final String BATCH_JOB_NAME = "testJob";
35 private Long ibjId;
36 private BatchJobService bjService;
37
38 @Before
39 public void setUp() throws Exception {
40 super.setUp();
41 bjService = TkServiceLocator.getBatchJobService();
42 }
43
44 private void creatAndSaveBatchJob() throws Exception{
45 Date beginPeriodDate = DATE_FORMAT.parse("04/01/2011");
46 Date endPeriodDate = DATE_FORMAT.parse("04/15/2011");
47 CalendarEntries calendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntriesByBeginAndEndDate(beginPeriodDate, endPeriodDate);
48 InitiateBatchJob ibj = new InitiateBatchJob(calendarEntry);
49 ibj.setBatchJobName(BATCH_JOB_NAME);
50 ibj.setBatchJobStatus(TkConstants.BATCH_JOB_ENTRY_STATUS.SCHEDULED);
51 ibj.setTimeElapsed(new Long(123));
52
53 bjService.saveBatchJob(ibj);
54
55 ibjId = ibj.getTkBatchJobId();
56 }
57
58 @Test
59 public void testSavingAndRetrievingBatchJob() throws Exception {
60 creatAndSaveBatchJob();
61 BatchJob bj = (BatchJob) bjService.getBatchJob(ibjId);
62 Assert.assertTrue("Batch Job Name not right", bj.getBatchJobName().equals(BATCH_JOB_NAME));
63 }
64 }