From 327b17ab250b4c17cf3f91f5e4cd9bffd89f3d1e Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 7 Mar 2018 18:17:22 -0800 Subject: Reduce log noise/warnings format to conventions Reduce build log warnings by formatting tests to ONAP code conventions (removing tabs etc.) Issue-ID: SO-368 Change-Id: I48c6d359b83617aebeb79db4e30c1d72d31f7eec Signed-off-by: Marcus G K Williams --- .../mso/adapter_utils/tests/AdapterBeansTest.java | 235 +++++++++++---------- .../adapter_utils/tests/MsoCommonUtilsTest.java | 108 +++++----- .../mso/adapter_utils/tests/MsoHeatUtilsTest.java | 224 ++++++++++---------- .../tests/MsoHeatUtilsWithUpdateTest.java | 77 +++---- 4 files changed, 321 insertions(+), 323 deletions(-) (limited to 'adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils') diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java index 250211845f..045b62df85 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.junit.Test; import org.openecomp.mso.entity.MsoRequest; import org.openecomp.mso.openstack.beans.MsoTenant; @@ -35,125 +36,125 @@ import org.openecomp.mso.openstack.beans.Subnet; import org.openecomp.mso.openstack.beans.VnfRollback; public class AdapterBeansTest { - @Test - public final void msoTenantTest() { - MsoTenant tenant = new MsoTenant(); - tenant.setTenantId("1"); - assertTrue(tenant.getTenantId().equalsIgnoreCase("1")); - tenant.setTenantName("TenantName"); - assertTrue(tenant.getTenantName().equalsIgnoreCase("TenantName")); - Map hm = new HashMap<>(); - hm.put("Key1", "value1"); - tenant.setMetadata(hm); - assertTrue(tenant.getMetadata() != null); - new MsoTenant("1", "TenantName", hm); - // assertTrue(tenant.toString() != null); - } + @Test + public final void msoTenantTest() { + MsoTenant tenant = new MsoTenant(); + tenant.setTenantId("1"); + assertTrue(tenant.getTenantId().equalsIgnoreCase("1")); + tenant.setTenantName("TenantName"); + assertTrue(tenant.getTenantName().equalsIgnoreCase("TenantName")); + Map hm = new HashMap<>(); + hm.put("Key1", "value1"); + tenant.setMetadata(hm); + assertTrue(tenant.getMetadata() != null); + new MsoTenant("1", "TenantName", hm); + // assertTrue(tenant.toString() != null); + } - @Test - public final void networkRollbackTest() { - NetworkRollback networkRollback = new NetworkRollback(); - networkRollback.setCloudId("cloudId"); - assertTrue(networkRollback.getCloudId().equalsIgnoreCase("cloudId")); - networkRollback.setModelCustomizationUuid("modelCustomizationUuid"); - assertTrue(networkRollback.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid")); - MsoRequest msoRequest = new MsoRequest(); - networkRollback.setMsoRequest(msoRequest); - networkRollback.getMsoRequest(); - // assertTrue(networkRollback.getMsoRequest() == null); - networkRollback.setNetworkCreated(Boolean.TRUE); - assertTrue(networkRollback.getNetworkCreated()); - networkRollback.setNetworkId("networkId"); - assertTrue(networkRollback.getNetworkId().equalsIgnoreCase("networkId")); - networkRollback.setNetworkName("networkName"); - assertTrue(networkRollback.getNetworkName().equalsIgnoreCase("networkName")); - networkRollback.setNetworkStackId("networkStackId"); - assertTrue(networkRollback.getNetworkStackId().equalsIgnoreCase("networkStackId")); - networkRollback.setNetworkType("networkType"); - assertTrue(networkRollback.getNetworkType().equalsIgnoreCase("networkType")); - networkRollback.setNeutronNetworkId("neutronNetworkId"); - assertTrue(networkRollback.getNeutronNetworkId().equalsIgnoreCase("neutronNetworkId")); - networkRollback.setPhysicalNetwork("physicalNetwork"); - assertTrue(networkRollback.getPhysicalNetwork().equalsIgnoreCase("physicalNetwork")); - networkRollback.setTenantId("tenantId"); - assertTrue(networkRollback.getTenantId().equalsIgnoreCase("tenantId")); - List al = new ArrayList<>(); - al.add(1); - al.add(2); - networkRollback.setVlans(al); - assertTrue(networkRollback.getVlans() != null); - assertTrue(networkRollback.toString() != null); - } + @Test + public final void networkRollbackTest() { + NetworkRollback networkRollback = new NetworkRollback(); + networkRollback.setCloudId("cloudId"); + assertTrue(networkRollback.getCloudId().equalsIgnoreCase("cloudId")); + networkRollback.setModelCustomizationUuid("modelCustomizationUuid"); + assertTrue(networkRollback.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid")); + MsoRequest msoRequest = new MsoRequest(); + networkRollback.setMsoRequest(msoRequest); + networkRollback.getMsoRequest(); + // assertTrue(networkRollback.getMsoRequest() == null); + networkRollback.setNetworkCreated(Boolean.TRUE); + assertTrue(networkRollback.getNetworkCreated()); + networkRollback.setNetworkId("networkId"); + assertTrue(networkRollback.getNetworkId().equalsIgnoreCase("networkId")); + networkRollback.setNetworkName("networkName"); + assertTrue(networkRollback.getNetworkName().equalsIgnoreCase("networkName")); + networkRollback.setNetworkStackId("networkStackId"); + assertTrue(networkRollback.getNetworkStackId().equalsIgnoreCase("networkStackId")); + networkRollback.setNetworkType("networkType"); + assertTrue(networkRollback.getNetworkType().equalsIgnoreCase("networkType")); + networkRollback.setNeutronNetworkId("neutronNetworkId"); + assertTrue(networkRollback.getNeutronNetworkId().equalsIgnoreCase("neutronNetworkId")); + networkRollback.setPhysicalNetwork("physicalNetwork"); + assertTrue(networkRollback.getPhysicalNetwork().equalsIgnoreCase("physicalNetwork")); + networkRollback.setTenantId("tenantId"); + assertTrue(networkRollback.getTenantId().equalsIgnoreCase("tenantId")); + List al = new ArrayList<>(); + al.add(1); + al.add(2); + networkRollback.setVlans(al); + assertTrue(networkRollback.getVlans() != null); + assertTrue(networkRollback.toString() != null); + } - @Test - public final void poolTest() { - Pool p = new Pool(); - p.setStart("start"); - p.getStart(); - p.setEnd("end"); - p.getEnd(); - p.toString(); - } + @Test + public final void poolTest() { + Pool p = new Pool(); + p.setStart("start"); + p.getStart(); + p.setEnd("end"); + p.getEnd(); + p.toString(); + } - @Test - public final void subnetTest() { - Subnet subnet = new Subnet(); - subnet.setAllocationPools(new ArrayList<>()); - subnet.getAllocationPools(); - subnet.setCidr("cidr"); - subnet.getCidr(); - subnet.setDnsNameServers(new ArrayList<>()); - subnet.getDnsNameServers(); - subnet.setEnableDHCP(true); - subnet.getEnableDHCP(); - subnet.setGatewayIp("gatewayIp"); - subnet.getGatewayIp(); - subnet.setHostRoutes(new ArrayList<>()); - subnet.getHostRoutes(); - subnet.setIpVersion("ipVersion"); - subnet.getIpVersion(); - subnet.setNeutronId("neutronId"); - subnet.getNeutronId(); - subnet.setSubnetId("subnetId"); - subnet.getSubnetId(); - subnet.setSubnetName("subnetName"); - subnet.getSubnetName(); - subnet.toString(); - } + @Test + public final void subnetTest() { + Subnet subnet = new Subnet(); + subnet.setAllocationPools(new ArrayList<>()); + subnet.getAllocationPools(); + subnet.setCidr("cidr"); + subnet.getCidr(); + subnet.setDnsNameServers(new ArrayList<>()); + subnet.getDnsNameServers(); + subnet.setEnableDHCP(true); + subnet.getEnableDHCP(); + subnet.setGatewayIp("gatewayIp"); + subnet.getGatewayIp(); + subnet.setHostRoutes(new ArrayList<>()); + subnet.getHostRoutes(); + subnet.setIpVersion("ipVersion"); + subnet.getIpVersion(); + subnet.setNeutronId("neutronId"); + subnet.getNeutronId(); + subnet.setSubnetId("subnetId"); + subnet.getSubnetId(); + subnet.setSubnetName("subnetName"); + subnet.getSubnetName(); + subnet.toString(); + } - @Test - public final void vnfRollbackTest() { - VnfRollback vnfRollback = new VnfRollback(); - new VnfRollback("vnfId", "tenantId", "cloudSiteId", true, true, new MsoRequest(), "volumeGroupName", - "volumeGroupId", "requestType", "modelCustomizationUuid"); - vnfRollback.setBaseGroupHeatStackId("baseGroupHeatStackId"); - vnfRollback.getBaseGroupHeatStackId(); - vnfRollback.setCloudSiteId("cloudId"); - vnfRollback.getCloudSiteId(); - vnfRollback.setIsBase(false); - vnfRollback.isBase(); - vnfRollback.setModelCustomizationUuid("modelCustomizationUuid"); - vnfRollback.getModelCustomizationUuid(); - vnfRollback.setMsoRequest(new MsoRequest()); - vnfRollback.getMsoRequest(); - vnfRollback.setRequestType("requestType"); - vnfRollback.getRequestType(); - vnfRollback.setTenantCreated(true); - vnfRollback.getTenantCreated(); - vnfRollback.setTenantId("tenantId"); - vnfRollback.getTenantId(); - vnfRollback.setVfModuleStackId("vfModuleStackId"); - vnfRollback.getVfModuleStackId(); - vnfRollback.setVnfCreated(true); - vnfRollback.getVnfCreated(); - vnfRollback.setVnfId("vnfId"); - vnfRollback.getVnfId(); - vnfRollback.setVolumeGroupHeatStackId("volumeGroupHeatStackId"); - vnfRollback.getVolumeGroupHeatStackId(); - vnfRollback.setVolumeGroupId("volumeGroupId"); - vnfRollback.getVolumeGroupId(); - vnfRollback.setVolumeGroupName("volumeGroupName"); - vnfRollback.getVolumeGroupName(); - vnfRollback.toString(); - } + @Test + public final void vnfRollbackTest() { + VnfRollback vnfRollback = new VnfRollback(); + new VnfRollback("vnfId", "tenantId", "cloudSiteId", true, true, new MsoRequest(), "volumeGroupName", + "volumeGroupId", "requestType", "modelCustomizationUuid"); + vnfRollback.setBaseGroupHeatStackId("baseGroupHeatStackId"); + vnfRollback.getBaseGroupHeatStackId(); + vnfRollback.setCloudSiteId("cloudId"); + vnfRollback.getCloudSiteId(); + vnfRollback.setIsBase(false); + vnfRollback.isBase(); + vnfRollback.setModelCustomizationUuid("modelCustomizationUuid"); + vnfRollback.getModelCustomizationUuid(); + vnfRollback.setMsoRequest(new MsoRequest()); + vnfRollback.getMsoRequest(); + vnfRollback.setRequestType("requestType"); + vnfRollback.getRequestType(); + vnfRollback.setTenantCreated(true); + vnfRollback.getTenantCreated(); + vnfRollback.setTenantId("tenantId"); + vnfRollback.getTenantId(); + vnfRollback.setVfModuleStackId("vfModuleStackId"); + vnfRollback.getVfModuleStackId(); + vnfRollback.setVnfCreated(true); + vnfRollback.getVnfCreated(); + vnfRollback.setVnfId("vnfId"); + vnfRollback.getVnfId(); + vnfRollback.setVolumeGroupHeatStackId("volumeGroupHeatStackId"); + vnfRollback.getVolumeGroupHeatStackId(); + vnfRollback.setVolumeGroupId("volumeGroupId"); + vnfRollback.getVolumeGroupId(); + vnfRollback.setVolumeGroupName("volumeGroupName"); + vnfRollback.getVolumeGroupName(); + vnfRollback.toString(); + } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java index 73bd67723d..0316e4b74c 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java @@ -47,84 +47,82 @@ import com.woorea.openstack.base.client.OpenStackResponseException; /** * This class implements test methods of the MsoCommonUtils - * - * */ public class MsoCommonUtilsTest extends MsoCommonUtils { - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - @Test - public final void testExecuteAndRecordOpenstackRequest () { - OpenStackRequest openstackRequest = Mockito.mock(OpenStackRequest.class); - Mockito.when(openstackRequest.endpoint()).thenReturn("localhost"); - Mockito.when(openstackRequest.path()).thenReturn("/test"); - //TODO:Must try a real connection - assertNull(super.executeAndRecordOpenstackRequest (openstackRequest)); + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - } + @Test + public final void testExecuteAndRecordOpenstackRequest() { + OpenStackRequest openstackRequest = Mockito.mock(OpenStackRequest.class); + Mockito.when(openstackRequest.endpoint()).thenReturn("localhost"); + Mockito.when(openstackRequest.path()).thenReturn("/test"); + //TODO:Must try a real connection + assertNull(super.executeAndRecordOpenstackRequest(openstackRequest)); - @Test - public final void testKeystoneErrorToMsoException () { - OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + } - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + @Test + public final void testKeystoneErrorToMsoException() { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); - MsoException me = super.keystoneErrorToMsoException (openStackConnectException,"ContextError"); + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response", 1); - assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + MsoException me = super.keystoneErrorToMsoException(openStackConnectException, "ContextError"); + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); - MsoException me2 = super.keystoneErrorToMsoException (openStackResponseException,"ContextError"); - assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); - } + MsoException me2 = super.keystoneErrorToMsoException(openStackResponseException, "ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); - @Test - public final void testHeatExceptionToMsoException () { - OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + } - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + @Test + public final void testHeatExceptionToMsoException() { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); - MsoException me = super.heatExceptionToMsoException (openStackConnectException,"ContextError"); + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response", 1); - assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + MsoException me = super.heatExceptionToMsoException(openStackConnectException, "ContextError"); + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); - MsoException me2 = super.heatExceptionToMsoException (openStackResponseException,"ContextError"); - assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); - } - @Test - public final void testNeutronExceptionToMsoException () { - OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); + MsoException me2 = super.heatExceptionToMsoException(openStackResponseException, "ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + } - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); + @Test + public final void testNeutronExceptionToMsoException() { + OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); - MsoException me = super.neutronExceptionToMsoException (openStackConnectException,"ContextError"); + OpenStackBaseException openStackResponseException = new OpenStackResponseException("response", 1); - assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); + MsoException me = super.neutronExceptionToMsoException(openStackConnectException, "ContextError"); - MsoException me2 = super.neutronExceptionToMsoException (openStackResponseException,"ContextError"); - assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); - } + assertTrue(me instanceof MsoIOException); + assertTrue("connect".equals(me.getMessage())); - @Test - public final void testRuntimeExceptionToMsoException () { - RuntimeException re = new RuntimeException ("runtime"); - MsoException me = super.runtimeExceptionToMsoException (re, "ContextError"); + MsoException me2 = super.neutronExceptionToMsoException(openStackResponseException, "ContextError"); + assertTrue(me2 instanceof MsoOpenstackException); + assertTrue("ContextError".equals(me2.getContext())); + assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); + } - assertTrue (me instanceof MsoAdapterException); - assertTrue("ContextError".equals(me.getContext())); + @Test + public final void testRuntimeExceptionToMsoException() { + RuntimeException re = new RuntimeException("runtime"); + MsoException me = super.runtimeExceptionToMsoException(re, "ContextError"); + + assertTrue(me instanceof MsoAdapterException); + assertTrue("ContextError".equals(me.getContext())); assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory())); - } + } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java index c2d4f9ba60..84b3fb4f91 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java @@ -40,119 +40,117 @@ import com.woorea.openstack.heat.model.CreateStackParam; /** * This class implements test methods of the MsoHeatUtils - * - * */ public class MsoHeatUtilsTest extends MsoCommonUtils { - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); - public static MsoHeatUtils msoHeatUtils; - - @BeforeClass - public static final void loadClasses() throws MsoCloudIdentityNotFound { - ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); - String config = classLoader.getResource("cloud_config.json").toString().substring(5); - cloudConfigFactory.initializeCloudConfig(config, 1); - msoHeatUtils = new MsoHeatUtils("NO_PROP", msoPropertiesFactory, cloudConfigFactory); - } - - @Test - public final void testCreateStackBadCloudConfig() - throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { - try { - msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<>(), - Boolean.TRUE, 10); - } catch (MsoCloudSiteNotFound e) { - - } catch (java.lang.NullPointerException npe) { - - } - - } - - @Test - public final void testCreateStackFailedConnectionHeatClient() - throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { - try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, - 10); - } catch (MsoIOException e) { - - } - - } - - @Test - public final void testCreateStackFailedConnection() - throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { - try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, - 10); - } catch (MsoIOException e) { - - } - - } - - @Test - public final void createStackSuccessWithEnvironment() throws MsoException { - try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment"); - } catch (MsoIOException e) { - - } - - } - - @Test - public final void createStackSuccessWithFiles() throws MsoException { - try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment", new HashMap<>()); - } catch (MsoIOException e) { - - } - - } - - @Test - public final void createStackSuccessWithHeatFiles() throws MsoException { - try { - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment", new HashMap<>(), new HashMap<>()); - } catch (MsoIOException e) { - - } - } - - @Test - public final void requestToStringBuilderTest() { - CreateStackParam param = new CreateStackParam(); - param.setDisableRollback(false); - param.setEnvironment("environment"); - param.setFiles(new HashMap<>()); - param.setParameters(new HashMap<>()); - param.setStackName("stackName"); - param.setTemplate("template"); - param.setTemplateUrl("http://templateUrl"); - param.setTimeoutMinutes(1); - - msoHeatUtils.requestToStringBuilder(param); - } - - @Test - public final void heatCacheResetTest() { - msoHeatUtils.heatCacheReset(); - } - - @Test - public final void expireHeatClientTest() { - msoHeatUtils.expireHeatClient("tenantId", "cloudId"); - } - - @Test - public final void heatCacheCleanupTest() { - msoHeatUtils.heatCacheCleanup(); - } + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + public static MsoHeatUtils msoHeatUtils; + + @BeforeClass + public static final void loadClasses() throws MsoCloudIdentityNotFound { + ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); + String config = classLoader.getResource("cloud_config.json").toString().substring(5); + cloudConfigFactory.initializeCloudConfig(config, 1); + msoHeatUtils = new MsoHeatUtils("NO_PROP", msoPropertiesFactory, cloudConfigFactory); + } + + @Test + public final void testCreateStackBadCloudConfig() + throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { + try { + msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<>(), + Boolean.TRUE, 10); + } catch (MsoCloudSiteNotFound e) { + + } catch (java.lang.NullPointerException npe) { + + } + + } + + @Test + public final void testCreateStackFailedConnectionHeatClient() + throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { + try { + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, + 10); + } catch (MsoIOException e) { + + } + + } + + @Test + public final void testCreateStackFailedConnection() + throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { + try { + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, + 10); + } catch (MsoIOException e) { + + } + + } + + @Test + public final void createStackSuccessWithEnvironment() throws MsoException { + try { + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, + "environment"); + } catch (MsoIOException e) { + + } + + } + + @Test + public final void createStackSuccessWithFiles() throws MsoException { + try { + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, + "environment", new HashMap<>()); + } catch (MsoIOException e) { + + } + + } + + @Test + public final void createStackSuccessWithHeatFiles() throws MsoException { + try { + msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, + "environment", new HashMap<>(), new HashMap<>()); + } catch (MsoIOException e) { + + } + } + + @Test + public final void requestToStringBuilderTest() { + CreateStackParam param = new CreateStackParam(); + param.setDisableRollback(false); + param.setEnvironment("environment"); + param.setFiles(new HashMap<>()); + param.setParameters(new HashMap<>()); + param.setStackName("stackName"); + param.setTemplate("template"); + param.setTemplateUrl("http://templateUrl"); + param.setTimeoutMinutes(1); + + msoHeatUtils.requestToStringBuilder(param); + } + + @Test + public final void heatCacheResetTest() { + msoHeatUtils.heatCacheReset(); + } + + @Test + public final void expireHeatClientTest() { + msoHeatUtils.expireHeatClient("tenantId", "cloudId"); + } + + @Test + public final void heatCacheCleanupTest() { + msoHeatUtils.heatCacheCleanup(); + } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java index 62043e83b8..47ffff8941 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; + import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -50,86 +51,86 @@ import com.woorea.openstack.base.client.OpenStackConnectException; @RunWith(MockitoJUnitRunner.class) public class MsoHeatUtilsWithUpdateTest { - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); - + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + @Mock CloudConfig cloudConfig; @InjectMocks - MsoHeatUtilsWithUpdate util=new MsoHeatUtilsWithUpdate("NO_PROP",msoPropertiesFactory,cloudConfigFactory); + MsoHeatUtilsWithUpdate util = new MsoHeatUtilsWithUpdate("NO_PROP", msoPropertiesFactory, cloudConfigFactory); private CloudSite cloudSite; @Before - public void init () { - cloudSite = new CloudSite (); - cloudSite.setId ("cloud"); - CloudIdentity cloudIdentity = new CloudIdentity (); + public void init() { + cloudSite = new CloudSite(); + cloudSite.setId("cloud"); + CloudIdentity cloudIdentity = new CloudIdentity(); cloudIdentity.setIdentityServerType(IdentityServerType.KEYSTONE); - cloudIdentity.setKeystoneUrl ("toto"); - cloudIdentity.setMsoPass (CloudIdentity.encryptPassword ("mockId")); - cloudSite.setIdentityService (cloudIdentity); - when(cloudConfig.getCloudSite("cloud")).thenReturn (Optional.of(cloudSite)); - when(cloudConfig.getCloudSite("none")).thenReturn (Optional.empty()); + cloudIdentity.setKeystoneUrl("toto"); + cloudIdentity.setMsoPass(CloudIdentity.encryptPassword("mockId")); + cloudSite.setIdentityService(cloudIdentity); + when(cloudConfig.getCloudSite("cloud")).thenReturn(Optional.of(cloudSite)); + when(cloudConfig.getCloudSite("none")).thenReturn(Optional.empty()); } @Test @Ignore - public void testUpdateStack () { + public void testUpdateStack() { // Heat heat = Mockito.mock (Heat.class); - Map stackInputs = new HashMap <> (); + Map stackInputs = new HashMap<>(); try { - util.updateStack ("none", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); + util.updateStack("none", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); } catch (MsoException e) { if (e instanceof MsoCloudSiteNotFound) { // Ok } else { - e.printStackTrace (); - fail ("Exception caught"); + e.printStackTrace(); + fail("Exception caught"); } } try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); + util.updateStack("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); } catch (MsoException e) { - if (e instanceof MsoIOException && e.getCause () != null - && e.getCause () instanceof OpenStackConnectException) { + if (e instanceof MsoIOException && e.getCause() != null + && e.getCause() instanceof OpenStackConnectException) { // Ok, we were able to go up to the connection to OpenStack } else { - e.printStackTrace (); - fail ("Exception caught"); + e.printStackTrace(); + fail("Exception caught"); } } try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment"); + util.updateStack("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment"); } catch (MsoException e) { - if (e instanceof MsoIOException && e.getCause () != null - && e.getCause () instanceof OpenStackConnectException) { + if (e instanceof MsoIOException && e.getCause() != null + && e.getCause() instanceof OpenStackConnectException) { // Ok, we were able to go up to the connection to OpenStack } else { - e.printStackTrace (); - fail ("Exception caught"); + e.printStackTrace(); + fail("Exception caught"); } } try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null); + util.updateStack("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null); } catch (MsoException e) { - if (e instanceof MsoIOException && e.getCause () != null - && e.getCause () instanceof OpenStackConnectException) { + if (e instanceof MsoIOException && e.getCause() != null + && e.getCause() instanceof OpenStackConnectException) { // Ok, we were able to go up to the connection to OpenStack } else { - e.printStackTrace (); - fail ("Exception caught"); + e.printStackTrace(); + fail("Exception caught"); } } try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null, null); + util.updateStack("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment", null, null); } catch (MsoException e) { - if (e instanceof MsoIOException && e.getCause () != null - && e.getCause () instanceof OpenStackConnectException) { + if (e instanceof MsoIOException && e.getCause() != null + && e.getCause() instanceof OpenStackConnectException) { // Ok, we were able to go up to the connection to OpenStack } else { - e.printStackTrace (); - fail ("Exception caught"); + e.printStackTrace(); + fail("Exception caught"); } } } -- cgit 1.2.3-korg