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.classification.flag;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.joda.time.LocalDate;
24  import org.junit.Assert;
25  import org.junit.Test;
26  import org.kuali.kpme.pm.api.classification.Classification;
27  import org.kuali.kpme.pm.api.classification.flag.ClassificationFlag;
28  import org.kuali.kpme.pm.classification.ClassificationBo;
29  import org.kuali.kpme.pm.classification.ClassificationBoTest;
30  
31  public class ClassificationFlagBoTest {
32  
33  
34  	private static Map<String, ClassificationFlag> testClassificationFlagBos;
35  	public static ClassificationFlag.Builder classificationFlagBuilder = ClassificationFlag.Builder.create();
36  	public static LocalDate currentTime = LocalDate.now();
37  	
38  	static{
39  		testClassificationFlagBos = new HashMap<String, ClassificationFlag>();
40  		
41  		classificationFlagBuilder.setObjectId("0804716a-cbb7-11e3-9cd3-51a754ad6a0a");
42  		classificationFlagBuilder.setVersionNumber(1l);
43  		List<String> names = new ArrayList<String>();
44  		names.add("Name1");
45  		classificationFlagBuilder.setNames(names);
46  		classificationFlagBuilder.setCategory("CAT");
47  		classificationFlagBuilder.setPmFlagId("TST-CLSFCTNFLAG");
48  		classificationFlagBuilder.setPmPositionClassId("TST-PMCLASSID");
49  		classificationFlagBuilder.setEffectiveLocalDateOfOwner(currentTime);
50  		
51  		testClassificationFlagBos.put(classificationFlagBuilder.getPmFlagId(), classificationFlagBuilder.build());
52  		
53  	}
54  		
55  	@Test
56      public void testNotEqualsWithGroup() {
57      	ClassificationFlag immutable = ClassificationFlagBoTest.getClassificationFlag("TST-CLSFCTNFLAG");
58      	ClassificationFlagBo bo = ClassificationFlagBo.from(immutable);
59      	
60      	ClassificationBo classificationBo = new ClassificationBo();
61      	classificationBo.setEffectiveLocalDate(currentTime);
62      	bo.setOwner(classificationBo);
63  
64          Assert.assertFalse(bo.equals(immutable));
65          Assert.assertFalse(immutable.equals(bo));
66          Assert.assertEquals(immutable, ClassificationFlagBo.to(bo));
67      }
68  
69      public static ClassificationFlag getClassificationFlag(String classificationFlag) {
70          return testClassificationFlagBos.get(classificationFlag);
71      }
72  }