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.position;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.joda.time.LocalDate;
22  import org.junit.Assert;
23  import org.junit.Test;
24  import org.kuali.kpme.core.api.groupkey.HrGroupKey;
25  import org.kuali.kpme.core.api.position.PositionBase;
26  import org.kuali.kpme.core.groupkey.HrGroupKeyBoTest;
27  
28  public class PositionBaseBoTest {
29  	
30  	private static Map<String, PositionBase> testPositionBaseBos;
31  	public static PositionBase.Builder PositionBaseBuilder = PositionBase.Builder.create("TST-PSTNNUM");
32  	private static final LocalDate currentTime = new LocalDate();
33  	
34  	static {
35  		testPositionBaseBos = new HashMap<String, PositionBase>();
36  		PositionBaseBuilder.setActive(true);
37  		PositionBaseBuilder.setPositionNumber("TST-PSTNNUM");
38  		PositionBaseBuilder.setHrPositionId("TST-PSTNID");
39  		PositionBaseBuilder.setDescription("Testing");
40  		PositionBaseBuilder.setGroupKeyCode("ISU-IA");
41  		PositionBaseBuilder.setGroupKey(HrGroupKey.Builder.create(HrGroupKeyBoTest.getTestHrGroupKey("ISU-IA")));
42  		PositionBaseBuilder.setId(PositionBaseBuilder.getHrPositionId());
43  		PositionBaseBuilder.setVersionNumber(1L);
44  		PositionBaseBuilder.setEffectiveLocalDate(currentTime);
45  		PositionBaseBuilder.setObjectId("0804716a-cbb7-11e3-9cd3-51a754ad6a0a");
46  		testPositionBaseBos.put(PositionBaseBuilder.getPositionNumber(), PositionBaseBuilder.build());
47  	}
48  	
49  	@Test
50      public void testNotEqualsWithGroup() {
51  		PositionBase immutable = PositionBaseBoTest.getPositionBase("TST-PSTNNUM");
52  		PositionBaseBo bo = PositionBaseBo.from(immutable);
53          Assert.assertFalse(bo.equals(immutable));
54          Assert.assertFalse(immutable.equals(bo));
55          Assert.assertEquals(immutable, PositionBaseBo.to(bo));
56      }
57  	
58      public static PositionBase getPositionBase(String positionNumber) {
59          return testPositionBaseBos.get(positionNumber);
60      }
61  
62  }