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.position;
17  
18  import java.util.*;
19  
20  import org.joda.time.LocalDate;
21  import org.junit.Assert;
22  import org.junit.Test;
23  import org.kuali.kpme.pm.api.position.Position;
24  import org.kuali.kpme.pm.api.position.PstnFlag;
25  
26  public class PstnFlagBoTest {
27  	private static Map<String, PstnFlag> testPstnFlagBos;
28  	public static PstnFlag.Builder pstnFlagBuilder = PstnFlag.Builder.create();
29  	static LocalDate currentTime = new LocalDate();
30  
31  	static {
32  
33  		testPstnFlagBos = new HashMap<String, PstnFlag>();
34  		
35  		List<String> names = new ArrayList<String>();
36  		names.add("Name1");
37  		pstnFlagBuilder.setCategory("CAT");
38  		pstnFlagBuilder.setHrPositionId("");
39  		pstnFlagBuilder.setNames(names);
40  		pstnFlagBuilder.setObjectId("0804716a-cbb7-11e3-9cd3-51a754ad6a0a");
41  		pstnFlagBuilder.setEffectiveLocalDateOfOwner(currentTime);
42  //		pstnFlagBuilder.setOwner(Position.Builder.create(PositionDataBoTest.getPosition("TST-PSTN")));
43  		pstnFlagBuilder.setPmFlagId("TST-PSTNFLAG");
44  		pstnFlagBuilder.setVersionNumber(1L);
45  		
46  		
47  		testPstnFlagBos.put(pstnFlagBuilder.getPmFlagId(),pstnFlagBuilder.build());
48  		System.out.println(testPstnFlagBos);
49  	}
50  
51  	@Test
52      public void testNotEqualsWithGroup() {
53      	PstnFlag immutable = PstnFlagBoTest.getPstnFlag("TST-PSTNFLAG");
54      	PstnFlagBo bo = PstnFlagBo.from(immutable);
55      	
56      	PositionBo positionBo = new PositionBo();
57  		positionBo.setEffectiveLocalDate(currentTime);
58  		bo.setOwner(positionBo);
59      	
60          Assert.assertFalse(bo.equals(immutable));
61          Assert.assertFalse(immutable.equals(bo));
62          Assert.assertEquals(immutable, PstnFlagBo.to(bo));
63      }
64  
65      public static PstnFlag getPstnFlag(String pstnFlag) {
66           PstnFlag pstnFlag1 = testPstnFlagBos.get(pstnFlag);
67           return pstnFlag1;
68      }
69  
70  }