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.leaveplan;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.LocalDate;
20  import org.joda.time.LocalTime;
21  import org.junit.Assert;
22  import org.junit.Test;
23  import org.kuali.kpme.core.api.leaveplan.LeavePlan;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  /**
29   * Created by jjhanso on 4/24/14.
30   */
31  public class LeavePlanBoTest {
32      private static Map<String, LeavePlan> testLeavePlans;
33      static {
34          testLeavePlans = new HashMap<String, LeavePlan>();
35          LeavePlan.Builder b = LeavePlan.Builder.create("LEAVE");
36  
37          b.setVersionNumber(1L);
38          b.setBatchPriorYearCarryOverStartLocalTime(new LocalTime(20, 0));
39          b.setPlanningMonths("12");
40          b.setLmLeavePlanId("KPME_TEST_001");
41          b.setDescr("Leave Plan");
42          b.setCalendarYearStart("01/01");
43          b.setBatchPriorYearCarryOverStartDate("02/01");
44          b.setVersionNumber(1L);
45          b.setActive(true);
46          b.setId(b.getLmLeavePlanId());
47          b.setEffectiveLocalDate(new LocalDate(2010, 1, 1));
48          b.setCreateTime(DateTime.now());
49          b.setObjectId("ac1c2c7c-cbba-11e3-9cd3-51a754ad6a0a");
50          testLeavePlans.put(b.getLeavePlan(), b.build());
51  
52      }
53  
54      public static LeavePlan getLeavePlan(String leavePlan) {
55          return testLeavePlans.get(leavePlan);
56      }
57  
58      @Test
59      public void testLeavePlanConversions() {
60          LeavePlan immutable = LeavePlanBoTest.getLeavePlan("LEAVE");
61          LeavePlanBo bo = LeavePlanBo.from(immutable);
62          //mockIdentityService
63          Assert.assertFalse(bo.equals(immutable));
64          Assert.assertFalse(immutable.equals(bo));
65          Assert.assertEquals(immutable, LeavePlanBo.to(bo));
66      }
67  }