View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.core.calendar;
17  
18  import org.joda.time.DateTimeConstants;
19  import org.joda.time.LocalTime;
20  import org.junit.Assert;
21  import org.junit.Test;
22  import org.kuali.kpme.core.api.calendar.Calendar;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  /**
28   * Created by jjhanso on 4/24/14.
29   */
30  public class CalendarBoTest {
31      private static Map<String, Calendar> testCalendars;
32      static {
33          testCalendars = new HashMap<String, Calendar>();
34          Calendar.Builder b = Calendar.Builder.create();
35          b.setCalendarDescriptions("Test Description");
36          b.setCalendarName("BWS-CAL");
37          b.setCalendarTypes("Pay");
38          b.setFlsaBeginDay("Sun");
39          b.setFlsaBeginLocalTime(new LocalTime(12, 0));
40          b.setFlsaBeginDayConstant(DateTimeConstants.SUNDAY);
41          b.setHrCalendarId("KPME_TEST_0001");
42          b.setVersionNumber(1L);
43          b.setObjectId("d9e94e3a-cbb7-11e3-9cd3-51a754ad6a0a");
44          testCalendars.put(b.getCalendarName(), b.build());
45  
46          b.setCalendarName("LM");
47          b.setCalendarTypes("Leave");
48          b.setHrCalendarId("KPME_TEST_0002");
49          testCalendars.put(b.getCalendarName(), b.build());
50      }
51  
52      public static Calendar getTestCalendar(String calendarName) {
53          return testCalendars.get(calendarName);
54      }
55  
56      @Test
57      public void testCalendarConversions() {
58          Calendar immutable = CalendarBoTest.getTestCalendar("BWS-CAL");
59          CalendarBo bo = CalendarBo.from(immutable);
60          //mockIdentityService
61          Assert.assertFalse(bo.equals(immutable));
62          Assert.assertFalse(immutable.equals(bo));
63          Assert.assertEquals(immutable, CalendarBo.to(bo));
64      }
65  }