From f892e78757872bdb811e6b08fe2bfcba3ebb54fc Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Mon, 15 Apr 2019 14:08:38 +0200 Subject: add junit coverage for HeatBridgeUtils Change-Id: Ibea7e60ac8e8b511e2a6a6ab54b2072e7e8d4008 Issue-ID: SO-414 Signed-off-by: Lukasz Muszkieta --- .../onap/so/heatbridge/utils/HeatBridgeUtils.java | 11 -------- .../so/heatbridge/utils/HeatBridgeUtilsTest.java | 31 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java (limited to 'adapters') diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java index d3faf1d7bf..9726197172 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java @@ -44,15 +44,4 @@ public class HeatBridgeUtils { } return Optional.empty(); } - - public static Optional getMatchingPhysicalNetworkName(final String pserverPinterfaceName) { - if (pserverPinterfaceName.contains(COMPUTE_SIDE_DEDICATED_SRIOV_PREFIX)) { - return Optional.of( - pserverPinterfaceName.replace(COMPUTE_SIDE_DEDICATED_SRIOV_PREFIX, OS_SIDE_DEDICATED_SRIOV_PREFIX)); - } else if (pserverPinterfaceName.contains(COMPUTE_SIDE_SHARED_SRIOV_PREFIX)) { - return Optional - .of(pserverPinterfaceName.replace(COMPUTE_SIDE_SHARED_SRIOV_PREFIX, OS_SIDE_SHARED_SRIOV_PREFIX)); - } - return Optional.empty(); - } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java new file mode 100644 index 0000000000..bbc99bd258 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java @@ -0,0 +1,31 @@ +package org.onap.so.heatbridge.utils; + +import static org.assertj.core.api.Assertions.assertThat; +import java.util.Optional; +import org.junit.Test; + +public class HeatBridgeUtilsTest { + + @Test(expected = IllegalStateException.class) + public void matchServerName_canNotBeNull() { + HeatBridgeUtils.getMatchingPserverPifName(null); + } + + @Test + public void matchServerName_isDedicated() { + Optional serverName = HeatBridgeUtils.getMatchingPserverPifName("dedicated-testServer"); + assertThat(serverName).isNotEmpty().hasValue("sriov-d-testServer"); + } + + @Test + public void matchServerName_isShared() { + Optional serverName = HeatBridgeUtils.getMatchingPserverPifName("shared-testServer"); + assertThat(serverName).isNotEmpty().hasValue("sriov-s-testServer"); + } + + @Test + public void matchServerName_unknown() { + Optional serverName = HeatBridgeUtils.getMatchingPserverPifName("differentServerName"); + assertThat(serverName).isEmpty(); + } +} -- cgit 1.2.3-korg