Test Cases for the Port scaling Utility 05/22505/1
authorsiddharth0905 <siddharth.singh4@amdocs.com>
Tue, 7 Nov 2017 11:30:31 +0000 (17:00 +0530)
committersiddharth0905 <siddharth.singh4@amdocs.com>
Tue, 7 Nov 2017 11:30:31 +0000 (17:00 +0530)
Test cases to cover all possible scenario which might come as port type.

Change-Id: Icdfa35fea52cba86bc5128fad3ec2f857c1d6079
Issue-ID: SDC-573
Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java [new file with mode: 0644]

diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java
new file mode 100644 (file)
index 0000000..019d143
--- /dev/null
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.translator.services.heattotosca;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+
+public class ConsolidationDataUtilTest {
+    private static final String PORT_TYPE_FORMAT_1 = "a_11_network_port_22";
+    private static final String PORT_TYPE_FORMAT_2 = "a_11_network_port22";
+    private static final String PORT_TYPE_FORMAT_3 = "a_network_port_22";
+    private static final String PORT_TYPE_FORMAT_4 = "a_network_port22";
+    private static final String PORT_TYPE_FORMAT_5 = "network_port_22";
+    private static final String PORT_TYPE_FORMAT_6 = "network_port22";
+    private static final String PORT_TYPE_FORMAT_7 = "a_network_11_port22";
+    private static final String PORT_TYPE_OUTPUT_1 = "a_network_port";
+    private static final String PORT_TYPE_OUTPUT_2 = "network_port";
+    private static final String PORT_TYPE_OUTPUT_3 = "a_network_11_port";
+
+    @Test
+    public void testGetPortType_Empty() throws Exception {
+        String port = "";
+        assertEquals(ConsolidationDataUtil.getPortType(port), port);
+    }
+
+    @Test
+    public void testGetPortType_Spaces() throws Exception {
+        String port = "   ";
+        assertEquals(ConsolidationDataUtil.getPortType(port), port);
+    }
+
+    @Test
+    public void testGetPortType_Null() throws Exception {
+        String port = null;
+        assertEquals(ConsolidationDataUtil.getPortType(port), port);
+    }
+
+    @Test
+    public void testGetPortType_OnlyPortType() throws Exception {
+        String port = "network";
+        assertEquals(ConsolidationDataUtil.getPortType(port), port);
+    }
+
+    @Test
+    public void testGetPortType_WithServerAndPortIndex() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_1), PORT_TYPE_OUTPUT_1);
+    }
+
+    @Test
+    public void testGetPortType_Input_WithServerAndPortIndexWithoutUnderscore() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_2), PORT_TYPE_OUTPUT_1);
+    }
+
+    @Test
+    public void testGetPortType_Input_WithoutServerIndexAndWithPortIndex() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_3), PORT_TYPE_OUTPUT_1);
+    }
+
+    @Test
+    public void testGetPortType_Input_WithoutServerIndexAndWithPortIndexWithoutUnderscore() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_4), PORT_TYPE_OUTPUT_1);
+    }
+
+    @Test
+    public void testGetPortType_Input_PortTypeWithIndex() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_5), PORT_TYPE_OUTPUT_2);
+    }
+
+    @Test
+    public void testGetPortType_Input_PortIndexWithoutUnderscore() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_6), PORT_TYPE_OUTPUT_2);
+    }
+
+    @Test
+    public void testGetPortType_Input_PortIndexAndDigitInBetween() throws Exception {
+        assertEquals(ConsolidationDataUtil.getPortType(PORT_TYPE_FORMAT_7), PORT_TYPE_OUTPUT_3);
+    }
+}