2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.flow.controller.data;
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;
31 public class ActionIdentifierTest {
34 public void testHashCode() {
35 ActionIdentifier actionId1 = new ActionIdentifier();
36 ActionIdentifier actionId2 = new ActionIdentifier();
37 assertTrue(actionId1.hashCode() == actionId2.hashCode());
39 if (actionId1.equals(actionId2)) {
40 assertTrue(actionId1.hashCode() == actionId2.hashCode());
43 actionId2.setVnfcName("vnfcName");
44 assertFalse(actionId1.hashCode() == actionId2.hashCode());
46 actionId2.setVnfcName("");
47 assertTrue(actionId1.hashCode() == actionId2.hashCode());
49 actionId2.setVnfId("vnfId");
50 assertFalse(actionId1.hashCode() == actionId2.hashCode());
52 actionId2.setVnfId("");
53 assertTrue(actionId1.hashCode() == actionId2.hashCode());
55 actionId2.setVserverId("vserverId");
56 assertFalse(actionId1.hashCode() == actionId2.hashCode());
58 actionId2.setVserverId("");
59 assertTrue(actionId1.hashCode() == actionId2.hashCode());
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");
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);
89 public void testSettersAndGetters() {
90 ActionIdentifier actionId = new ActionIdentifier();
91 actionId.setVserverId("vserverId");
92 assertEquals("vserverId", actionId.getVserverId());
94 actionId.setVnfcName("vnfcName");
95 assertEquals("vnfcName", actionId.getVnfcName());
97 actionId.setVnfId("vnfId");
98 assertEquals("vnfId", actionId.getVnfId());
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());