summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-11-07 12:50:47 +0000
committerGerrit Code Review <gerrit@onap.org>2017-11-07 12:50:47 +0000
commitc4dec61512ccd123f791b319ff457d861a67c113 (patch)
tree444446330ecfc04e1d95a46bc2c2e6b36ca4a7b0
parentc6a41de2f5a2e3217c8364dcd27f297069fc005f (diff)
parent280d31feb0585132610e0079234a562a3c0577a1 (diff)
Merge "Test Cases for the Port scaling Utility"
-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);
+ }
+}