001 /**
002 * Copyright 2004-2013 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.lm.leaveblock.service;
017
018 import java.util.Calendar;
019 import java.util.Date;
020 import java.util.List;
021
022 import junit.framework.Assert;
023
024 import org.joda.time.DateTime;
025 import org.junit.After;
026 import org.junit.Before;
027 import org.junit.Test;
028 import org.kuali.hr.lm.LMConstants;
029 import org.kuali.hr.lm.leaveblock.LeaveBlockHistory;
030 import org.kuali.hr.test.KPMETestCase;
031 import org.kuali.hr.time.service.base.TkServiceLocator;
032 import org.kuali.hr.time.util.TKUtils;
033
034 public class LeaveBlockHistoryServiceImplTest extends KPMETestCase {
035
036 private LeaveBlockHistoryService leaveBlockHistoryService;
037
038 @Before
039 public void setUp() throws Exception {
040 super.setUp();
041 leaveBlockHistoryService = TkServiceLocator
042 .getLeaveBlockHistoryService();
043 }
044
045 @After
046 public void tearDown() throws Exception {
047 super.tearDown();
048 }
049
050 @Test
051 public void testGetLeaveBlockHistoryByLmLeaveBlockId() {
052 List<LeaveBlockHistory> leaveBlockHistories = leaveBlockHistoryService.getLeaveBlockHistoryByLmLeaveBlockId("1000");
053 Assert.assertNotNull("Leave Block histories not found ", leaveBlockHistories);
054 }
055
056 @Test
057 public void testGetLeaveBlockHistories() {
058 List<LeaveBlockHistory> leaveBlockHistories = leaveBlockHistoryService.getLeaveBlockHistories("admin", null);
059 Assert.assertNotNull("Leave Block histories not found ", leaveBlockHistories);
060 }
061
062 @Test
063 public void testGetLeaveBlockHistoriesForLeaveDisplay() {
064 Calendar currCal = Calendar.getInstance();
065 currCal.set(2012, 0, 1);
066 Date beginDate = TKUtils.getTimelessDate(currCal.getTime());
067 currCal.set(2012, 11, 31);
068 Date endDate = TKUtils.getTimelessDate(currCal.getTime());
069 List<LeaveBlockHistory> leaveBlockHistories= leaveBlockHistoryService.getLeaveBlockHistoriesForLeaveDisplay("admin", beginDate, endDate, Boolean.TRUE);
070 Assert.assertNotNull("Leave Block histories for leavedisplay not found ", leaveBlockHistories);
071 }
072 @Test
073 public void testGetLeaveBlockHistoriesWithStatusAndAction() {
074 Date currentDate = new Date((new DateTime(2012, 3, 10, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
075 List<LeaveBlockHistory> leaveBlockHistories= leaveBlockHistoryService.getLeaveBlockHistories("admin", LMConstants.REQUEST_STATUS.DISAPPROVED, LMConstants.ACTION.DELETE, currentDate);
076 Assert.assertNotNull("Leave Block histories for leavedisplay not found ", leaveBlockHistories);
077 Assert.assertTrue("There should be 1 leave block history found, not " + leaveBlockHistories.size() , leaveBlockHistories.size() == 1);
078 }
079
080
081 }