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.time.calendar.service; 017 018 import java.util.Date; 019 import java.util.List; 020 021 import org.apache.commons.collections.CollectionUtils; 022 import org.joda.time.DateTime; 023 import org.junit.After; 024 import org.junit.Assert; 025 import org.junit.Before; 026 import org.junit.Test; 027 import org.kuali.hr.test.KPMETestCase; 028 import org.kuali.hr.time.calendar.CalendarEntries; 029 import org.kuali.hr.time.service.base.TkServiceLocator; 030 import org.kuali.hr.time.util.TKUtils; 031 032 public class CalendarEntriesServiceImplTest extends KPMETestCase { 033 private CalendarEntriesService ceService; 034 @Before 035 public void setUp() throws Exception{ 036 super.setUp(); 037 ceService = TkServiceLocator.getCalendarEntriesService(); 038 } 039 040 @After 041 public void tearDown() throws Exception { 042 super.tearDown(); 043 } 044 045 @Test 046 public void testGetAllCalendarEntriesForCalendarId() { 047 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarId("2"); 048 Assert.assertTrue("Calendar entries not found for Calendar Id '2'", CollectionUtils.isNotEmpty(ceList)); 049 } 050 @Test 051 public void testGetAllCalendarEntriesForCalendarIdAndYear() { 052 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdAndYear("2", "2012"); 053 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and year '2012'", CollectionUtils.isNotEmpty(ceList)); 054 Assert.assertTrue("There should be 24 Calendar entries, not " + ceList.size(), ceList.size() == 24); 055 } 056 057 @Test 058 public void testGetAllCalendarEntriesForCalendarIdUpToPlanningMonths() { 059 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdUpToPlanningMonths("2", "admin"); 060 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and principalId 'admin'", CollectionUtils.isNotEmpty(ceList)); 061 } 062 063 @Test 064 public void testGetAllCalendarEntriesForCalendarIdUpToCutOffTime() { 065 Date aDate = new Date((new DateTime(2012,10,31,0,0,0,0, TKUtils.getSystemDateTimeZone())).getMillis()); 066 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdUpToCutOffTime("2", aDate); 067 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and date ", CollectionUtils.isNotEmpty(ceList)); 068 Assert.assertTrue("There should be 67 Calendar entries, not " + ceList.size(), ceList.size() == 67); 069 } 070 } 071 072