83a215779705f413c8b3f5c397a92c738b978942
[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         assertTrue(actionId1.equals(actionId1));
66         assertFalse(actionId1.equals(null));
67         assertFalse(actionId1.equals(""));
68         ActionIdentifier actionId2 = new ActionIdentifier();
69         actionId2.setVnfId("other_vnfId");
70         assertFalse(actionId1.equals(actionId2));
71         actionId1.setVnfId("vnfId");
72         assertFalse(actionId1.equals(actionId2));
73         actionId2.setVnfId("vnfId");
74
75         actionId2.setVnfcName("other_vnfcName");
76         assertFalse(actionId1.equals(actionId2));
77         actionId1.setVnfcName("vnfc_name");
78         assertFalse(actionId1.equals(actionId2));
79         actionId2.setVnfcName("vnfc_name");
80         actionId2.setVserverId("other_vserverId");
81         assertFalse(actionId1.equals(actionId2));
82         actionId1.setVserverId("vserverId");
83         assertFalse(actionId1.equals(actionId2));
84         actionId2.setVserverId("vserverId");
85         assertEquals(actionId2, actionId1);
86     }
87
88     @Test
89     public void testSettersAndGetters() {
90         ActionIdentifier actionId = new ActionIdentifier();
91         actionId.setVserverId("vserverId");
92         assertEquals("vserverId", actionId.getVserverId());
93
94         actionId.setVnfcName("vnfcName");
95         assertEquals("vnfcName", actionId.getVnfcName());
96
97         actionId.setVnfId("vnfId");
98         assertEquals("vnfId", actionId.getVnfId());
99     }
100
101     @Test
102     public void testtoString() {
103         ActionIdentifier actionId = new ActionIdentifier();
104         actionId.setVnfcName("vnfcName");
105         String ret = actionId.toString();
106         assertFalse("toString is not empty", ret.isEmpty());
107     }
108
109 }