diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-30 15:56:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-31 11:09:25 -0400 |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /adapters/mso-adapter-utils/src/test/java/org/openecomp | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org/openecomp')
37 files changed, 0 insertions, 3850 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 deleted file mode 100644 index 250211845f..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapter_utils.tests;
-
-import static org.junit.Assert.assertTrue;
-
-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;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.Pool;
-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 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 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();
- }
-}
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 deleted file mode 100644 index 73bd67723d..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoCommonUtilsTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.openstack.exceptions.MsoAdapterException; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; -import org.openecomp.mso.openstack.exceptions.MsoIOException; -import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; -import org.openecomp.mso.openstack.utils.MsoCommonUtils; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import com.woorea.openstack.base.client.OpenStackBaseException; -import com.woorea.openstack.base.client.OpenStackConnectException; -import com.woorea.openstack.base.client.OpenStackRequest; -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)); - - } - - @Test - public final void testKeystoneErrorToMsoException () { - OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); - - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); - - 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())); - - } - - @Test - public final void testHeatExceptionToMsoException () { - OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect"); - - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); - - 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"); - - OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1); - - MsoException me = super.neutronExceptionToMsoException (openStackConnectException,"ContextError"); - - assertTrue(me instanceof MsoIOException); - assertTrue("connect".equals(me.getMessage())); - - MsoException me2 = super.neutronExceptionToMsoException (openStackResponseException,"ContextError"); - assertTrue(me2 instanceof MsoOpenstackException); - assertTrue("ContextError".equals(me2.getContext())); - assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory())); - } - - @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 deleted file mode 100644 index 93afbcccaf..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java +++ /dev/null @@ -1,365 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - -import java.io.IOException; -import java.util.*; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.TextNode; -import com.woorea.openstack.base.client.HttpMethod; -import com.woorea.openstack.base.client.OpenStackRequest; -import com.woorea.openstack.heat.model.Stack; -import com.woorea.openstack.keystone.model.Access; -import com.woorea.openstack.keystone.utils.KeystoneUtils; -import mockit.Deencapsulation; -import mockit.Invocation; -import mockit.Mock; -import mockit.MockUp; -import mockit.integration.junit4.JMockit; -import org.json.JSONException; -import org.json.JSONObject; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudConfigTest; -import org.openecomp.mso.openstack.beans.StackInfo; -import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; -import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.exceptions.MsoIOException; -import org.openecomp.mso.openstack.exceptions.MsoStackAlreadyExists; -import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound; -import org.openecomp.mso.openstack.utils.MsoCommonUtils; -import org.openecomp.mso.openstack.utils.MsoHeatUtils; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -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, MsoPropertiesException { - ClassLoader classLoader = MsoHeatUtilsTest.class.getClassLoader(); - String cloudConfigJson = classLoader.getResource("cloud_config.json").getPath(); - cloudConfigFactory.initializeCloudConfig(cloudConfigJson, 1); - msoPropertiesFactory.initializeMsoProperties("NO_PROP", classLoader.getResource("mso.properties").getPath()); - 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 { - final MockUp<OpenStackRequest<Access>> mockRequest = new MockUp<OpenStackRequest<Access>>() { - @Mock - public Object execute(Invocation invocation) { - final OpenStackRequest invokedInstance = invocation.getInvokedInstance(); - final Class<?> returnType = Deencapsulation.getField(invokedInstance, "returnType"); - - try { - if (returnType == Access.class) { - ObjectMapper mapper = new ObjectMapper(); - String json = "{\"token\":{\"id\":\"tokenId\",\"tenant\":{\"id\":\"tenantId\",\"name\":\"tenantName\"}},\"serviceCatalog\":[{\"type\":\"orchestration\",\"name\":\"orchestration\",\"endpoints\":[{\"region\":\"region1\",\"publicURL\":\"http://localhost:5000\",\"internalURL\":\"http://localhost:5000\",\"adminURL\":\"http://localhost:5000\"}]}]}"; - return mapper.readValue(json, Access.class); - } else if (returnType == Stack.class) { - final Stack stack = new Stack(); - stack.setId("stackId"); - stack.setStackName("stackName"); - stack.setStackStatus("CREATE_COMPLETE"); - return stack; - } - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - - final MockUp<KeystoneUtils> mockKeystone = new MockUp<KeystoneUtils>() { - @Mock - String findEndpointURL(List<Access.Service> serviceCatalog, String type, String region, String facing) { - return "http://localhost:5000"; - } - }; - - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment"); - - mockRequest.tearDown(); - mockKeystone.tearDown(); - } - - @Test - public final void createStackSuccessWithFiles() throws MsoException { - final MockUp<OpenStackRequest<Access>> mockRequest = new MockUp<OpenStackRequest<Access>>() { - @Mock - public Object execute(Invocation invocation) { - final OpenStackRequest invokedInstance = invocation.getInvokedInstance(); - final Class<?> returnType = Deencapsulation.getField(invokedInstance, "returnType"); - - try { - if (returnType == Access.class) { - ObjectMapper mapper = new ObjectMapper(); - String json = "{\"token\":{\"id\":\"tokenId\",\"tenant\":{\"id\":\"tenantId\",\"name\":\"tenantName\"}},\"serviceCatalog\":[{\"type\":\"orchestration\",\"name\":\"orchestration\",\"endpoints\":[{\"region\":\"region1\",\"publicURL\":\"http://localhost:5000\",\"internalURL\":\"http://localhost:5000\",\"adminURL\":\"http://localhost:5000\"}]}]}"; - return mapper.readValue(json, Access.class); - } else if (returnType == Stack.class) { - final Stack stack = new Stack(); - stack.setId("stackId"); - stack.setStackName("stackName"); - stack.setStackStatus("CREATE_COMPLETE"); - return stack; - } - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - - final MockUp<KeystoneUtils> mockKeystone = new MockUp<KeystoneUtils>() { - @Mock - String findEndpointURL(List<Access.Service> serviceCatalog, String type, String region, String facing) { - return "http://localhost:5000"; - } - }; - - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment", new HashMap<>()); - - mockRequest.tearDown(); - mockKeystone.tearDown(); - } - - @Test - public final void createStackSuccessWithHeatFiles() throws MsoException { - - final MockUp<OpenStackRequest<Access>> mockRequest = new MockUp<OpenStackRequest<Access>>() { - @Mock - public Object execute(Invocation invocation) { - final OpenStackRequest invokedInstance = invocation.getInvokedInstance(); - final Class<?> returnType = Deencapsulation.getField(invokedInstance, "returnType"); - - try { - if (returnType == Access.class) { - ObjectMapper mapper = new ObjectMapper(); - String json = "{\"token\":{\"id\":\"tokenId\",\"tenant\":{\"id\":\"tenantId\",\"name\":\"tenantName\"}},\"serviceCatalog\":[{\"type\":\"orchestration\",\"name\":\"orchestration\",\"endpoints\":[{\"region\":\"region1\",\"publicURL\":\"http://localhost:5000\",\"internalURL\":\"http://localhost:5000\",\"adminURL\":\"http://localhost:5000\"}]}]}"; - return mapper.readValue(json, Access.class); - } else if (returnType == Stack.class) { - final Stack stack = new Stack(); - stack.setId("stackId"); - stack.setStackName("stackName"); - stack.setStackStatus("CREATE_COMPLETE"); - return stack; - } - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - - final MockUp<KeystoneUtils> mockKeystone = new MockUp<KeystoneUtils>() { - @Mock - String findEndpointURL(List<Access.Service> serviceCatalog, String type, String region, String facing) { - return "http://localhost:5000"; - } - }; - - msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10, - "environment", new HashMap<>(), new HashMap<>()); - - mockRequest.tearDown(); - mockKeystone.tearDown(); - } - - @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(); - } - - @Test - public void queryStackTest() throws MsoException { - final MockUp<OpenStackRequest<Access>> mockRequest = new MockUp<OpenStackRequest<Access>>() { - @Mock - public Object execute(Invocation invocation) { - final OpenStackRequest invokedInstance = invocation.getInvokedInstance(); - final Class<?> returnType = Deencapsulation.getField(invokedInstance, "returnType"); - - try { - if (returnType == Access.class) { - ObjectMapper mapper = new ObjectMapper(); - String json = "{\"token\":{\"id\":\"tokenId\",\"tenant\":{\"id\":\"tenantId\",\"name\":\"tenantName\"}},\"serviceCatalog\":[{\"type\":\"orchestration\",\"name\":\"orchestration\",\"endpoints\":[{\"region\":\"region1\",\"publicURL\":\"http://localhost:5000\",\"internalURL\":\"http://localhost:5000\",\"adminURL\":\"http://localhost:5000\"}]}]}"; - return mapper.readValue(json, Access.class); - } else if (returnType == Stack.class) { - final Stack stack = new Stack(); - stack.setId("stackId"); - stack.setStackName("stackName"); - stack.setStackStatus("CREATE_COMPLETE"); - return stack; - } - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - - final MockUp<KeystoneUtils> mockKeystone = new MockUp<KeystoneUtils>() { - @Mock - String findEndpointURL(List<Access.Service> serviceCatalog, String type, String region, String facing) { - return "http://localhost:5000"; - } - }; - - final StackInfo stackInfo = msoHeatUtils.queryStack("MT", "test", "stackName"); - - mockRequest.tearDown(); - mockKeystone.tearDown(); - } - - @Test - public void deleteStack() throws MsoException { - final MockUp<OpenStackRequest<Access>> mockRequest = new MockUp<OpenStackRequest<Access>>() { - @Mock - public Object execute(Invocation invocation) { - final OpenStackRequest invokedInstance = invocation.getInvokedInstance(); - final Class<?> returnType = Deencapsulation.getField(invokedInstance, "returnType"); - final String path = Deencapsulation.getField(invokedInstance, "endpoint"); -// final String stackName = path.substring(path.lastIndexOf("/")); - - try { - if (returnType == Access.class) { - ObjectMapper mapper = new ObjectMapper(); - String json = "{\"token\":{\"id\":\"tokenId\",\"tenant\":{\"id\":\"tenantId\",\"name\":\"tenantName\"}},\"serviceCatalog\":[{\"type\":\"orchestration\",\"name\":\"orchestration\",\"endpoints\":[{\"region\":\"region1\",\"publicURL\":\"http://localhost:5000\",\"internalURL\":\"http://localhost:5000\",\"adminURL\":\"http://localhost:5000\"}]}]}"; - return mapper.readValue(json, Access.class); - } else if (returnType == Stack.class) { - final Stack stack = new Stack(); - stack.setId("stackId"); - stack.setStackName("stackName"); - final String status = "DELETE_COMPLETE"; - stack.setStackStatus(status); - return stack; - } - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - - final MockUp<KeystoneUtils> mockKeystone = new MockUp<KeystoneUtils>() { - @Mock - String findEndpointURL(List<Access.Service> serviceCatalog, String type, String region, String facing) { - return "http://localhost:5000"; - } - }; - - final StackInfo stackInfo = msoHeatUtils.deleteStack("test", "MT", "stackName", true); - - mockRequest.tearDown(); - mockKeystone.tearDown(); - } - - @Test - public void copyStringOutputsToInputsTest() { - Map<String, String> inputs = new HashMap<String, String>(){{put("key41", "value41");}}; - Map<String, Object> outputs = new HashMap<String, Object>(){{ - put("key2", "val2"); - put("key3", new TextNode("val3")); - put("key4", new LinkedHashMap<String, String>(){{put("key41", "value41");}}); - }}; - msoHeatUtils.copyStringOutputsToInputs(inputs, outputs, true); - } -} 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 deleted file mode 100644 index 62043e83b8..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; - -import java.util.Optional; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.cloud.CloudConfig; -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; -import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.exceptions.MsoIOException; -import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -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(); - - @Mock - CloudConfig cloudConfig; - @InjectMocks - 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 (); - 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()); - } - - @Test - @Ignore - public void testUpdateStack () { - // Heat heat = Mockito.mock (Heat.class); - Map <String, Object> stackInputs = new HashMap <> (); - try { - util.updateStack ("none", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); - } catch (MsoException e) { - if (e instanceof MsoCloudSiteNotFound) { - // Ok - } else { - e.printStackTrace (); - fail ("Exception caught"); - } - } - try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1); - } catch (MsoException e) { - 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"); - } - } - try { - util.updateStack ("cloud", "tenantId", "stackName", "heatTemplate", stackInputs, false, 1, "environment"); - } catch (MsoException e) { - 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"); - } - } - try { - 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) { - // Ok, we were able to go up to the connection to OpenStack - } else { - e.printStackTrace (); - fail ("Exception caught"); - } - } - try { - 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) { - // Ok, we were able to go up to the connection to OpenStack - } else { - e.printStackTrace (); - fail ("Exception caught"); - } - } - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapters/vdu/BeansTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapters/vdu/BeansTest.java deleted file mode 100644 index 1452c1569c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapters/vdu/BeansTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vdu; - -import org.junit.Test; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class BeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.adapters.vdu"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java deleted file mode 100644 index c6c6baf61b..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.cloud; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; - -public class CloudConfigFactoryTest { - - private static final String CLOUD_CONFIG_FIELD_NAME = "cloudConfigCache"; - private static final int REFRESH_TIMER_VALUE = 1; - - private CloudConfigFactory testedObject; - private CloudConfig cloudConfigMock; - private CloudConfig savedCloudConfig; - - @Before - public void init() throws NoSuchFieldException, IllegalAccessException { - cloudConfigMock = mock(CloudConfig.class); - testedObject = new CloudConfigFactory(); - Field field = CloudConfigFactory.class.getDeclaredField(CLOUD_CONFIG_FIELD_NAME); - field.setAccessible(true); - savedCloudConfig = (CloudConfig) field.get(null); - field.set(null, cloudConfigMock); - } - - @After - public void reset() throws NoSuchFieldException, IllegalAccessException { - Field field = CloudConfigFactory.class.getDeclaredField(CLOUD_CONFIG_FIELD_NAME); - field.setAccessible(true); - field.set(null, savedCloudConfig); - } - - @Test - public void initializeCloudConfigSuccessful() throws MsoCloudIdentityNotFound, IOException { - ClassLoader classLoader = CloudConfigFactoryTest.class.getClassLoader(); - String cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath(); - testedObject.initializeCloudConfig(cloudConfigJsonFilePath, REFRESH_TIMER_VALUE); - verify(cloudConfigMock).loadCloudConfig(cloudConfigJsonFilePath, REFRESH_TIMER_VALUE); - } - - @Test - public void getValidCloudConfig() { - when(cloudConfigMock.isValidCloudConfig()).thenReturn(true); - - testedObject.getCloudConfig(); - - verify(cloudConfigMock).clone(); - } - - @Test - public void reload_CloudConfigValid() throws IOException, MsoCloudIdentityNotFound { - when(cloudConfigMock.isValidCloudConfig()).thenReturn(true); - - testedObject.reloadCloudConfig(); - - verify(cloudConfigMock).clone(); - verify(cloudConfigMock).reloadPropertiesFile(); - } - - @Test - public void reload_CloudConfigNotValid() - throws IOException, MsoCloudIdentityNotFound { - when(cloudConfigMock.isValidCloudConfig()).thenReturn(false); - - testedObject.reloadCloudConfig(); - - verify(cloudConfigMock).reloadPropertiesFile(); - } - - @Test - public void showCloudConfig() throws NoSuchFieldException, IllegalAccessException { - when(cloudConfigMock.isValidCloudConfig()).thenReturn(true); - when(cloudConfigMock.clone()).thenReturn(createCloudConfig("IdTest576", "identityTest456")); - Response response = testedObject.showCloudConfig(); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getEntity().toString()).containsPattern("CloudSite:.*IdTest576") - .containsPattern("Cloud Identity Service:.*identityTest456"); - - } - - @Test - public void resetClientCaches_Successful() { - Response response = testedObject.resetClientCaches(); - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getEntity().toString()).isEqualTo("Client caches reset. All entries removed."); - } - - @Test - public void cleanUpClientCache_Successful() { - Response response = testedObject.cleanupClientCaches(); - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getEntity().toString()).isEqualTo("Client caches cleaned up. All expired entries removed."); - } - - @Test - public void encryptPassword_Successful() { - Response response = testedObject.encryptPassword("passTest123"); - String expectedEncryptedPassword = CloudIdentity.encryptPassword("passTest123"); - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getEntity().toString()).isEqualTo("Encrypted Password = "+expectedEncryptedPassword); - } - - private CloudConfig createCloudConfig(String cloudSiteId, String identityServiceId) - throws NoSuchFieldException, IllegalAccessException { - CloudConfig cloudConfig = new CloudConfig(); - Map<String, CloudSite> cloudSiteMap = new HashMap<>(); - CloudSite cs = new CloudSite(); - cs.setId(cloudSiteId); - cloudSiteMap.put("keyTest", cs); - Field cloudSitesField = cloudConfig.getClass().getDeclaredField("cloudSites"); - cloudSitesField.setAccessible(true); - cloudSitesField.set(cloudConfig, cloudSiteMap); - - Map<String, CloudIdentity> identityServicesMap = new HashMap<>(); - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId(identityServiceId); - identityServicesMap.put("identityKey", cloudIdentity); - - Field identityServicesField = cloudConfig.getClass().getDeclaredField("identityServices"); - identityServicesField.setAccessible(true); - identityServicesField.set(cloudConfig, identityServicesMap); - - return cloudConfig; - } - - private void setCloudConfig() - throws NoSuchFieldException, IllegalAccessException { - } - -} 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 deleted file mode 100644 index a4859a11b2..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.cloud; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; - -public class CloudConfigTest { - - private static final int NUMBER_OF_CLOUD_SITES_IN_JSON_FILE = 4; - private static final int NUMBER_OF_IDENTITY_SERVICES_IN_JSON_FILE = 4; - private static final String CLOUD_SITES_FIELD_NAME = "cloudSites"; - private static final String IDENTITY_SERVICE_FIELD_NAME = "identityServices"; - private static final String CLOUD_SITE_DEFAULT = "default"; - private static final String CLOUD_CONFIG_JSON_FILE_NAME = "cloud_config.json"; - private static final String CLOUD_CONFIG_INVALID_JSON_FILE_NAME = "cloud_config_bad.json"; - - private CloudConfig testedObject; - private CloudSite cloudSite; - private CloudSite cloudSiteDefault; - - @Before - public void init() { - testedObject = new CloudConfig(); - } - - @Test - public void cloudSite_returnEmptyOptionalIfIdIsNull() { - Optional<CloudSite> cloudConfigOpt = new CloudConfig().getCloudSite(null); - assertThat(cloudConfigOpt).isEmpty(); - } - - @Test - public void cloudSiteIsGotById_when_IdFound() throws NoSuchFieldException, IllegalAccessException { - setCloudSitesMap(); - Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite(cloudSite.getId()); - assertThat(cloudSiteOpt).isPresent(); - assertThat(cloudSiteOpt.get().getId()).isEqualTo(cloudSite.getId()); - assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSite.getClli()); - } - - @Test - @Ignore // 1802 merge - public void cloudSiteIsGotByClli_when_IdNotFound() throws NoSuchFieldException, IllegalAccessException { - setCloudSitesMap(); - Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite(cloudSite.getClli()); - assertTrue(cloudSiteOpt.isPresent()); - assertThat(cloudSiteOpt.get().getId()).isEqualTo(cloudSite.getId()); - assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSite.getClli()); - } - - @Test - @Ignore // 1802 merge - public void cloudSiteIsGotByDefault_when_IdAndClliNotFound() throws NoSuchFieldException, IllegalAccessException { - setCloudSitesMap(); - Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite("not_existing_id"); - assertTrue(cloudSiteOpt.isPresent()); - assertThat(cloudSiteOpt.get().getId()).isEqualTo("not_existing_id"); - assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSiteDefault.getClli()); - } - - @Test - @Ignore // 1802 merge - public void cloudSiteNotFound_returnNull() { - assertThat(testedObject.getCloudSite("not_existing_id")).isEmpty(); - } - - @Test - public void identityServiceFoundById() throws NoSuchFieldException, IllegalAccessException { - CloudIdentity cloudIdentity = createCloudIdentity(); - setIdentityServiceMap(); - CloudIdentity cloudIdentityResult = testedObject.getIdentityService(cloudIdentity.getId()); - - assertThat(cloudIdentityResult).isNotNull(); - assertThat(cloudIdentityResult.getId()).isEqualTo(cloudIdentity.getId()); - assertThat(cloudIdentityResult.getMsoId()).isEqualTo(cloudIdentity.getMsoId()); - } - - @Test - public void defaultClodeSiteNotFound_returnNull() { - assertThat(testedObject.getIdentityService("not_existing_id")).isNull(); - } - - @Test - public void loadCloudConfigSuccessful() throws IOException, MsoCloudIdentityNotFound { - ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); - String cloudConfigJsonFilePath = classLoader.getResource(CLOUD_CONFIG_JSON_FILE_NAME).getPath(); - testedObject.loadCloudConfig(cloudConfigJsonFilePath, 1); - assertThat(testedObject.isValidCloudConfig()).isTrue(); - checkCloudSites(); - checkIdentityServices(); - } - - @Test - public void loadCloudConfig_cloudIdentityNotFound() { - ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); - String cloudConfigInvalidJsonFilePath = classLoader.getResource(CLOUD_CONFIG_INVALID_JSON_FILE_NAME).getPath(); - assertThatThrownBy(() -> testedObject.loadCloudConfig(cloudConfigInvalidJsonFilePath, 1)) - .isInstanceOf(MsoCloudIdentityNotFound.class) - .hasMessage("Cloud Identity [MT Cloud site refers to a non-existing identity service: " - + "MT_KEYSTONE_NOT_EXISTING] not found"); - assertThat(testedObject.isValidCloudConfig()).isFalse(); - } - - private void checkCloudSites() { - Map<String, CloudSite> siteMap = testedObject.getCloudSites(); - assertThat(siteMap).isNotEmpty().hasSize(NUMBER_OF_CLOUD_SITES_IN_JSON_FILE); - CloudSite site1 = siteMap.get("MT"); - CloudSite site2 = siteMap.get("DAN"); - CloudSite site3 = siteMap.get("MTINJVCC101"); - CloudSite site4 = siteMap.get("MTSNJA4LCP1"); - - assertThat(site1.getId()).isEqualTo("MT"); - assertThat(site1.getRegionId()).isEqualTo("regionOne"); - assertThat(site1.getIdentityServiceId()).isEqualTo("MT_KEYSTONE"); - assertThat(site1.getIdentityService()).isNotNull(); - assertThat(site1.getIdentityService().getId()).isEqualTo(site1.getIdentityServiceId()); - - assertThat(site2.getId()).isEqualTo("DAN"); - assertThat(site2.getRegionId()).isEqualTo("RegionOne"); - assertThat(site2.getIdentityServiceId()).isEqualTo("DAN_KEYSTONE"); - assertThat(site2.getIdentityService()).isNotNull(); - assertThat(site2.getIdentityService().getId()).isEqualTo(site2.getIdentityServiceId()); - - assertThat(site3.getId()).isEqualTo("MTINJVCC101"); - assertThat(site3.getRegionId()).isEqualTo("regionTwo"); - assertThat(site3.getIdentityServiceId()).isEqualTo("MTINJVCC101_DCP"); - assertThat(site3.getIdentityService()).isNotNull(); - assertThat(site3.getIdentityService().getId()).isEqualTo(site3.getIdentityServiceId()); - - assertThat(site4.getId()).isEqualTo("MTSNJA4LCP1"); - assertThat(site4.getRegionId()).isEqualTo("mtsnjlcp1"); - assertThat(site4.getIdentityServiceId()).isEqualTo("MTSNJA3DCP1"); - assertThat(site4.getIdentityService()).isNotNull(); - assertThat(site4.getIdentityService().getId()).isEqualTo(site4.getIdentityServiceId()); - } - - private void checkIdentityServices() { - Map<String, CloudIdentity> identityMap = testedObject.getIdentityServices(); - assertThat(identityMap).isNotEmpty().hasSize(NUMBER_OF_IDENTITY_SERVICES_IN_JSON_FILE); - - CloudIdentity identity1 = identityMap.get("MT_KEYSTONE"); - CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE"); - CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP"); - CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1"); - - assertThat(identity1.getMsoId()).isEqualTo("john"); - assertThat(identity1.getMsoPass()).isEqualTo("changeme"); - assertThat(identity1.getAdminTenant()).isEqualTo("admin"); - assertThat(identity1.getMemberRole()).isEqualTo("_member_"); - assertThat(identity1.hasTenantMetadata()).isFalse(); - - assertThat(identity2.getMsoId()).isEqualTo("mockId"); - assertThat(identity2.getMsoPass()).isEqualTo("stack123"); - assertThat(identity2.getAdminTenant()).isEqualTo("service"); - assertThat(identity2.getMemberRole()).isEqualTo("_member_"); - assertThat(identity2.hasTenantMetadata()).isFalse(); - - assertThat(identity3.getMsoId()).isEqualTo("mockIdToo"); - assertThat(identity3.getMsoPass()).isEqualTo("AICG@mm@@2015"); - assertThat(identity3.getAdminTenant()).isEqualTo("service"); - assertThat(identity3.getMemberRole()).isEqualTo("admin"); - assertThat(identity3.hasTenantMetadata()).isTrue(); - - assertThat(identity4.getMsoId()).isEqualTo("mockIdToo"); - assertThat(identity4.getMsoPass()).isEqualTo("2315QRS2015srq"); - assertThat(identity4.getAdminTenant()).isEqualTo("service"); - assertThat(identity4.getMemberRole()).isEqualTo("admin"); - assertThat(identity4.hasTenantMetadata()).isTrue(); - } - - @Test - public void cloneSuccessful() throws NoSuchFieldException, IllegalAccessException { - setCloudSitesMap(); - setIdentityServiceMap(); - assertThat(testedObject.clone()).isEqualTo(testedObject); - } - - private void setCloudSitesMap() throws NoSuchFieldException, IllegalAccessException { - Field field = testedObject.getClass().getDeclaredField(CLOUD_SITES_FIELD_NAME); - field.setAccessible(true); - Map<String, CloudSite> cloudSites = new HashMap<>(); - cloudSite = createCloudSite("idTest1", "clliTest1"); - cloudSiteDefault = createCloudSite(CLOUD_SITE_DEFAULT, "clliTest2"); - cloudSites.put(cloudSite.getId(), cloudSite); - cloudSites.put(cloudSiteDefault.getId(), cloudSiteDefault); - field.set(testedObject, cloudSites); - } - - private void setIdentityServiceMap() throws NoSuchFieldException, IllegalAccessException { - Field field = testedObject.getClass().getDeclaredField(IDENTITY_SERVICE_FIELD_NAME); - field.setAccessible(true); - - Map<String, CloudIdentity> cloudIdentityMap = new HashMap<>(); - CloudIdentity cloudIdentity = createCloudIdentity(); - cloudIdentityMap.put(cloudIdentity.getId(), cloudIdentity); - field.set(testedObject, cloudIdentityMap); - } - - private CloudIdentity createCloudIdentity() { - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId("identityTestId"); - cloudIdentity.setMsoId("msoTestId"); - return cloudIdentity; - } - - private CloudSite createCloudSite(String id, String clli) { - CloudSite cloudSite = new CloudSite(); - cloudSite.setId(id); - cloudSite.setClli(clli); - cloudSite.setAic_version("2.5"); - cloudSite.setIdentityService(createCloudIdentity()); - return cloudSite; - } -} 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 deleted file mode 100644 index eef45b7164..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudIdentityTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.cloud; - - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - - -public class CloudIdentityTest { - - @Test - 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.setIdentityServerType(null); - id.setIdentityAuthenticationType(null); - - - 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.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")); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteTest.java deleted file mode 100644 index 4c5ceb238c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudSiteTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.cloud; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class CloudSiteTest { - - @Mock - CloudIdentity ci= new CloudIdentity(); - - @InjectMocks - CloudSite cs = new CloudSite(); - - -@Before -public void init(){ - MockitoAnnotations.initMocks(this); - } - @Test - public void testCloudSite() { - cs.setAic_version("aic_version"); - cs.setClli("clli"); - cs.setId("id"); - cs.setIdentityService(ci); - cs.setRegionId("regionId"); - assert(cs.getAic_version().equals("aic_version")); - assert(cs.getClli().equals("clli")); - assert(cs.getId().equals("id")); - assert(cs.getIdentityService().equals(ci)); - assert(cs.getRegionId().equals("regionId")); - } - @Test - public void testtoStringmethod(){ - assert(cs.toString()!=null); - } - @Test - public void testhashCodemethod(){ - assert(cs.hashCode()!=0); - } - @Test - public void testclone(){ - assert(cs.clone()!=null); - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java deleted file mode 100644 index 2cfce276d8..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ============LICENSE_START========================================== - * =================================================================== - * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * - * ECOMP and OpenECOMP are trademarks - * and service marks of AT&T Intellectual Property. - * - */ - -package org.openecomp.mso.cloud.authentication; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.woorea.openstack.keystone.model.Authentication; -import org.junit.Test; -import org.openecomp.mso.cloud.CloudIdentity; -import org.openecomp.mso.cloud.CloudIdentity.IdentityAuthenticationType; -import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper; - -public class AuthenticationMethodFactoryTest { - - private static final Class WRAPPER_CLASS = RackspaceAPIKeyWrapper.class; - private static final String AUTHENTICATION_TYPE = "authenticationTest"; - - @Test - public void register_NoExceptionThrown() throws IllegalAccessException, InstantiationException { - AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, WRAPPER_CLASS); - } - - @Test - public void register_throwExceptionWhenAuthTypeIsNull() throws InstantiationException, IllegalAccessException { - try { - AuthenticationMethodFactory.register(null, WRAPPER_CLASS); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null " - + "or an empty name string"); - } - } - - @Test - public void register_throwExceptionWhenAuthTypeIsEmpty() throws InstantiationException, IllegalAccessException { - try { - AuthenticationMethodFactory.register("", WRAPPER_CLASS); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null " - + "or an empty name string"); - } - } - - @Test - public void register_throwExceptionWhenWrapperIsNull() throws IllegalAccessException, InstantiationException { - try { - AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, null); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isNotEmpty() - .contains("Wrapper Class to register for Authentication cannot be null"); - } - } - - @Test - public void getAuthentication_NoExceptionThrown() { - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setIdentityAuthenticationType(IdentityAuthenticationType.RACKSPACE_APIKEY); - cloudIdentity.setMsoId("msoIdTest"); - cloudIdentity.setMsoPass("123"); - Authentication result = AuthenticationMethodFactory.getAuthenticationFor(cloudIdentity); - assertThat(result).isNotNull(); - } - - @Test - public void getAuthentication_ThrowExWhenCloudSiteIsNull() { - try { - AuthenticationMethodFactory.getAuthenticationFor(null); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isNotEmpty().contains("Cloud identity cannot be null"); - } - } - - @Test - public void getAuthentication_ThrowExWhenIdentityAuthenticationTypeIsNotSet() { - try { - AuthenticationMethodFactory.getAuthenticationFor(new CloudIdentity()); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isNotEmpty() - .contains("Cloud identity authentication type cannot be null or empty"); - } - } - -} 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 deleted file mode 100644 index b6c1c7373f..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication;
-
-import static org.junit.Assert.assertTrue;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import org.junit.Test;
-import org.openecomp.mso.cloud.CloudIdentity;
-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
- }
-
- @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()));
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java deleted file mode 100644 index 33f91c641e..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START========================================== - * =================================================================== - * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * - * ECOMP and OpenECOMP are trademarks - * and service marks of AT&T Intellectual Property. - * - */ - -package org.openecomp.mso.cloud.authentication.wrappers; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import com.woorea.openstack.keystone.model.Authentication; -import org.junit.Test; -import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; - -public class RackspaceAPIKeyWrapperTest { - - @Test - public void getAuthenticationSuccessful() { - RackspaceAPIKeyWrapper testedObject = new RackspaceAPIKeyWrapper(); - Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity()); - - assertThat(authentication).isInstanceOf(RackspaceAuthentication.class); - RackspaceAuthentication rackspaceAuthentication = (RackspaceAuthentication) authentication; - assertThat(rackspaceAuthentication.getToken().getUsername()) - .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID); - assertThat(rackspaceAuthentication.getToken().getApiKey()) - .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS); - } - - @Test - public void getAuthenticationThrowsException() { - assertThatThrownBy(() -> new RackspaceAPIKeyWrapper().getAuthentication(null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java deleted file mode 100644 index 0cfe287dfe..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START========================================== - * =================================================================== - * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * - * ECOMP and OpenECOMP are trademarks - * and service marks of AT&T Intellectual Property. - * - */ - -package org.openecomp.mso.cloud.authentication.wrappers; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import com.woorea.openstack.keystone.model.Authentication; -import com.woorea.openstack.keystone.model.authentication.UsernamePassword; -import org.junit.Test; - -public class UsernamePasswordWrapperTest { - - @Test - public void getAuthenticationSuccessful() { - UsernamePasswordWrapper testedObject = new UsernamePasswordWrapper(); - Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity()); - - assertThat(authentication).isInstanceOf(UsernamePassword.class); - UsernamePassword usernamePassword = (UsernamePassword) authentication; - assertThat(usernamePassword.getPasswordCredentials().getUsername()) - .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID); - assertThat(usernamePassword.getPasswordCredentials().getPassword()) - .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS); - } - - @Test - public void getAuthenticationThrowsException() { - assertThatThrownBy(() -> new UsernamePasswordWrapper().getAuthentication(null)). - isInstanceOf(IllegalArgumentException.class). - hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java deleted file mode 100644 index 3cbc48d090..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ============LICENSE_START========================================== - * =================================================================== - * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * - * ECOMP and OpenECOMP are trademarks - * and service marks of AT&T Intellectual Property. - * - */ - -package org.openecomp.mso.cloud.authentication.wrappers; - -import org.openecomp.mso.cloud.CloudIdentity; - -final class WrapperTestUtility { - - static final String CLOUD_IDENTITY_MSO_ID = "msoIdTest"; - static final String CLOUD_IDENTITY_MSO_PASS = "msoPassTest"; - static final String EXCEPTION_MESSAGE = "Provided cloud identity is null, cannot extract username and " - + "password"; - - private WrapperTestUtility() { - } - - static CloudIdentity createCloudIdentity() { - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setMsoId(CLOUD_IDENTITY_MSO_ID); - cloudIdentity.setMsoPass(CloudIdentity.encryptPassword(CLOUD_IDENTITY_MSO_PASS)); - return cloudIdentity; - } -} 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 deleted file mode 100644 index 40108b3802..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.cloud.servertype;
-
-import java.util.Map;
-
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.openstack.beans.MsoTenant;
-import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoTenantUtils;
-
-
-public class NewServerTypeUtils extends MsoTenantUtils {
-
- public NewServerTypeUtils(String msoPropID, CloudConfigFactory cloudConfigFactory) {
- super(msoPropID, cloudConfigFactory);
- }
-
- @Override
- public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
- throws MsoException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public MsoTenant queryTenantByName(String tenantName, String cloudSiteId)
- throws MsoException, MsoCloudSiteNotFound {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity)
- throws MsoException {
- return msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl();
- }
-
-}
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 deleted file mode 100644 index 69fab27f78..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.cloud.servertype;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
-import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoKeystoneUtilsTest;
-
-public class ServerTypeTest {
-
- @BeforeClass
- public static void init() throws Exception {
- String cloudConfigJson = ServerTypeTest.class.getClassLoader()
- .getResource("cloud_config.json").getPath();
- (new CloudConfigFactory()).initializeCloudConfig(cloudConfigJson, 0);
- }
-
- @Test
- @Ignore // IGNORED FOR 1710 MERGE TO ONAP
- public void testKeystoneServerType() {
- 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 {
- customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
- 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");
- } 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"));
- 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");
- }
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/beans/DeploymentInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/beans/DeploymentInfoTest.java deleted file mode 100644 index a8fef5db94..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/beans/DeploymentInfoTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.cloudify.beans;
-
-import static org.mockito.Mockito.mock;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.openecomp.mso.cloudify.v3.model.Deployment;
-import org.openecomp.mso.cloudify.v3.model.DeploymentOutputs;
-import org.openecomp.mso.cloudify.v3.model.Execution;
-import org.powermock.api.mockito.PowerMockito;
-
-public class DeploymentInfoTest {
-
- @Mock
- DeploymentStatus status;
-
- @Mock
- DeploymentOutputs out;
-
- @Mock
- Execution execution;
-
- @Mock
- Deployment deployment;
-
- @Test
- public void test() {
- Deployment deployment=mock(Deployment.class);
- Map<String,Object> dep=new HashMap();
- Map<String,Object> outputs = new HashMap<String,Object>();
- Map<String,Object> inputs = new HashMap<String,Object>();
- inputs.put("id",dep);
- status=DeploymentStatus.CREATED;
- outputs.put("id", out);
- dep.put("id", outputs);
- DeploymentInfo dinfo=new DeploymentInfo(deployment);
- DeploymentInfo dinfi=new DeploymentInfo("id");
- DeploymentInfo din=new DeploymentInfo("id",outputs);
- DeploymentInfo dfo=new DeploymentInfo("id", status);
- DeploymentInfo dfoi=new DeploymentInfo(deployment, out, execution);
- dinfo=PowerMockito.spy(new DeploymentInfo());
- dinfo.setId("id");
- dinfi.setInputs(inputs);
- din.setStatus(status);
- din.setOutputs(outputs);
- assert(din.toString()!=null);
- assert(din.getOutputs().equals(outputs));
- assert(din.getId().equals("id"));
- assert(din.getStatus().equals(status));
- din.getLastAction();
- din.getErrorMessage();
- din.getActionStatus();
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyExceptionTest.java deleted file mode 100644 index 1521d11f31..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyExceptionTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.cloudify.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class MsoCloudifyExceptionTest {
-
- @Test
- public void test() {
- Exception e = null;
- boolean pendingWorkflow=true;
- MsoCloudifyException mce=new MsoCloudifyException(200, "message", "detail");
- MsoCloudifyException mcl=new MsoCloudifyException(200, "message", "detail", e);
- mce.setPendingWorkflow(pendingWorkflow);
- assert(mcl.toString()!=null);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTest.java deleted file mode 100644 index 1646f53022..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.cloudify.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class MsoCloudifyTest {
-
- @Test
- public void test() {
- MsoBlueprintAlreadyExists mbae=new MsoBlueprintAlreadyExists("blueprintId", "cloud");
- MsoCloudifyManagerNotFound mcm=new MsoCloudifyManagerNotFound("cloudSiteId");
- MsoDeploymentAlreadyExists mdae=new MsoDeploymentAlreadyExists("deploymentId", "cloud");
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeoutTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeoutTest.java deleted file mode 100644 index f24db06389..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyTimeoutTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.cloudify.exceptions;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.openecomp.mso.cloudify.v3.model.Execution;
-
-public class MsoCloudifyTimeoutTest {
-
- @Test
- public void test() {
- Execution execution=mock(Execution.class);
- MsoCloudifyTimeout mct=new MsoCloudifyTimeout(execution);
- mct.getExecution();
- assert(mct.toString()!=null);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java deleted file mode 100644 index 985066cab1..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package org.openecomp.mso.cloudify.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class MsoCloudifyWorkflowExceptionTest {
-
- @Test
- public void test() {
- MsoCloudifyWorkflowException mcw=new MsoCloudifyWorkflowException("message", "id", "workflowId", "workflowStatus");
- mcw.getWorkflowStatus();
- assertFalse(mcw.isWorkflowStillRunning());
-
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java deleted file mode 100644 index da4aebd3d9..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.cloudify.utils; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.cloudify.beans.DeploymentInfo; -import org.openecomp.mso.cloudify.exceptions.MsoCloudifyManagerNotFound; -import org.openecomp.mso.cloudify.v3.client.Cloudify; -import org.openecomp.mso.cloudify.v3.model.DeploymentOutputs; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.HashMap; -import java.util.Map; -import static org.mockito.Mockito.mock; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; - -//@RunWith(PowerMockRunner.class) -@PrepareForTest({MsoCloudifyUtils.class}) - - -public class MsoCloudifyUtilsTest { - - - @Mock - MsoPropertiesFactory msoPropertiesFactory; - - @Mock - CloudConfigFactory cloudConfigFactory; - - @Mock - DeploymentInfo deploymentInfo; - - @Mock - Cloudify cloudify; - - @Mock - DeploymentOutputs deploymentOutputs; - - @Mock - CloudSite cloudSite; - - @Test(expected = NullPointerException.class) - public void testCreateandInstallDeployment() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - Map<String, Object> inputs = new HashMap<>(); - inputs.put("1", "value"); - - mcu.createAndInstallDeployment("cloudSiteId", "tenantId", "deploymentId", "blueprintId" - , inputs, true, 1, true); - - assert (mcu.createAndInstallDeployment("cloudSiteId", "tenantId", "deploymentId", "blueprintId" - , inputs, true, 1, true) != null); - - - } - - @Test(expected = NullPointerException.class) - public void testDeploymentOutputs() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - mcu.queryDeployment("cloudSiteId", "tenantId", "deploymentId"); - assert (mcu.queryDeployment("cloudSiteId", "tenantId", "deploymentId") != null); - } - - @Test(expected = NullPointerException.class) - public void testUninstallAndDeleteDeployment() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - mcu.uninstallAndDeleteDeployment("cloudSiteId", "tenantId", "deploymentId", 1); - assert (mcu.uninstallAndDeleteDeployment("cloudSiteId", "tenantId", "deploymentId", 1) != null); - } - - @Test(expected = NullPointerException.class) - public void testIsBlueprintLoaded() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - mcu.isBlueprintLoaded("cloudSiteId", "blueprintId"); - assertTrue(mcu.isBlueprintLoaded("cloudSiteId", "blueprintId")); - } - - @Test(expected = MsoCloudifyManagerNotFound.class) - public void testCloudifyClient() throws MsoException { - msoPropertiesFactory = mock(MsoPropertiesFactory.class); - cloudConfigFactory = mock(CloudConfigFactory.class); - cloudSite = mock(CloudSite.class); - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - mcu.getCloudifyClient(cloudSite); - assert (mcu.getCloudifyClient(cloudSite) != null); - - } - - @Test(expected = NullPointerException.class) - public void testuploadBlueprint() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - - Map<String, byte[]> blueprintFiles = new HashMap<String, byte[]>(); - byte[] byteArray = new byte[]{8, 1, 2, 8}; - blueprintFiles.put("1", byteArray); - - mcu.uploadBlueprint("cloudSiteId", "blueprintId", "mainFileName", blueprintFiles, false); - - } - - @Test(expected = NullPointerException.class) - public void testqueryDeployment() throws MsoException { - - MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); - mcu.queryDeployment(cloudify, "deploymentId"); - assert (mcu.queryDeployment(cloudify, "deploymentId") != null); - - - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest2.java deleted file mode 100644 index 05608b4d99..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest2.java +++ /dev/null @@ -1,254 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.cloudify.utils;
-
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.vdu.CloudInfo;
-import org.openecomp.mso.adapters.vdu.PluginAction;
-import org.openecomp.mso.adapters.vdu.VduArtifact;
-import org.openecomp.mso.adapters.vdu.VduArtifact.ArtifactType;
-import org.openecomp.mso.adapters.vdu.VduInstance;
-import org.openecomp.mso.adapters.vdu.VduModelInfo;
-import org.openecomp.mso.adapters.vdu.VduStateType;
-import org.openecomp.mso.adapters.vdu.VduStatus;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.cloudify.beans.DeploymentInfo;
-import org.openecomp.mso.cloudify.beans.DeploymentStatus;
-import org.openecomp.mso.cloudify.v3.client.Cloudify;
-import org.openecomp.mso.cloudify.v3.model.AzureConfig;
-import org.openecomp.mso.cloudify.v3.model.OpenstackConfig;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-
-public class MsoCloudifyUtilsTest2 {
-
- @Test
- public void instantiateVduTest() throws MsoException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("id");
- expected.setVduInstanceName("id");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.INSTANTIATED);
- status.setLastAction(new PluginAction(null, null, null));
- expected.setStatus(status);
-
- MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class);
- CloudSite site = new CloudSite();
- Optional<CloudSite> opSite = Optional.ofNullable(site);
- CloudConfig config = Mockito.mock(CloudConfig.class);
- cloudify.cloudConfig = config;
- Cloudify cloudifyClient = new Cloudify("cloudSite");
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- VduModelInfo vduModel = new VduModelInfo();
- vduModel.setModelCustomizationUUID("blueprintId");
- vduModel.setTimeoutMinutes(1);
- VduArtifact artifact = new VduArtifact();
- artifact.setName("name");
- artifact.setType(ArtifactType.MAIN_TEMPLATE);
- byte[] content = new byte[1];
- artifact.setContent(content);
- List<VduArtifact> artifacts = new ArrayList<>();
- artifacts.add(artifact);
- vduModel.setArtifacts(artifacts);
- DeploymentInfo deployment = new DeploymentInfo();
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.INSTALLED);
- Map<String, byte[]> blueprintFiles = new HashMap<>();
- blueprintFiles.put(artifact.getName(), artifact.getContent());
- String instanceName = "instanceName";
- Map<String, Object> inputs = new HashMap<>();
- boolean rollbackOnFailure = true;
-
- when(config.getCloudSite(cloudInfo.getCloudSiteId())).thenReturn(opSite);
- doReturn(false).when(cloudify).isBlueprintLoaded(cloudInfo.getCloudSiteId(),
- vduModel.getModelCustomizationUUID());
- doReturn(cloudifyClient).when(cloudify).getCloudifyClient(site);
- doReturn(true).when(cloudify).uploadBlueprint(cloudifyClient, vduModel.getModelCustomizationUUID(),
- artifact.getName(), blueprintFiles);
- doReturn(deployment).when(cloudify).createAndInstallDeployment(cloudInfo.getCloudSiteId(),
- cloudInfo.getTenantId(), instanceName, vduModel.getModelCustomizationUUID(), inputs, true,
- vduModel.getTimeoutMinutes(), rollbackOnFailure);
-
- VduInstance actual = cloudify.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void queryVduTest() throws MsoException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("id");
- expected.setVduInstanceName("id");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.INSTANTIATED);
- status.setLastAction(new PluginAction(null, null, null));
- expected.setStatus(status);
-
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- DeploymentInfo deployment = new DeploymentInfo();
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.INSTALLED);
- String instanceId = "instanceId";
-
- MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class);
-
- doReturn(deployment).when(cloudify).queryDeployment(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(),
- instanceId);
-
- VduInstance actual = cloudify.queryVdu(cloudInfo, instanceId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void deleteVduTest() throws MsoException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("id");
- expected.setVduInstanceName("id");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.DELETING);
- status.setLastAction(new PluginAction("deleting", null, null));
- expected.setStatus(status);
-
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- String instanceId = "instanceId";
- int timeoutMinutes = 1;
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
- MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class);
- doReturn(deployment).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(),
- cloudInfo.getTenantId(), instanceId, timeoutMinutes);
-
- VduInstance actual = cloudify.deleteVdu(cloudInfo, instanceId, timeoutMinutes);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void deploymentInfoToVduInstanceTest() {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("id");
- expected.setVduInstanceName("id");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.DELETING);
- status.setLastAction(new PluginAction("deleting", null, null));
- expected.setStatus(status);
-
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
-
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
-
- VduInstance actual = cloudify.deploymentInfoToVduInstance(deployment);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void deploymentStatusToVduStatusTest() {
- VduStatus expected = new VduStatus();
- expected.setState(VduStateType.DELETING);
- expected.setLastAction(new PluginAction("deleting", null, null));
-
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
-
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
-
- VduStatus actual = cloudify.deploymentStatusToVduStatus(deployment);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void getOpenstackConfigTest() {
- OpenstackConfig expected = new OpenstackConfig();
- expected.setRegion("regionId");
- expected.setAuthUrl("identityUrl");
- expected.setUsername("msoId");
- expected.setPassword("msoPass");
- expected.setTenantName("tenantId");
-
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
- CloudSite cloudSite = Mockito.mock(CloudSite.class);
- CloudIdentity cloudIdentity = Mockito.mock(CloudIdentity.class);
- when(cloudSite.getIdentityService()).thenReturn(cloudIdentity);
- when(cloudSite.getRegionId()).thenReturn("regionId");
- when(cloudIdentity.getIdentityUrl()).thenReturn("identityUrl");
- when(cloudIdentity.getMsoId()).thenReturn("msoId");
- when(cloudIdentity.getMsoPass()).thenReturn("msoPass");
- String tenantId = "tenantId";
- OpenstackConfig actual = cloudify.getOpenstackConfig(cloudSite, tenantId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void getAzureConfigTest() {
- AzureConfig expected = new AzureConfig();
- expected.setSubscriptionId("subscriptionId");
- expected.setTenantId("tenantId");
- expected.setClientId("msoId");
- expected.setClientSecret("msoPass");
-
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
- CloudSite cloudSite = Mockito.mock(CloudSite.class);
- CloudIdentity cloudIdentity = Mockito.mock(CloudIdentity.class);
- when(cloudSite.getIdentityService()).thenReturn(cloudIdentity);
- when(cloudIdentity.getAdminTenant()).thenReturn("subscriptionId");
- when(cloudIdentity.getMsoId()).thenReturn("msoId");
- when(cloudIdentity.getMsoPass()).thenReturn("msoPass");
- String tenantId = "tenantId";
- AzureConfig actual = cloudify.getAzureConfig(cloudSite, tenantId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantTest.java deleted file mode 100644 index a1de54e231..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/MsoTenantTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.openstack.beans; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class MsoTenantTest { - MsoTenant ms = new MsoTenant(); - - @Test - public void test() { - Map<String, String> map = new HashMap<>(); - map.put("id","name"); - ms.setTenantId("tenantId"); - ms.setTenantName("tenantName"); - ms.setMetadata(map); - assert(ms.getMetadata().equals(map)); - assert(ms.getTenantId().equals("tenantId")); - assert(ms.getTenantName().equals("tenantName")); - } -} 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 deleted file mode 100644 index 0f357e5555..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openstack.beans; - -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 { - - private static final String NETWORK_STATUS_ACTIVE = "ACTIVE"; - private static final String NETWORK_STATUS_ID = "networkIdTest"; - private static final String NETWORK_STATUS_NAME = "networkNameTest"; - private static final String SUBNET_NAME = "subnetTest"; - private static final String PROVIDER = "providerTest"; - private static final String PROVIDER_NETWORK_TYPE_VLAN = "vlan"; - private static final String PROVIDER_NETWORK_TYPE_OTHER = "providerTypeTest"; - private static final Integer PROVIDER_SEGMENTATION_ID = 777; - private static final String PROVIDER_FOR_SEGMENT = "providerSegmentTest"; - private static final Integer PROVIDER_SEGMENTATION_ID_FOR_SEGMENT = 123; - - @Test - public void networkStatusUnknownWhenIsNullInNetwork() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetwork(null)); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.UNKNOWN); - checkCommonPartWhenProviderIsNotPresent(networkInfo); - } - - @Test - public void networkStatusUnknownWhenNotFoundInNetworkStatusMap() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetwork("notExistingNetworkStatus")); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.UNKNOWN); - checkCommonPartWhenProviderIsNotPresent(networkInfo); - } - - @Test - public void setNetworkStatusWhenNetworkStatusFoundInNetworkStatusMap() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetwork(NETWORK_STATUS_ACTIVE)); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE); - checkCommonPartWhenProviderIsNotPresent(networkInfo); - } - - @Test - public void setVLANProviderFromTheNetwork() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithProvider(NETWORK_STATUS_ACTIVE, PROVIDER, - PROVIDER_NETWORK_TYPE_VLAN)); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE); - assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER); - assertThat(networkInfo.getVlans()).hasSize(1).contains(PROVIDER_SEGMENTATION_ID); - checkCommonPart(networkInfo); - } - - @Test - public void setOtherProviderFromTheNetwork() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithProvider(NETWORK_STATUS_ACTIVE, PROVIDER, - PROVIDER_NETWORK_TYPE_OTHER)); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE); - assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER); - assertThat(networkInfo.getVlans()).isEmpty(); - checkCommonPart(networkInfo); - } - - @Test - public void setVLANProviderFromTheNetworkSegments() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithSegments(NETWORK_STATUS_ACTIVE, - prepareSegment(PROVIDER_NETWORK_TYPE_VLAN))); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE); - assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER_FOR_SEGMENT); - assertThat(networkInfo.getVlans()).hasSize(1).contains(PROVIDER_SEGMENTATION_ID_FOR_SEGMENT); - checkCommonPart(networkInfo); - } - - @Test - public void setOtherProviderFromTheNetworkSegments() { - NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithSegments(NETWORK_STATUS_ACTIVE, - prepareSegment(PROVIDER_NETWORK_TYPE_OTHER))); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE); - assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER_FOR_SEGMENT); - assertThat(networkInfo.getVlans()).isEmpty(); - checkCommonPart(networkInfo); - } - - @Test - public void setNetworkStatusNotFoundWhenNetworkIsNull() { - NetworkInfo networkInfo = new NetworkInfo(null); - assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.NOTFOUND); - } - - private void checkCommonPartWhenProviderIsNotPresent(NetworkInfo networkInfo) { - assertThat(networkInfo.getProvider()).isEmpty(); - assertThat(networkInfo.getVlans()).isEmpty(); - checkCommonPart(networkInfo); - } - - private void checkCommonPart(NetworkInfo networkInfo) { - assertThat(networkInfo.getId()).isEqualTo(NETWORK_STATUS_ID); - assertThat(networkInfo.getName()).isEqualTo(NETWORK_STATUS_NAME); - assertThat(networkInfo.getSubnets()).hasSize(1).contains(SUBNET_NAME); - } - - private Network prepareNetwork(String networkStatus) { - Network network = new Network(); - network.setId(NETWORK_STATUS_ID); - network.setName(NETWORK_STATUS_NAME); - network.setStatus(networkStatus); - List<String> subnets = new ArrayList<>(); - subnets.add(SUBNET_NAME); - network.setSubnets(subnets); - return network; - } - - private Network prepareNetworkWithProvider(String networkStatus, String providerPhysicalNetwork, String providerNetworkType) { - Network network = prepareNetwork(networkStatus); - network.setProviderPhysicalNetwork(providerPhysicalNetwork); - network.setProviderNetworkType(providerNetworkType); - network.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID); - return network; - } - - private Network prepareNetworkWithSegments(String networkStatus, Segment segment) { - Network network = prepareNetwork(networkStatus); - List<Segment> segments = new ArrayList<>(); - segments.add(segment); - network.setSegments(segments); - return network; - } - - private Segment prepareSegment(String providerNetworkType) { - Segment segment = new Segment(); - segment.setProviderPhysicalNetwork(PROVIDER_FOR_SEGMENT); - segment.setProviderNetworkType(providerNetworkType); - segment.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID_FOR_SEGMENT); - return segment; - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackTest.java deleted file mode 100644 index d70c01d0d3..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkRollbackTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.openecomp.mso.openstack.beans; - -import static org.junit.Assert.*; -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.openecomp.mso.entity.MsoRequest; - -public class NetworkRollbackTest { - @Mock - MsoRequest ms = new MsoRequest(); - - @InjectMocks - NetworkRollback nr = new NetworkRollback(); - - @Test - public void test() { - List<Integer> vlans = new ArrayList(); - vlans.add(1); - vlans.add(2); - nr.setCloudId("cloudId"); - nr.setModelCustomizationUuid("modelCustomizationUuid"); - nr.setNetworkId("networkId"); - nr.setNetworkName("networkName"); - nr.setNetworkStackId("networkStackId"); - nr.setNetworkType("networkType");; - nr.setNeutronNetworkId("neutronNetworkId"); - nr.setPhysicalNetwork("physicalNetwork"); - nr.setTenantId("tenantId"); - nr.setNetworkCreated(false); - nr.setVlans(vlans); - nr.setMsoRequest(ms); - assert(nr.getCloudId().equals("cloudId")); - assert(nr.getModelCustomizationUuid().equals("modelCustomizationUuid")); - assert(nr.getNetworkId().equals("networkId")); - assert(nr.getNetworkName().equals("networkName")); - assert(nr.getNetworkStackId().equals("networkStackId")); - assert(nr.getNeutronNetworkId().equals("neutronNetworkId")); - assert(nr.getPhysicalNetwork().equals("physicalNetwork")); - assert(nr.getNetworkType().equals("networkType")); - assert(nr.getTenantId().equals("tenantId")); - assert(nr.getMsoRequest().equals(ms)); - assertFalse(nr.getNetworkCreated()); - assert(nr.getVlans().equals(vlans)); - assert(nr.toString()!=null); - } -} 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 deleted file mode 100644 index 9c7911ef89..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/StackInfoTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -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; - -public class StackInfoTest { - - private static final String STACK_NAME = "stackNameTest"; - private static final String STACK_STATUS = "CREATE_COMPLETE"; - private static final String STACK_OUTPUT_KEY = "outputKeyTest"; - private static final String STACK_OUTPUT_VALUE = "outputValueTest"; - private static final String STACK_PARAM_KEY = "paramKeyTest"; - private static final String STACK_PARAM_VALUE = "paramValueTest"; - - @Test - public void setStatusNotFoundWhenStackIsNull() { - StackInfo stackInfo = new StackInfo(null); - assertThat(stackInfo.getStatus()).isEqualTo(HeatStatus.NOTFOUND); - assertThat(stackInfo.getOutputs()).isEmpty(); - assertThat(stackInfo.getParameters()).isEmpty(); - } - - @Test - public void createObjectWhenStackStatusIsNull() { - StackInfo stackInfo = new StackInfo(createStackWithStatus(null)); - assertThat(stackInfo.getName()).isEqualTo(STACK_NAME); - assertThat(stackInfo.getOutputs()).isEmpty(); - assertThat(stackInfo.getStatus()).isEqualTo(HeatStatus.INIT); - assertThat(stackInfo.getParameters()).hasSize(1).containsEntry(STACK_PARAM_KEY, STACK_PARAM_VALUE); - } - - @Test - public void createObjectWhenStackStatusIsFound() { - StackInfo stackInfo = new StackInfo(createStackWithStatus(STACK_STATUS)); - assertThat(stackInfo.getName()).isEqualTo(STACK_NAME); - assertThat(stackInfo.getOutputs()).isEmpty(); - assertThat(stackInfo.getStatus()).isEqualTo(HeatStatus.CREATED); - assertThat(stackInfo.getParameters()).hasSize(1).containsEntry(STACK_PARAM_KEY, STACK_PARAM_VALUE); - } - - @Test - public void createObjectWhenStackStatusIsUnknown() { - StackInfo stackInfo = new StackInfo(createStackWithStatus("unknownStatus")); - assertThat(stackInfo.getName()).isEqualTo(STACK_NAME); - assertThat(stackInfo.getOutputs()).isEmpty(); - assertThat(stackInfo.getStatus()).isEqualTo(HeatStatus.UNKNOWN); - assertThat(stackInfo.getParameters()).hasSize(1).containsEntry(STACK_PARAM_KEY, STACK_PARAM_VALUE); - } - - @Test - public void createStackWhenOutputsListIsNotNull() throws IOException { - StackInfo stackInfo = new StackInfo(createStackWithOutputs()); - assertThat(stackInfo.getOutputs()).isNotEmpty().hasSize(1); - assertThat(stackInfo.getOutputs()).hasSize(1).containsEntry(STACK_OUTPUT_KEY, STACK_OUTPUT_VALUE); - } - - private Stack createStackWithStatus(String stackStatus) { - Stack stack = new Stack(); - stack.setStackName(STACK_NAME); - stack.setStackStatus(stackStatus); - stack.getParameters().put(STACK_PARAM_KEY, STACK_PARAM_VALUE); - return stack; - } - - private Stack createStackWithOutputs() throws IOException { - String json = "{\"outputs\":[{\"output_key\" : \"" + STACK_OUTPUT_KEY + "\", \"output_value\" : \"" - + STACK_OUTPUT_VALUE + "\" }]}"; - JsonNode node = new ObjectMapper().readTree(json); - Stack stack = new ObjectMapper().readValue(node, Stack.class); - return stack; - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryTest.java deleted file mode 100644 index 668bc68a3d..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntryTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openstack.utils; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class MsoHeatEnvironmentEntryTest { - - private static final String PARAMETER_NAME = "keyTest"; - private static final String VALUE_NAME = "valueTest"; - private static final String NOT_EXISTING_PARAM = "notExistingParam"; - private static final String RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY = "parameters: {" - + PARAMETER_NAME + ": " + VALUE_NAME + "}"; - private static final String RAW_ENTRY_WITH_RESOURCE_REGISTRY = "resource_registry: resourceTest"; - private static final String RAW_ENTRY_INVALID = "invalidRawEntry"; - - @Test - public void createObjectWithNullStringBuilder() { - MsoHeatEnvironmentEntry testedObject = new MsoHeatEnvironmentEntry(null); - assertThat(testedObject.isValid()).isTrue(); - assertThat(testedObject.getRawEntry()).isNull(); - assertThat(testedObject.containsParameter(PARAMETER_NAME)).isFalse(); - } - - @Test - public void toFullString_ResourceRegistryNotPresentInRawEntry() { - StringBuilder sb = new StringBuilder(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY); - MsoHeatEnvironmentEntry testedObject = new MsoHeatEnvironmentEntry(sb); - assertThat(testedObject.getRawEntry()).isEqualTo(sb); - assertThat(testedObject.isValid()).isTrue(); - assertThat(testedObject.containsParameter(PARAMETER_NAME)).isTrue(); - assertThat(testedObject.toString()).doesNotContain(RAW_ENTRY_WITH_RESOURCE_REGISTRY); - } - - @Test - public void toFullString_ExceptionOccurred() { - StringBuilder sb = new StringBuilder(RAW_ENTRY_INVALID); - MsoHeatEnvironmentEntry testedObject = new MsoHeatEnvironmentEntry(sb); - assertThat(testedObject.getRawEntry()).isEqualTo(sb); - assertThat(testedObject.isValid()).isFalse(); - assertThat(testedObject.getErrorString()).isNotNull().isNotEmpty(); - } - - @Test - public void checkIfContainsTheParameter() { - StringBuilder sb = new StringBuilder(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY); - MsoHeatEnvironmentEntry testedObject = new MsoHeatEnvironmentEntry(sb); - assertThat(testedObject.getRawEntry()).isEqualTo(sb); - assertThat(testedObject.isValid()).isTrue(); - assertThat(testedObject.containsParameter(PARAMETER_NAME)).isTrue(); - assertThat(testedObject.containsParameter(NOT_EXISTING_PARAM)).isFalse(); - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterTest.java deleted file mode 100644 index 17a94840cf..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentParameterTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-
-public class MsoHeatEnvironmentParameterTest {
-
- @Test
- public void test() {
- MsoHeatEnvironmentParameter hep=mock(MsoHeatEnvironmentParameter.class);
- Object op=hep.getName();
- MsoHeatEnvironmentParameter meo=new MsoHeatEnvironmentParameter();
- MsoHeatEnvironmentParameter mea=new MsoHeatEnvironmentParameter("name");
- MsoHeatEnvironmentParameter mep=new MsoHeatEnvironmentParameter("name"," value");
- mea.setName("name");
- mep.setValue("value");
- assert(mea.getName().equals("name"));
- assert(mep.getValue().equals("value"));
- assert(meo.toString()!=null);
- //assertTrue(op.equals(hep));
- meo.equals(op);
- meo.hashCode();
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceTest.java deleted file mode 100644 index fb666ea5df..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResourceTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import org.junit.Test;
-
-
-public class MsoHeatEnvironmentResourceTest {
-
-
- @Test
- public void test() {
- Object op=true;
- // MsoHeatEnvironmentResource mer=mock(MsoHeatEnvironmentResource.class);
- // MsoHeatEnvironmentResource mrea=new MsoHeatEnvironmentResource();
- MsoHeatEnvironmentResource mre=new MsoHeatEnvironmentResource("name");
- MsoHeatEnvironmentResource mae=new MsoHeatEnvironmentResource("name", "value");
- mre.setName("name");
- mae.setValue("value");
- assert(mre.getName().equals("name"));
- assert(mae.getValue().equals("value"));
- assert(mre.toString()!=null);
- //assertFalse(mer.equals(op));
- mae.equals(op);
- mae.hashCode();
- //when(mer.hashCode()).thenReturn(result);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java deleted file mode 100644 index 9ba9b2f39d..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openstack.utils; - - -import com.woorea.openstack.heat.Heat; -import com.woorea.openstack.heat.model.Stack; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.openstack.beans.HeatStatus; -import org.openecomp.mso.openstack.beans.StackInfo; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.exceptions.MsoTenantNotFound; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.doReturn; - -//@RunWith(PowerMockRunner.class) -@PrepareForTest({MsoHeatUtils.class}) - - -public class MsoHeatUtilsTest { - - @Mock - StackInfo stackInfo; - - @Mock - MsoPropertiesFactory msoPropertiesFactory; - - @Mock - CloudConfigFactory cloudConfigFactory; - - @Mock - Heat heatClient; - - @Mock - CloudSite cloudSite; - - @Test(expected = NullPointerException.class) - public void testCreateStack() throws MsoException - { - - MsoHeatUtils mht = PowerMockito.spy(new MsoHeatUtils("msoPropID" ,msoPropertiesFactory,cloudConfigFactory)); - Map<String,String>metadata=new HashMap<>(); - metadata.put("1", "value"); - mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1); - doReturn(mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - null, null, - null, - true)); - - } - - @Test(expected = NullPointerException.class) - public void testCreateStackOne() throws MsoException - { - MsoHeatUtils mht = PowerMockito.spy(new MsoHeatUtils("msoPropID" ,msoPropertiesFactory,cloudConfigFactory)); - Map<String,String>metadata=new HashMap<>(); - metadata.put("1", "value"); - mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env"); - doReturn(mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env", null, - null, - true)); - } - - @Test(expected = NullPointerException.class) - public void testCreateStackTwo() throws MsoException - { - MsoHeatUtils mht = PowerMockito.spy(new MsoHeatUtils("msoPropID" ,msoPropertiesFactory,cloudConfigFactory)); - Map<String,String>metadata=new HashMap<>(); - metadata.put("1", "value"); - Map<String,Object>fileMap=new HashMap<>(); - fileMap.put("2", "value"); - mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env", - fileMap); - doReturn(mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env", fileMap, - null, - true)); - } - - @Test(expected = NullPointerException.class) - public void testCreateStackThree() throws MsoException - { - MsoHeatUtils mht = PowerMockito.spy(new MsoHeatUtils("msoPropID" ,msoPropertiesFactory,cloudConfigFactory)); - Map<String,String>metadata=new HashMap<>(); - metadata.put("1", "value"); - Map<String,Object>fileMap=new HashMap<>(); - fileMap.put("2", "value"); - Map<String,Object>heatFileMap=new HashMap<>(); - heatFileMap.put("3", "value"); - mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env", - fileMap, - heatFileMap); - doReturn(mht.createStack("cloudSiteId", - "tenantId", - "stackName", - "heatTemplate", - metadata, - true, - 1, - "env", fileMap, - heatFileMap, - true)); - } - - @Test(expected = NullPointerException.class) - - - public void testqueryStack() throws MsoException - { - MsoHeatUtils mht = PowerMockito.spy(new MsoHeatUtils("msoPropID" ,msoPropertiesFactory,cloudConfigFactory)); - - mht.queryStack("cloudSiteId","tenantId","stackName"); - - try { - heatClient = mht.getHeatClient (cloudSite, "tenantId"); - assertNotNull(heatClient); - - } catch (MsoTenantNotFound e) { - doReturn(new StackInfo ("stackName", HeatStatus.NOTFOUND)); - } catch (MsoException me) { - - me.addContext ("QueryStack"); - throw me; - } - - Stack heatStack = mht.queryHeatStack (heatClient, "stackName"); - - assertNull(heatStack); - StackInfo stackInfo = new StackInfo ("stackName", HeatStatus.NOTFOUND); - doReturn(stackInfo); - - assertNotNull(heatStack); - doReturn(new StackInfo (heatStack)); - - - - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest2.java deleted file mode 100644 index 74d512c63e..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest2.java +++ /dev/null @@ -1,172 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.openstack.utils;
-
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.vdu.CloudInfo;
-import org.openecomp.mso.adapters.vdu.PluginAction;
-import org.openecomp.mso.adapters.vdu.VduArtifact;
-import org.openecomp.mso.adapters.vdu.VduArtifact.ArtifactType;
-import org.openecomp.mso.adapters.vdu.VduInstance;
-import org.openecomp.mso.adapters.vdu.VduModelInfo;
-import org.openecomp.mso.adapters.vdu.VduStateType;
-import org.openecomp.mso.adapters.vdu.VduStatus;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.cloudify.beans.DeploymentInfo;
-import org.openecomp.mso.cloudify.beans.DeploymentStatus;
-import org.openecomp.mso.cloudify.utils.MsoCloudifyUtils;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-
-public class MsoHeatUtilsTest2 {
-
- @Test
- public void instantiateVduTest() throws MsoException, JsonProcessingException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("canonicalName");
- expected.setVduInstanceName("name");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.INSTANTIATED);
- status.setLastAction((new PluginAction("create", "complete", "")));
- expected.setStatus(status);
-
- MsoHeatUtils heatUtils = Mockito.spy(MsoHeatUtils.class);
- CloudSite site = new CloudSite();
- Optional<CloudSite> opSite = Optional.ofNullable(site);
- CloudConfig config = Mockito.mock(CloudConfig.class);
- CloudConfigFactory cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- when(cloudConfigFactory.getCloudConfig()).thenReturn(config);
- when(heatUtils.getCloudConfigFactory()).thenReturn(cloudConfigFactory);
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- VduModelInfo vduModel = new VduModelInfo();
- vduModel.setModelCustomizationUUID("blueprintId");
- vduModel.setTimeoutMinutes(1);
- VduArtifact artifact = new VduArtifact();
- artifact.setName("name");
- artifact.setType(ArtifactType.MAIN_TEMPLATE);
- byte[] content = new byte[1];
- artifact.setContent(content);
- List<VduArtifact> artifacts = new ArrayList<>();
- artifacts.add(artifact);
- vduModel.setArtifacts(artifacts);
- Map<String, byte[]> blueprintFiles = new HashMap<>();
- blueprintFiles.put(artifact.getName(), artifact.getContent());
- String instanceName = "instanceName";
- Map<String, Object> inputs = new HashMap<>();
- boolean rollbackOnFailure = true;
- String heatTemplate = new String(artifact.getContent());
- when(config.getCloudSite(cloudInfo.getCloudSiteId())).thenReturn(opSite);
- Map<String, Object> nestedTemplates = new HashMap<String, Object>();
- Map<String, Object> files = new HashMap<String, Object>();
-
- StackInfo stackInfo = new StackInfo();
- stackInfo.setCanonicalName("canonicalName");
- stackInfo.setName("name");
- stackInfo.setStatus(HeatStatus.CREATED);
-
- doReturn(stackInfo).when(heatUtils).createStack(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(),
- instanceName, heatTemplate, inputs, true, vduModel.getTimeoutMinutes(), null, nestedTemplates, files,
- rollbackOnFailure);
-
- VduInstance actual = heatUtils.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void queryVduTest() throws MsoException, JsonProcessingException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("canonicalName");
- expected.setVduInstanceName("name");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.INSTANTIATED);
- status.setLastAction((new PluginAction("create", "complete", "")));
- expected.setStatus(status);
-
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- String instanceId = "instanceId";
-
- StackInfo stackInfo = new StackInfo();
- stackInfo.setCanonicalName("canonicalName");
- stackInfo.setName("name");
- stackInfo.setStatus(HeatStatus.CREATED);
-
- MsoHeatUtils heatUtils = Mockito.spy(MsoHeatUtils.class);
-
- doReturn(stackInfo).when(heatUtils).queryStack(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(), instanceId);
-
- VduInstance actual = heatUtils.queryVdu(cloudInfo, instanceId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void deleteVduTest() throws MsoException {
- VduInstance expected = new VduInstance();
- expected.setVduInstanceId("canonicalName");
- expected.setVduInstanceName("name");
- VduStatus status = new VduStatus();
- status.setState(VduStateType.DELETED);
- expected.setStatus(status);
-
- CloudInfo cloudInfo = new CloudInfo();
- cloudInfo.setCloudSiteId("cloudSiteId");
- cloudInfo.setTenantId("tenantId");
- String instanceId = "instanceId";
-
- StackInfo stackInfo = new StackInfo();
- stackInfo.setCanonicalName("canonicalName");
- stackInfo.setName("name");
- stackInfo.setStatus(HeatStatus.NOTFOUND);
-
- int timeoutInMinutes = 1;
-
- MsoHeatUtils heatUtils = Mockito.spy(MsoHeatUtils.class);
-
- doReturn(stackInfo).when(heatUtils).deleteStack( cloudInfo.getTenantId(), cloudInfo.getCloudSiteId(), instanceId, true);
-
- VduInstance actual = heatUtils.deleteVdu(cloudInfo, instanceId, timeoutInMinutes);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java deleted file mode 100644 index f2d14d8b22..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.openstack.beans.MsoTenant;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Tenant;
-
-//@RunWith(PowerMockRunner.class)
-@PrepareForTest({MsoKeystoneUtils.class,CloudSite.class,CloudIdentity.class,Tenant.class,Keystone.class,MsoTenant.class,MsoJavaProperties.class})
-public class MsoKeystoneUtilsTest {
-
- @Mock
- Tenant tenant;
-
- @Mock
- Keystone adminClient;
-
- @Mock
- MsoTenant mst;
-
- @Mock
- CloudSite cs;
-
- @Mock
- CloudIdentity cloudIdentity;
-
- @Mock
- MsoJavaProperties msoProps;
-
- @Mock
- private static CloudConfigFactory cloudConfigFactory;
-
- @BeforeClass
- public static final void prepare () {
- cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- Mockito.when(cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- }
-
- @Test
- public void testcreateTenant() throws MsoException{
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- Map<String,String>metadata=new HashMap<>();
- metadata.put("1", "value");
- tenant = mock(Tenant.class);
- PowerMockito.when(tenant.getId ()).thenReturn("ID");
- doReturn(tenant.getId ()).when(msk).createTenant("tenantName", "cloudSiteId", metadata, true);
- PowerMockito.spy(tenant.getId ());
- String Id = msk.createTenant("tenantName", "cloudSiteId", metadata, true);
- Assert.assertEquals(tenant.getId (), Id);
- assert(msk.createTenant("tenantName", "cloudSiteId", metadata, true)!=null);
- }
- @Test
- public void testdeleteTenant() throws MsoException{
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- doReturn(true).when(msk).deleteTenant("tenantId", "cloudSiteId");
- assertTrue(msk.deleteTenant("tenantId", "cloudSiteId"));
- }
- @Test
- public void testfindTenantByName() throws Exception{
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- doReturn(null).when(msk).findTenantByName(adminClient, "tenantName");
- assertNull(msk.findTenantByName(adminClient, "tenantName"));
- }
- @Test
- public void testqueryTenant() throws MsoException{
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- Map<String,String>metadata=new HashMap<>();
- metadata.put("1", "value");
- mst = mock(MsoTenant.class);
- PowerMockito.when(mst.getTenantId()).thenReturn("tenantId");
- PowerMockito.when(mst.getMetadata()).thenReturn(metadata);
- PowerMockito.when(mst.getTenantName()).thenReturn("name");
- doReturn(mst).when(msk).queryTenant ("tenantId", "cloudSiteId");
- assertNotNull(msk.queryTenant("tenantId", "cloudSiteId"));
- }
-
- @Test
- public void testqueryTenantByName()throws MsoException {
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- Map<String,String>metadata=new HashMap<>();
- metadata.put("1", "value");
- mst = mock(MsoTenant.class);
- PowerMockito.when(mst.getTenantId()).thenReturn("tenantId");
- PowerMockito.when(mst.getMetadata()).thenReturn(metadata);
- PowerMockito.when(mst.getTenantName()).thenReturn("name");
- doReturn(mst).when(msk).queryTenantByName ("tenantId", "cloudSiteId");
- assertNotNull(msk.queryTenantByName("tenantId", "cloudSiteId"));
-
- }
-
- @Test
- public void testgetKeystoneAdminClient() throws MsoException{
- cloudIdentity = mock(CloudIdentity.class);
- Keystone keystone = new Keystone (cloudIdentity.getKeystoneUrl ("region", "msoPropID"));
- MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID", cloudConfigFactory));
- doReturn(keystone).when(msk).getKeystoneAdminClient(cs);
- assertNotNull(msk.getKeystoneAdminClient(cs));
- }
-}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java deleted file mode 100644 index 839da370df..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.openstack.beans.NetworkInfo;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoNeutronUtils.NetworkType;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import com.woorea.openstack.quantum.Quantum;
-import com.woorea.openstack.quantum.model.Network;
-import com.woorea.openstack.quantum.model.Segment;
-
-
-//@RunWith(PowerMockRunner.class)
-@PrepareForTest({MsoNeutronUtils.class,MsoCommonUtils.class,NetworkInfo.class,CloudConfigFactory.class,CloudConfig.class,Segment.class,Network.class,Quantum.class})
-public class MsoNeutronUtilsTest{
-
-@Mock
-MsoCommonUtils utils;
-
-@Mock
-NetworkInfo net;
-
-@Mock
-CloudConfig cloudConfig;
-
-@Mock
-Segment segment;
-
-@Mock
-CloudConfigFactory cloudConfigFactory;
-
-@Mock
-Network network;
-
-@Mock
-NetworkInfo ninfo;
-
-@Mock
-Quantum neutronClient;
-
-@Mock
-CloudSite cloudSite;
-
-
- @Test
- public void testcreateNetwork() throws MsoException{
- List<Integer> vlans=new ArrayList();
- vlans.add(1);
- cloudConfigFactory = mock(CloudConfigFactory.class);
- ninfo = mock(NetworkInfo.class);
- MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
- NetworkType type=NetworkType.PROVIDER;
- doReturn(ninfo).when(mnu).createNetwork("cloudSiteId", "tenantId", type, "networkName", "provider", vlans);
- assert(mnu.createNetwork("cloudSiteId", "tenantId", type, "networkName", "provider", vlans)!=null);
-
- }
- @Test
- public void testqueryNetwork() throws MsoException{
- cloudConfigFactory = mock(CloudConfigFactory.class);
- ninfo = mock(NetworkInfo.class);
- MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
- doReturn(ninfo).when(mnu).queryNetwork("networkNameOrId", "tenantId", "cloudSiteId");
- NetworkInfo ni = mnu.queryNetwork("networkNameOrId", "tenantId", "cloudSiteId");
- assert(ni!=null);
- }
-
- @Test
- public void testdeleteNetwork() throws MsoException{
- cloudConfigFactory = mock(CloudConfigFactory.class);
- MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
- doReturn(true).when(mnu).deleteNetwork("networkId", "tenantId", "cloudSiteId");
- assertTrue(mnu.deleteNetwork("networkId", "tenantId", "cloudSiteId"));
-
- }
- @Test
- public void testupdateNetwork() throws MsoException{
- List<Integer> vlans=new ArrayList();
- vlans.add(1);
- NetworkType type=NetworkType.PROVIDER;
- cloudConfigFactory = mock(CloudConfigFactory.class);
- ninfo = mock(NetworkInfo.class);
- MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
- doReturn(ninfo).when(mnu).updateNetwork("cloudSiteId", "tenantId", "Nid", type, "provider", vlans);
- assert(mnu.updateNetwork("cloudSiteId", "tenantId", "Nid", type, "provider", vlans)!=null);
- }
-
- }
-
-
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactoryTest.java deleted file mode 100644 index a759e0d1a6..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactoryTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
-
-public class MsoTenantUtilsFactoryTest {
-
- MsoTenantUtils tenantU = null;
-
- @Test
- public void test() throws MsoCloudSiteNotFound {
- tenantU = mock( MsoKeystoneUtils.class);
- new MsoTenantUtilsFactory("ID");
- MsoTenantUtilsFactory mti=mock(MsoTenantUtilsFactory.class);
- mti.getTenantUtils("cloudSiteId");
- when(mti.getTenantUtils("cloudSiteId")).thenReturn(tenantU);
- mti.getTenantUtilsByServerType("type");
- when(mti.getTenantUtilsByServerType("type")).thenReturn(tenantU);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsTest.java deleted file mode 100644 index ffb1e3b787..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.openecomp.mso.cloud.CloudIdentity;
-
-@RunWith(MockitoJUnitRunner.class)
-public class MsoTenantUtilsTest {
-
- @Test
- public void test()throws Exception {
- MsoTenantUtils mtu =mock(MsoTenantUtils.class);
- //MsoTenantUtils mki = null;
- CloudIdentity cloudIdentity=mock(CloudIdentity.class);
- Map <String, String> metadata=new HashMap<>();
- mtu.createTenant("name", "id", metadata, true);
- verify(mtu).createTenant("name", "id", metadata, true);
- mtu.queryTenant("tenantId", "cloudSiteId");
- verify(mtu).queryTenant("tenantId", "cloudSiteId");
- mtu.deleteTenant("tenantId", "cloudSiteId");
- verify(mtu).deleteTenant("tenantId", "cloudSiteId");
- mtu.getKeystoneUrl("regionId", "msoPropID", cloudIdentity);
- verify(mtu).getKeystoneUrl("regionId", "msoPropID", cloudIdentity);
- mtu.queryTenantByName("tenantName", "cloudSiteId");
- verify(mtu).queryTenantByName("tenantName", "cloudSiteId");
-
- }
-}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvtTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvtTest.java deleted file mode 100644 index 3dee177dee..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvtTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-
-package org.openecomp.mso.openstack.utils;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.powermock.api.mockito.PowerMockito;
-
-public class MsoYamlEditorWithEnvtTest {
-
- @Mock
- MsoHeatEnvironmentParameter mhep;
-
- @Mock
- HeatTemplateParam hep;
-
- @Test
- public void testgetParameterList() {
- Set<HeatTemplateParam> paramSet = new HashSet<>();
- paramSet.add(hep);
- mhep=PowerMockito.spy(new MsoHeatEnvironmentParameter());
- MsoYamlEditorWithEnvt Mso=mock(MsoYamlEditorWithEnvt.class);
- when(Mso.getParameterList()).thenReturn(paramSet);
- assert(Mso.getParameterList()!=null);
- }
-
- @Test
- public void testgetResourceLisstFromEnvt() {
- Set<MsoHeatEnvironmentParameter> paramSet = new HashSet<>();
- paramSet.add(mhep);
- new MsoHeatEnvironmentResource();;
- mhep=PowerMockito.spy(new MsoHeatEnvironmentParameter());
- MsoYamlEditorWithEnvt Mso=mock(MsoYamlEditorWithEnvt.class);
- when(Mso.getParameterListFromEnvt()).thenReturn(paramSet);
- }
-
- @Test
- public void getParameterListFromEnvt() {
- mhep=PowerMockito.spy(new MsoHeatEnvironmentParameter());
- Set<MsoHeatEnvironmentParameter> paramSet = new HashSet<>();
- paramSet.add(mhep);
- new MsoHeatEnvironmentResource();;
- MsoYamlEditorWithEnvt Mso=mock(MsoYamlEditorWithEnvt.class);
- when(Mso.getParameterListFromEnvt()).thenReturn(paramSet);
- }
-
-}
|