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