Add Junit coverage for ActionIdentifier class 05/38105/3
authorNeha Sood <ns189k@att.com>
Fri, 23 Mar 2018 14:19:28 +0000 (10:19 -0400)
committerTakamune Cho <tc012c@att.com>
Fri, 23 Mar 2018 15:18:59 +0000 (15:18 +0000)
Introduce junit tests for ActionIdentifier class

Change-Id: If14abe7b165d310d693d0d3ea04b563c0b68edd4
Issue-ID: APPC-777
Signed-off-by: Neha Sood <ns189k@att.com>
appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/ActionIdentifierTest.java [new file with mode: 0644]

diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/ActionIdentifierTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/ActionIdentifierTest.java
new file mode 100644 (file)
index 0000000..220e791
--- /dev/null
@@ -0,0 +1,91 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.appc.flow.controller.data;\r
+\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Test;\r
+\r
+public class ActionIdentifierTest {\r
+\r
+    @Test\r
+    public void testHashCode() {\r
+        ActionIdentifier actionId1 = new ActionIdentifier();\r
+        ActionIdentifier actionId2 = new ActionIdentifier();\r
+        assertTrue(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        if (actionId1.equals(actionId2)) {\r
+            assertTrue(actionId1.hashCode() == actionId2.hashCode());\r
+        }\r
+\r
+        actionId2.setVnfcName("vnfcName");\r
+        assertFalse(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        actionId2.setVnfcName("");\r
+        assertTrue(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        actionId2.setVnfId("vnfId");\r
+        assertFalse(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        actionId2.setVnfId("");\r
+        assertTrue(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        actionId2.setVserverId("vserverId");\r
+        assertFalse(actionId1.hashCode() == actionId2.hashCode());\r
+\r
+        actionId2.setVserverId("");\r
+        assertTrue(actionId1.hashCode() == actionId2.hashCode());\r
+    }\r
+\r
+    @Test\r
+    public void testEquals() {\r
+        ActionIdentifier actionId1 = new ActionIdentifier();\r
+        ActionIdentifier actionId2 = new ActionIdentifier();\r
+\r
+        assertTrue(actionId1.equals(actionId2) && actionId2.equals(actionId1));\r
+        assertTrue(actionId1.equals(actionId1));\r
+        assertFalse(actionId1.equals(null));\r
+    }\r
+\r
+    @Test\r
+    public void testSettersAndGetters() {\r
+        ActionIdentifier actionId = new ActionIdentifier();\r
+        actionId.setVserverId("vserverId");\r
+        assertEquals("vserverId", actionId.getVserverId());\r
+\r
+        actionId.setVnfcName("vnfcName");\r
+        assertEquals("vnfcName", actionId.getVnfcName());\r
+\r
+        actionId.setVnfId("vnfId");\r
+        assertEquals("vnfId", actionId.getVnfId());\r
+    }\r
+\r
+    @Test\r
+    public void testtoString() {\r
+        ActionIdentifier actionId = new ActionIdentifier();\r
+        actionId.setVnfcName("vnfcName");\r
+        String ret = actionId.toString();\r
+        assertFalse("toString is not empty", ret.isEmpty());\r
+    }\r
+\r
+}\r