diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src')
11 files changed, 393 insertions, 387 deletions
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<String, String> 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<String, String> 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<Integer> 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<Integer> 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 <String, Object> stackInputs = new HashMap <> (); + Map<String, Object> 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"); } } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java index 1c2501e8e4..b213bbd90b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java @@ -27,10 +27,13 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.Optional; + import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; + import java.util.Map; + import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; public class CloudConfigTest { diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java index eef45b7164..0033be80fd 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java @@ -29,36 +29,36 @@ import org.junit.Test; public class CloudIdentityTest { @Test - public final void testCloudIdentity () { - CloudIdentity id = new CloudIdentity (); - id.setAdminTenant ("AdminTenant"); - id.setId ("id"); + public final void testCloudIdentity() { + CloudIdentity id = new CloudIdentity(); + id.setAdminTenant("AdminTenant"); + id.setId("id"); // id.setKeystoneUrl ("keystone"); - id.setIdentityUrl ("keystone"); - id.setMemberRole ("member"); - id.setMsoId ("msoId"); - id.setMsoPass (CloudIdentity.encryptPassword ("password")); - id.setTenantMetadata (true); + id.setIdentityUrl("keystone"); + id.setMemberRole("member"); + id.setMsoId("msoId"); + id.setMsoPass(CloudIdentity.encryptPassword("password")); + id.setTenantMetadata(true); id.setIdentityServerType(null); id.setIdentityAuthenticationType(null); - - assertTrue (id.getAdminTenant ().equals ("AdminTenant")); - assertTrue (id.getId ().equals ("id")); + + assertTrue(id.getAdminTenant().equals("AdminTenant")); + assertTrue(id.getId().equals("id")); // assertTrue (id.getKeystoneUrl ().equals ("keystone")); - assertTrue (id.getMemberRole ().equals ("member")); - assertTrue (id.getMsoId ().equals ("msoId")); - assertTrue (id.getMsoPass ().equals ("password")); - assertTrue (id.hasTenantMetadata ()); + assertTrue(id.getMemberRole().equals("member")); + assertTrue(id.getMsoId().equals("msoId")); + assertTrue(id.getMsoPass().equals("password")); + assertTrue(id.hasTenantMetadata()); // assertTrue (id.toString ().contains ("keystone")); assertTrue(id.toString().contains("null")); } @Test - public final void testEncryption () { - String encrypted = CloudIdentity.encryptPassword ("password"); - assertTrue (encrypted != null); - assertTrue (!encrypted.equals ("password")); + public final void testEncryption() { + String encrypted = CloudIdentity.encryptPassword("password"); + assertTrue(encrypted != null); + assertTrue(!encrypted.equals("password")); } - + } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java index b6c1c7373f..08a8c3b9cd 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java @@ -35,34 +35,33 @@ import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; * A few JUnit tests to evaluate the new factory that manages authentication
* types and their associated wrapper classes. Here it is assumed that core types
* only are tested.
- *
*/
public class AuthenticationMethodTest {
- /**
- *
- */
- public AuthenticationMethodTest() {
- // TODO Auto-generated constructor stub
- }
+ /**
+ *
+ */
+ public AuthenticationMethodTest() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Test
+ public void testCustomRackspaceAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("test");
+ Authentication auth = ci.getAuthentication();
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
+ }
- @Test
- public void testCustomRackspaceAuthFromCloudIdentity() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("test");
- Authentication auth = ci.getAuthentication();
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- }
-
- @Test
- public void testCoreUsernamePasswordAuthFromCloudIdentity() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("someuser");
- Authentication auth = ci.getAuthentication();
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- }
+ @Test
+ public void testCoreUsernamePasswordAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("someuser");
+ Authentication auth = ci.getAuthentication();
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
+ }
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java index aaa732c9a3..94a224d5e3 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java @@ -31,14 +31,14 @@ import org.openecomp.mso.openstack.utils.MsoTenantUtils; public class NewServerTypeUtils extends MsoTenantUtils {
- /**
- * @param msoPropID
- */
- public NewServerTypeUtils(String msoPropID) {
- super(msoPropID);
- }
+ /**
+ * @param msoPropID
+ */
+ public NewServerTypeUtils(String msoPropID) {
+ super(msoPropID);
+ }
- @Override
+ @Override
public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
throws MsoException {
// TODO Auto-generated method stub
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java index 4aaf379512..df853426ad 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java @@ -39,20 +39,20 @@ public class ServerTypeTest { IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
assertNotNull(keystoneServerType);
}
-
+
@Test
public void testNewServerType() {
IdentityServerTypeAbstract customServerType = null;
try {
customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
-
+
} catch (IllegalArgumentException e) {
fail("An exception should not be raised when we register a new server type for the first time");
} finally {
System.out.println(IdentityServerType.values().toString());
assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
}
-
+
// Create it a second time
IdentityServerTypeAbstract customServerType2 = null;
try {
@@ -60,23 +60,25 @@ public class ServerTypeTest { fail("An exception should be raised as server type does not exist");
} catch (IllegalArgumentException e) {
// Fail silently -- it simply indicates we already registered it
- customServerType2 = IdentityServerType.valueOf("NewServerType");
+ customServerType2 = IdentityServerType.valueOf("NewServerType");
} finally {
System.out.println(IdentityServerType.values().toString());
assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
}
-
+
// Check the KeystoneURL for this custom TenantUtils
CloudIdentity cloudIdentity = new CloudIdentity();
cloudIdentity.setIdentityUrl("LocalIdentity");
cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
- cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
+ cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.
+ valueOf("NewServerType"));
String regionId = "RegionA";
String msoPropID = "12345";
try {
- assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
- } catch (MsoException e) {
- fail("No MSO Exception should have occured here");
- }
+ assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId +
+ ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
+ } catch (MsoException e) {
+ fail("No MSO Exception should have occured here");
+ }
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java index 0f357e5555..2f58f1d964 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java @@ -24,8 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; import com.woorea.openstack.quantum.model.Network; import com.woorea.openstack.quantum.model.Segment; + import java.util.ArrayList; import java.util.List; + import org.junit.Test; public class NetworkInfoTest { diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/StackInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/StackInfoTest.java index 9c7911ef89..f289f38843 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/StackInfoTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/StackInfoTest.java @@ -23,7 +23,9 @@ package org.openecomp.mso.openstack.beans; import static org.assertj.core.api.Assertions.assertThat; import com.woorea.openstack.heat.model.Stack; + import java.io.IOException; + import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Test; |