summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth0905 <siddharth.singh4@amdocs.com>2017-11-07 17:00:31 +0530
committersiddharth0905 <siddharth.singh4@amdocs.com>2017-11-07 17:00:31 +0530
commit280d31feb0585132610e0079234a562a3c0577a1 (patch)
treeb3089f3b1cf6d0254fdb27be6238da18c2745780
parentd5fdfc4e67ba9839e680fa685134660659356c68 (diff)
Test Cases for the Port scaling Utility
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>
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java76
2 files changed, 77 insertions, 1 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
index a09d56672d..0a94d2a3d9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
@@ -527,7 +527,7 @@ public class ConsolidationDataUtil {
*/
public static String getPortType(String portNodeTemplateId) {
- if (!StringUtils.isNotBlank(portNodeTemplateId)) {
+ if (StringUtils.isBlank(portNodeTemplateId)) {
return portNodeTemplateId;
}
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
index 0000000000..019d143792
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java
@@ -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);
+ }
+}