cc0ed3dd4a2d53c7737ce24ea1200f310f511610
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / controller / data / ActionIdentifierTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * =============================================================================
7  * Modifications Copyright (C) 2018-2019 IBM.
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * ============LICENSE_END=========================================================
22  */
23  
24 package org.onap.appc.flow.controller.data;
25
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.assertFalse;
28 import static org.junit.Assert.assertEquals;
29 import org.junit.Test;
30
31 public class ActionIdentifierTest {
32
33     @Test
34     public void testHashCode() {
35         ActionIdentifier actionId1 = new ActionIdentifier();
36         ActionIdentifier actionId2 = new ActionIdentifier();
37         assertTrue(actionId1.hashCode() == actionId2.hashCode());
38
39         if (actionId1.equals(actionId2)) {
40             assertTrue(actionId1.hashCode() == actionId2.hashCode());
41         }
42
43         actionId2.setVnfcName("vnfcName");
44         assertFalse(actionId1.hashCode() == actionId2.hashCode());
45
46         actionId2.setVnfcName("");
47         assertTrue(actionId1.hashCode() == actionId2.hashCode());
48
49         actionId2.setVnfId("vnfId");
50         assertFalse(actionId1.hashCode() == actionId2.hashCode());
51
52         actionId2.setVnfId("");
53         assertTrue(actionId1.hashCode() == actionId2.hashCode());
54
55         actionId2.setVserverId("vserverId");
56         assertFalse(actionId1.hashCode() == actionId2.hashCode());
57
58         actionId2.setVserverId("");
59         assertTrue(actionId1.hashCode() == actionId2.hashCode());
60     }
61
62     @Test
63     public void testEquals() {
64         ActionIdentifier actionId1 = new ActionIdentifier();
65         ActionIdentifier actionId2 = new ActionIdentifier();
66         
67         actionId1.setVnfcName("vnfcName");
68         actionId1.setVnfId("vnfId");
69         actionId1.setVserverId("vserverId");
70         actionId2.setVnfcName("vnfcName");
71         actionId2.setVnfId("vnfId");
72         actionId2.setVserverId("vserverId");
73         assertEquals(actionId1,actionId2);
74         assertEquals(actionId2,actionId1);
75     }
76
77     @Test
78     public void testSettersAndGetters() {
79         ActionIdentifier actionId = new ActionIdentifier();
80         actionId.setVserverId("vserverId");
81         assertEquals("vserverId", actionId.getVserverId());
82
83         actionId.setVnfcName("vnfcName");
84         assertEquals("vnfcName", actionId.getVnfcName());
85
86         actionId.setVnfId("vnfId");
87         assertEquals("vnfId", actionId.getVnfId());
88     }
89
90     @Test
91     public void testtoString() {
92         ActionIdentifier actionId = new ActionIdentifier();
93         actionId.setVnfcName("vnfcName");
94         String ret = actionId.toString();
95         assertFalse("toString is not empty", ret.isEmpty());
96     }
97
98 }