1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar.service;
17
18 import java.util.Date;
19 import java.util.List;
20
21 import org.apache.commons.collections.CollectionUtils;
22 import org.joda.time.DateTime;
23 import org.junit.After;
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.kuali.hr.test.KPMETestCase;
28 import org.kuali.hr.time.calendar.CalendarEntries;
29 import org.kuali.hr.time.service.base.TkServiceLocator;
30 import org.kuali.hr.time.util.TKUtils;
31
32 public class CalendarEntriesServiceImplTest extends KPMETestCase {
33 private CalendarEntriesService ceService;
34 @Before
35 public void setUp() throws Exception{
36 super.setUp();
37 ceService = TkServiceLocator.getCalendarEntriesService();
38 }
39
40 @After
41 public void tearDown() throws Exception {
42 super.tearDown();
43 }
44
45 @Test
46 public void testGetAllCalendarEntriesForCalendarId() {
47 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarId("2");
48 Assert.assertTrue("Calendar entries not found for Calendar Id '2'", CollectionUtils.isNotEmpty(ceList));
49 }
50 @Test
51 public void testGetAllCalendarEntriesForCalendarIdAndYear() {
52 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdAndYear("2", "2012");
53 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and year '2012'", CollectionUtils.isNotEmpty(ceList));
54 Assert.assertTrue("There should be 24 Calendar entries, not " + ceList.size(), ceList.size() == 24);
55 }
56
57 @Test
58 public void testGetAllCalendarEntriesForCalendarIdUpToPlanningMonths() {
59 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdUpToPlanningMonths("2", "admin");
60 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and principalId 'admin'", CollectionUtils.isNotEmpty(ceList));
61 }
62
63 @Test
64 public void testGetAllCalendarEntriesForCalendarIdUpToCutOffTime() {
65 Date aDate = new Date((new DateTime(2012,10,31,0,0,0,0, TKUtils.getSystemDateTimeZone())).getMillis());
66 List<CalendarEntries> ceList= ceService.getAllCalendarEntriesForCalendarIdUpToCutOffTime("2", aDate);
67 Assert.assertTrue("Calendar entries not found for Calendar Id '2' and date ", CollectionUtils.isNotEmpty(ceList));
68 Assert.assertTrue("There should be 67 Calendar entries, not " + ceList.size(), ceList.size() == 67);
69 }
70 }
71
72