001    /**
002     * Copyright 2004-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.batch;
017    
018    import org.junit.Assert;
019    import org.junit.Before;
020    import org.junit.Test;
021    import org.kuali.hr.test.KPMETestCase;
022    import org.kuali.hr.time.batch.service.BatchJobService;
023    import org.kuali.hr.time.service.base.TkServiceLocator;
024    import org.kuali.hr.time.util.TkConstants;
025    
026    public class BatchJobTest extends KPMETestCase {
027    
028            private static final String BATCH_JOB_NAME = "testJob";
029            private Long ibjId;
030            private BatchJobService bjService;
031    
032            @Before
033        public void setUp() throws Exception {
034            super.setUp();
035            bjService = TkServiceLocator.getBatchJobService();
036        }
037            private void creatAndSaveBatchJob(){
038                    InitiateBatchJob ibj = new InitiateBatchJob("5");
039                    ibj.setBatchJobName(BATCH_JOB_NAME);
040                    ibj.setBatchJobStatus(TkConstants.BATCH_JOB_ENTRY_STATUS.SCHEDULED);
041                    ibj.setTimeElapsed(new Long(123));
042                    ibj.setHrPyCalendarEntryId("1234");
043    
044                    bjService.saveBatchJob(ibj);
045    
046                    ibjId = ibj.getTkBatchJobId();
047            }
048    
049            @Test
050            public void testSavingAndRetrievingBatchJob() throws Exception {
051                    creatAndSaveBatchJob();
052                    BatchJob bj = (BatchJob) bjService.getBatchJob(ibjId);
053                    Assert.assertTrue("Batch Job Name not right", bj.getBatchJobName().equals(BATCH_JOB_NAME));
054            }
055    }