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.pm.appointment;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.joda.time.DateTime;
22  import org.joda.time.LocalDate;
23  import org.junit.Assert;
24  import org.junit.Test;
25  import org.kuali.kpme.core.api.groupkey.HrGroupKey;
26  import org.kuali.kpme.core.groupkey.HrGroupKeyBoTest;
27  import org.kuali.kpme.pm.api.positionappointment.PositionAppointment;
28  import org.kuali.kpme.pm.positionappointment.PositionAppointmentBo;
29  
30  public class PositionAppointmentBoTest {
31  	private static Map<String, PositionAppointment> testPositionAppointmentBos;
32  	public static PositionAppointment.Builder positionAppointmentBuilder = PositionAppointment.Builder.create("ISU-IA", "TST-PSTNAPPMNT");
33  	
34  	static {
35  		testPositionAppointmentBos = new HashMap<String, PositionAppointment>();
36  		positionAppointmentBuilder.setGroupKeyCode("ISU-IA");
37  		positionAppointmentBuilder.setDescription("Testing Immutable PositionAppointment");
38  		positionAppointmentBuilder.setPositionAppointment("TST-PSTNAPPMNT");
39  		positionAppointmentBuilder.setUserPrincipalId("admin");
40  		
41  		positionAppointmentBuilder.setPmPositionAppointmentId("KPME_TEST_0001");
42  		positionAppointmentBuilder.setVersionNumber(1L);
43  		positionAppointmentBuilder.setObjectId("0804716a-cbb7-11e3-9cd3-51a754ad6a0a");
44  		positionAppointmentBuilder.setActive(true);
45  		positionAppointmentBuilder.setId(positionAppointmentBuilder.getPmPositionAppointmentId());
46  		positionAppointmentBuilder.setEffectiveLocalDate(new LocalDate(2012, 3, 1));
47  		positionAppointmentBuilder.setCreateTime(DateTime.now());
48  		
49  		// Set GroupKeycode Object
50  		positionAppointmentBuilder.setGroupKey(HrGroupKey.Builder.create(HrGroupKeyBoTest.getTestHrGroupKey("ISU-IA")));
51  		testPositionAppointmentBos.put(positionAppointmentBuilder.getPositionAppointment(), positionAppointmentBuilder.build());
52  	}
53  	
54      @Test
55      public void testNotEqualsWithGroup() {
56      	PositionAppointment immutable = PositionAppointmentBoTest.getPositionAppointment("TST-PSTNAPPMNT");
57      	PositionAppointmentBo bo = PositionAppointmentBo.from(immutable);
58          Assert.assertFalse(bo.equals(immutable));
59          Assert.assertFalse(immutable.equals(bo));
60          Assert.assertEquals(immutable, PositionAppointmentBo.to(bo));
61      }
62  
63      public static PositionAppointment getPositionAppointment(String positionAppointment) {
64          return testPositionAppointmentBos.get(positionAppointment);
65      }
66  }