aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org/onap
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /adapters/mso-adapter-utils/src/test/java/org/onap
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (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/onap')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java46
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java148
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/TestApplication.java39
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/TestDataSetup.java40
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java59
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsTest.java140
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java134
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java107
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java100
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java58
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java46
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java106
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java76
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java39
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java35
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java38
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java36
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java231
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java50
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java65
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java42
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NetworkRollbackTest.java69
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java57
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java48
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/VnfRollbackTest.java90
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java207
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntryTest.java110
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java46
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java49
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java188
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java170
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java111
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java125
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvtTest.java95
34 files changed, 3000 insertions, 0 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
new file mode 100644
index 0000000000..36f82e15bd
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so;
+
+
+import com.github.tomakehurst.wiremock.client.WireMock;
+import org.junit.After;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@AutoConfigureWireMock(port = 0)
+public abstract class BaseTest extends TestDataSetup {
+
+ @Value("${wiremock.server.port}")
+ protected int wireMockPort;
+
+ @After
+ public void after() {
+ WireMock.reset();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java
new file mode 100644
index 0000000000..f5867befc0
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java
@@ -0,0 +1,148 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so;
+
+import org.apache.http.HttpStatus;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+public class StubOpenStack {
+
+ public static void mockOpenStackResponseAccess(int port) throws IOException {
+ stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl"))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackDelete(String id) {
+ stubFor(delete(urlMatching("/mockPublicUrl/stacks/" + id)).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+ }
+
+
+ public static void mockOpenStackPostStack_200(String filename) {
+ stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackPostTenantWithBodyFile_200() throws IOException {
+ stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
+ .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetTenantByName(String tenantName) throws IOException {
+ stubFor(get(urlMatching("/mockPublicUrl/tenants/[?]name=" + tenantName))
+ .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetTenantById(String tenantId) throws IOException {
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId"))
+ .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackDeleteTenantById_200(String tenantId) {
+ stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetUserById(String user) {
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetUserByName(String userName) {
+ stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetUserByName_500(String userName) {
+ stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+ }
+
+ public static void mockOpenStackGetRoles_200(String roleFor) {
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("OpenstackResponse_Roles.json").withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenstackPostNetwork(String responseFile) {
+ stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenstackPutNetwork(String responseFile, String networkId) {
+ stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetNeutronNetwork(String filename,String networkId) {
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
+ }
+
+ public static void mockOpenStackGetNeutronNetwork_500(String networkId) {
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ .willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+ }
+
+ public static void mockOpenStackDeleteNeutronNetwork(String networkId) {
+ stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
+ .willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
+ }
+
+ private static String readFile(String fileName) throws IOException {
+ try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ sb.append("\n");
+ line = br.readLine();
+ }
+ return sb.toString();
+ }
+ }
+
+ public static String getBodyFromFile(String fileName, int port, String urlPath) throws IOException {
+ return readFile("src/test/resources/__files/" + fileName).replaceAll("port", "http://localhost:" + port + urlPath);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestApplication.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestApplication.java
new file mode 100644
index 0000000000..479731c870
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestApplication.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.onap.so;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.Profile;
+
+@SpringBootApplication
+@Profile("test")
+@ComponentScan(basePackages = {"org.onap.so", "com.att"}, excludeFilters = {
+ @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+public class TestApplication {
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestDataSetup.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestDataSetup.java
new file mode 100644
index 0000000000..21c4c225ba
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/TestDataSetup.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class TestDataSetup {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ public static final String RESOURCE_PATH = "src/test/resources/__files/";
+ public ObjectMapper mapper;
+
+ @Before
+ public void testDataSetupBefore() {
+ mapper = new ObjectMapper();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
new file mode 100644
index 0000000000..539e7acef0
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.onap.so.adapter_utils.tests;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.cloud.Application;
+import org.onap.so.openstack.utils.MsoCommonUtils;
+import org.onap.so.openstack.utils.MsoHeatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * This class implements test methods of the MsoHeatUtils
+ *
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+@ActiveProfiles("test")
+public class MsoHeatUtilsRefactorTest extends MsoCommonUtils {
+
+ @Autowired
+ private MsoHeatUtils msoHeatUtils;
+
+ @Test
+ public final void testGetKeystoneUrl() {
+ try {
+ String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN");
+ assertEquals("http://192.168.170.21:5000/v2.0",keyUrl);
+ } catch (Exception e) {
+
+ }
+ }
+
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsTest.java
new file mode 100644
index 0000000000..c9a0a1d8c6
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsTest.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.onap.so.adapter_utils.tests;
+
+import java.util.HashMap;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.cloud.Application;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.exceptions.MsoIOException;
+import org.onap.so.openstack.exceptions.MsoStackAlreadyExists;
+import org.onap.so.openstack.exceptions.MsoTenantNotFound;
+import org.onap.so.openstack.utils.MsoCommonUtils;
+import org.onap.so.openstack.utils.MsoHeatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.woorea.openstack.heat.model.CreateStackParam;
+
+/**
+ * This class implements test methods of the MsoHeatUtils
+ *
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+@ActiveProfiles("test")
+@Ignore
+public class MsoHeatUtilsTest extends MsoCommonUtils {
+ @Autowired
+ private MsoHeatUtils msoHeatUtils;
+
+ @Test
+ public final void testCreateStackBadCloudConfig()
+ throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
+ try {
+ msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String, Object>(),
+ 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<String, Object>(), 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<String, Object>(), Boolean.TRUE,
+ 10);
+ } catch (MsoIOException e) {
+
+ }
+
+ }
+
+ @Test
+ public final void createStackSuccessWithEnvironment() throws MsoException {
+ try {
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
+ "environment");
+ } catch (MsoIOException e) {
+
+ }
+
+ }
+
+ @Test
+ public final void createStackSuccessWithFiles() throws MsoException {
+ try {
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
+ "environment", new HashMap<String, Object>());
+ } catch (MsoIOException e) {
+
+ }
+
+ }
+
+ @Test
+ public final void createStackSuccessWithHeatFiles() throws MsoException {
+ try {
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
+ "environment", new HashMap<String, Object>(), new HashMap<String, Object>());
+ } catch (MsoIOException e) {
+
+ }
+ }
+
+ @Test
+ public final void requestToStringBuilderTest() {
+ CreateStackParam param = new CreateStackParam();
+ param.setDisableRollback(false);
+ param.setEnvironment("environment");
+ param.setFiles(new HashMap<String, Object>());
+ param.setParameters(new HashMap<>());
+ param.setStackName("stackName");
+ param.setTemplate("template");
+ param.setTemplateUrl("http://templateUrl");
+ param.setTimeoutMinutes(1);
+
+ msoHeatUtils.requestToStringBuilder(param);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
new file mode 100644
index 0000000000..6d9687216d
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
@@ -0,0 +1,134 @@
+/*-
+ * ============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.onap.so.adapter_utils.tests;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+
+import java.security.GeneralSecurityException;
+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.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.cloud.CloudSite;
+import org.onap.so.cloud.ServerType;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.exceptions.MsoIOException;
+import org.onap.so.openstack.utils.MsoHeatUtilsWithUpdate;
+import org.onap.so.utils.CryptoUtils;
+
+import com.woorea.openstack.base.client.OpenStackConnectException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MsoHeatUtilsWithUpdateTest {
+
+
+ @Mock
+ private CloudConfig cloudConfig;
+ @InjectMocks
+ private MsoHeatUtilsWithUpdate util=new MsoHeatUtilsWithUpdate();
+
+ private CloudSite cloudSite;
+
+ @Before
+ public void init () {
+ cloudSite = new CloudSite ();
+ cloudSite.setRegionId("cloud");
+ CloudIdentity cloudIdentity = new CloudIdentity ();
+ cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
+ cloudIdentity.setIdentityUrl("toto");
+ cloudIdentity.setMsoPass (CryptoUtils.encryptCloudConfigPassword("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/onap/so/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java
new file mode 100644
index 0000000000..668b1806ac
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.onap.so.cloud;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.BaseTest;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * This class implements test methods of the CloudConfig features.
+ *
+ *
+ */
+public class CloudConfigTest extends BaseTest {
+
+ @Autowired
+ private CloudConfig con;
+
+ /**
+ * This method implements a test for the getCloudSites method.
+ */
+ @Test
+ public final void testGetCloudSites () {
+ Map<String,CloudSite> siteMap = con.getCloudSites();
+ assertNotNull(siteMap);
+
+ CloudSite site1 = siteMap.get("regionOne");
+
+ assertEquals ("regionOne", site1.getRegionId());
+ assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId());
+ assertEquals ("MT2", site1.getClli());
+ assertEquals ("2.5", site1.getAicVersion());
+ }
+
+
+ /**
+ * This method implements a test for the getIdentityServices method.
+ * @throws MsoException
+ */
+ @Test
+ public final void testGetIdentityServices () throws MsoException {
+ Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
+ assertNotNull(identityMap);
+
+ CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
+
+ assertEquals("john", identity1.getMsoId());
+ assertEquals("313DECE408AF7759D442D7B06DD9A6AA", identity1.getMsoPass());
+ assertEquals("admin", identity1.getAdminTenant());
+ assertEquals("_member_", identity1.getMemberRole());
+ assertEquals(false, identity1.hasTenantMetadata());
+ assertEquals("http://localhost:"+wireMockPort+"/v2.0", identity1.getIdentityUrl());
+ assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType());
+ assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType());
+
+ }
+
+ /**
+ * This method implements a test for the getCloudSite method.
+ */
+ @Test
+ public final void testGetDefaultCloudSite () {
+ Optional<CloudSite> site = con.getCloudSite("NotThere");
+ assertTrue(site.isPresent());
+ CloudSite site1 = site.get();
+ assertEquals ("NotThere", site1.getRegionId());
+ assertEquals("MTN6", site1.getClli());
+ assertEquals("NotThere", site1.getId());
+ assertEquals ("ORDM3", site1.getIdentityServiceId());
+ }
+
+ @Test
+ public void testGetIdentityService() {
+ CloudIdentity identity = con.getIdentityService("MT_KEYSTONE");
+ assertEquals("john", identity.getMsoId());
+ assertEquals("MT_KEYSTONE", identity.getId());
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java
new file mode 100644
index 0000000000..db2ba05bf1
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.onap.so.cloud;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.security.GeneralSecurityException;
+
+import org.junit.Test;
+import org.onap.so.utils.CryptoUtils;
+
+public class CloudIdentityTest {
+
+ private CloudIdentity cloudIdentity = new CloudIdentity();
+ private static final String ID = "testId";
+ private static final String IDENTITY_URL = "testIdentityUrl";
+ private static final String MSO_ID = "testMsoId";
+ private static final String MSO_PASS = "testMsoPassword";
+ private static final String ADMIN_TENANT = "testAdminTenant";
+ private static final String MEMBER_ROLE = "testMemberRole";
+ private static final Boolean TENANT_METADATA = true;
+
+ @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 (CryptoUtils.encryptCloudConfigPassword("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 (CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals ("password"));
+ assertTrue (id.hasTenantMetadata ());
+// assertTrue (id.toString ().contains ("keystone"));
+ assertTrue(id.toString().contains("null"));
+ }
+
+ @Test
+ public final void testEncryption () throws GeneralSecurityException {
+ String encrypted = CryptoUtils.encryptCloudConfigPassword("password");
+ assertTrue (encrypted != null);
+ assertTrue (!encrypted.equals ("password"));
+ }
+
+ @Test
+ public void cloneTest() {
+ cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT,
+ MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD);
+ CloudIdentity cloudIdentity2 = cloudIdentity.clone();
+
+ assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass());
+ }
+
+ private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl,
+ String msoId, String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata,
+ ServerType identityServerType, AuthenticationType identityAuthenticationType) {
+ obj.setId(id);
+ obj.setIdentityUrl(identityUrl);
+ obj.setMsoId(msoId);
+ obj.setMsoPass(msoPass);
+ obj.setAdminTenant(adminTenant);
+ obj.setMemberRole(memberRole);
+ obj.setTenantMetadata(tenantMetadata);
+ obj.setIdentityServerType(identityServerType);
+ obj.setIdentityAuthenticationType(identityAuthenticationType);
+
+ return obj;
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java
new file mode 100644
index 0000000000..89c15b0deb
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.cloud;
+
+import org.junit.Test;
+import org.onap.so.openpojo.rules.EqualsAndHashCodeTester;
+import org.onap.so.openpojo.rules.ToStringTester;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule;
+import com.openpojo.validation.rule.impl.NoPrimitivesRule;
+import com.openpojo.validation.rule.impl.NoPublicFieldsRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class CloudPojoTest {
+ @Test
+ public void pojoStructure() {
+ test(PojoClassFactory.getPojoClass(CloudIdentity.class));
+ test(PojoClassFactory.getPojoClass(CloudifyManager.class));
+ test(PojoClassFactory.getPojoClass(CloudSite.class));
+ test(PojoClassFactory.getPojoClass(CloudConfig.class));
+ }
+
+ private void test(PojoClass pojoClass) {
+ Validator validator = ValidatorBuilder.create()
+ .with(new EqualsAndHashCodeMatchRule())
+ .with(new NoPrimitivesRule())
+ .with(new NoPublicFieldsRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .with(new ToStringTester())
+ .with(new EqualsAndHashCodeTester())
+ .build();
+ validator.validate(pojoClass);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java
new file mode 100644
index 0000000000..9a660b4d40
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.cloud;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class CloudifyManagerTest {
+
+ private CloudifyManager cloudifyManager = new CloudifyManager();
+ private static final String ID = "testId";
+ private static final String CLOUDIFY_URL = "testCloudifyUrl";
+ private static final String USERNAME = "testUsername";
+ private static final String PASSWORD = "testPassword";
+ private static final String VERSION = "testVersion";
+
+ @Test
+ public void cloneTest() {
+ cloudifyManager.setId(ID);
+ cloudifyManager.setCloudifyUrl(CLOUDIFY_URL);
+ cloudifyManager.setUsername(USERNAME);
+ cloudifyManager.setPassword(PASSWORD);
+ cloudifyManager.setVersion(VERSION);
+
+ CloudifyManager clone = cloudifyManager.clone();
+ assertEquals(cloudifyManager, clone);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
new file mode 100644
index 0000000000..e1c533757b
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.onap.so.cloud.authentication;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.cloud.Application;
+import org.onap.so.cloud.AuthenticationType;
+import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+
+/**
+ * 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.
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+@ActiveProfiles("test")
+public class AuthenticationMethodTest {
+
+ @Autowired
+ private AuthenticationMethodFactory authenticationMethodFactory;
+ /**
+ *
+ */
+ public AuthenticationMethodTest() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Test
+ public void testCustomRackspaceAuth() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("test");
+
+ Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
+
+ }
+
+ @Test
+ public void testCoreUsernamePasswordAuth() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("someuser");
+
+ Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
+
+ }
+
+ @Test
+ public void testCustomRackspaceAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("test");
+
+ Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
+ }
+
+ @Test
+ public void testCoreUsernamePasswordAuthFromCloudIdentity() {
+ CloudIdentity ci = new CloudIdentity();
+ ci.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
+ ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
+ ci.setMsoId("someuser");
+
+ Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
+
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java
new file mode 100644
index 0000000000..e200f9aa96
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java
@@ -0,0 +1,76 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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.onap.so.cloudify.v3.model.Deployment;
+import org.onap.so.cloudify.v3.model.DeploymentOutputs;
+import org.onap.so.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/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java
new file mode 100644
index 0000000000..4bf087b7a4
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java
@@ -0,0 +1,39 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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/onap/so/cloudify/exceptions/MsoCloudifyTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java
new file mode 100644
index 0000000000..a1859e491a
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java
@@ -0,0 +1,35 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java
new file mode 100644
index 0000000000..21c625feb3
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java
@@ -0,0 +1,38 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.cloudify.exceptions;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.onap.so.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/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java
new file mode 100644
index 0000000000..68df574611
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java
@@ -0,0 +1,36 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
new file mode 100644
index 0000000000..e75a4aecaf
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
@@ -0,0 +1,231 @@
+/*-
+ * ============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.onap.so.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.onap.so.adapters.vdu.CloudInfo;
+import org.onap.so.adapters.vdu.PluginAction;
+import org.onap.so.adapters.vdu.VduArtifact;
+import org.onap.so.adapters.vdu.VduArtifact.ArtifactType;
+import org.onap.so.adapters.vdu.VduInstance;
+import org.onap.so.adapters.vdu.VduModelInfo;
+import org.onap.so.adapters.vdu.VduStateType;
+import org.onap.so.adapters.vdu.VduStatus;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.CloudIdentity;
+import org.onap.so.cloud.CloudSite;
+import org.onap.so.cloudify.beans.DeploymentInfo;
+import org.onap.so.cloudify.beans.DeploymentStatus;
+import org.onap.so.cloudify.v3.client.Cloudify;
+import org.onap.so.cloudify.v3.model.AzureConfig;
+import org.onap.so.cloudify.v3.model.OpenstackConfig;
+import org.onap.so.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 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/onap/so/config/PoConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java
new file mode 100644
index 0000000000..d347dedb4f
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============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.onap.so.config;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.cloud.Application;
+import org.onap.so.config.beans.PoConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+@ActiveProfiles("test")
+public class PoConfigTest {
+
+
+ @Autowired
+ private PoConfig poConfig;
+
+
+ @Test
+ public void tenantConfigValues() {
+ assertEquals("504", poConfig.getRetryCodes());
+ assertEquals(5, poConfig.getRetryDelay());
+
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java
new file mode 100644
index 0000000000..4adf6bf5be
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.beans;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.junit.Test;
+import org.onap.so.BaseTest;
+
+public class HeatCacheEntryTest extends BaseTest {
+
+ private static final String HEAT_URL = "testHeatUrl";
+ private static final String TOKEN = "testToken";
+
+ @Test
+ public void getHeatClientTest() {
+ Calendar expires = new GregorianCalendar(2013,0,31);
+ HeatCacheEntry heatCacheEntry = new HeatCacheEntry(HEAT_URL, TOKEN, expires);
+ assertNotNull(heatCacheEntry.getHeatClient());
+ }
+
+ @Test
+ public void isExpiredTrueTest() {
+ Calendar expires = new GregorianCalendar(2013,0,31);
+ HeatCacheEntry heatCacheEntry = new HeatCacheEntry(HEAT_URL, TOKEN, expires);
+ assertTrue(heatCacheEntry.isExpired());
+ }
+
+ @Test
+ public void isExpiredFalseTest() {
+ Calendar expires = new GregorianCalendar(2100,0,31);
+ HeatCacheEntry heatCacheEntry = new HeatCacheEntry(HEAT_URL, TOKEN, expires);
+ assertFalse(heatCacheEntry.isExpired());
+ }
+
+ @Test
+ public void isExpiredNullTest() {
+ Calendar expires = null;
+ HeatCacheEntry heatCacheEntry = new HeatCacheEntry(HEAT_URL, TOKEN, expires);
+ assertTrue(heatCacheEntry.isExpired());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java
new file mode 100644
index 0000000000..379501f206
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/MsoTenantTest.java
@@ -0,0 +1,42 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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/onap/so/openstack/beans/NetworkRollbackTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NetworkRollbackTest.java
new file mode 100644
index 0000000000..5a5e2bb75e
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NetworkRollbackTest.java
@@ -0,0 +1,69 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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.onap.so.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/onap/so/openstack/beans/NeutronCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java
new file mode 100644
index 0000000000..3a652042b7
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.beans;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.junit.Test;
+import org.onap.so.BaseTest;
+
+public class NeutronCacheEntryTest extends BaseTest {
+
+ private static final String NEUTRON_URL = "testNeutronUrl";
+ private static final String TOKEN = "testToken";
+
+ @Test
+ public void isExpiredTrueTest() {
+ Calendar expires = new GregorianCalendar(2013,0,31);
+ NeutronCacheEntry neutronCacheEntry = new NeutronCacheEntry(NEUTRON_URL, TOKEN, expires);
+ assertTrue(neutronCacheEntry.isExpired());
+ }
+
+ @Test
+ public void isExpiredFalseTest() {
+ Calendar expires = new GregorianCalendar(2100,0,31);
+ NeutronCacheEntry neutronCacheEntry = new NeutronCacheEntry(NEUTRON_URL, TOKEN, expires);
+ assertFalse(neutronCacheEntry.isExpired());
+ }
+
+ @Test
+ public void isExpiredNullTest() {
+ Calendar expires = null;
+ NeutronCacheEntry neutronCacheEntry = new NeutronCacheEntry(NEUTRON_URL, TOKEN, expires);
+ assertTrue(neutronCacheEntry.isExpired());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java
new file mode 100644
index 0000000000..522a261fdd
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.beans;
+
+import org.junit.Test;
+import org.onap.so.BaseTest;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class OpenstackBeansPojoTest extends BaseTest {
+ @Test
+ public void pojoStructure() {
+ test(PojoClassFactory.getPojoClass(VnfRollback.class));
+ test(PojoClassFactory.getPojoClass(NeutronCacheEntry.class));
+ test(PojoClassFactory.getPojoClass(HeatCacheEntry.class));
+ }
+
+ private void test(PojoClass pojoClass) {
+ Validator validator = ValidatorBuilder.create()
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+ validator.validate(pojoClass);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/VnfRollbackTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/VnfRollbackTest.java
new file mode 100644
index 0000000000..163f141c5d
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/VnfRollbackTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.beans;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.so.BaseTest;
+import org.onap.so.entity.MsoRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class VnfRollbackTest extends BaseTest {
+ @Autowired
+ private VnfRollback vnfRollback;
+
+ private String vnfId = "testVnfId";
+ private String tenantId = "testTenantId";
+ private String cloudSiteId = "testCloudSiteId";
+ private boolean tenantCreated = true;
+ private boolean vnfCreated = true;
+ private MsoRequest msoRequest = new MsoRequest();
+ private String volumeGroupName = "testVolumeGroupName";
+ private String volumeGroupId = "testVolumeGroupId";
+ private String requestType = "testRequestType";
+ private String modelCustomizationUuid = "testModelCustimizationUuid";
+ private String orchestrationMode = "testOrchestrationMode";
+ private static final String VNF_ROLLBACK_STRING = "VnfRollback: cloud=testCloudSiteId, tenant=testTenantId, vnf=testVnfId, "
+ + "tenantCreated=true, vnfCreated=true, requestType = testRequestType, modelCustomizationUuid=testModelCustimizationUuid, mode=testOrchestrationMode";
+
+ @Test
+ public void VnfRollbackInstantiationTest() {
+ vnfRollback = new VnfRollback(vnfId, tenantId, cloudSiteId, tenantCreated, vnfCreated,
+ msoRequest, volumeGroupName, volumeGroupId, requestType, modelCustomizationUuid);
+
+ assertEquals(vnfId, vnfRollback.getVnfId());
+ assertEquals(tenantId, vnfRollback.getTenantId());
+ assertEquals(cloudSiteId, vnfRollback.getCloudSiteId());
+ assertEquals(tenantCreated, vnfRollback.getTenantCreated());
+ assertEquals(vnfCreated, vnfRollback.getVnfCreated());
+ assertEquals(msoRequest, vnfRollback.getMsoRequest());
+ assertEquals(volumeGroupName, vnfRollback.getVolumeGroupName());
+ assertEquals(volumeGroupId, vnfRollback.getVolumeGroupId());
+ assertEquals(requestType, vnfRollback.getRequestType());
+ assertEquals(modelCustomizationUuid, vnfRollback.getModelCustomizationUuid());
+ }
+
+ @Test
+ public void VnfRollbackInstantiationOrchestrationModeTest() {
+ vnfRollback = new VnfRollback(vnfId, tenantId, cloudSiteId, tenantCreated, vnfCreated,
+ msoRequest, volumeGroupName, volumeGroupId, requestType, modelCustomizationUuid, orchestrationMode);
+
+ assertEquals(vnfId, vnfRollback.getVnfId());
+ assertEquals(tenantId, vnfRollback.getTenantId());
+ assertEquals(cloudSiteId, vnfRollback.getCloudSiteId());
+ assertEquals(tenantCreated, vnfRollback.getTenantCreated());
+ assertEquals(vnfCreated, vnfRollback.getVnfCreated());
+ assertEquals(msoRequest, vnfRollback.getMsoRequest());
+ assertEquals(volumeGroupName, vnfRollback.getVolumeGroupName());
+ assertEquals(volumeGroupId, vnfRollback.getVolumeGroupId());
+ assertEquals(requestType, vnfRollback.getRequestType());
+ assertEquals(modelCustomizationUuid, vnfRollback.getModelCustomizationUuid());
+ assertEquals(orchestrationMode, vnfRollback.getMode());
+ }
+
+ @Test
+ public void toStringTest() {
+ vnfRollback = new VnfRollback(vnfId, tenantId, cloudSiteId, tenantCreated, vnfCreated,
+ msoRequest, volumeGroupName, volumeGroupId, requestType, modelCustomizationUuid, orchestrationMode);
+
+ assertEquals(VNF_ROLLBACK_STRING, vnfRollback.toString());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
new file mode 100644
index 0000000000..7ac92574a0
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
@@ -0,0 +1,207 @@
+/*-
+ * ============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.onap.so.openstack.utils;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.so.BaseTest;
+import org.onap.so.openstack.exceptions.MsoAdapterException;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.exceptions.MsoExceptionCategory;
+import org.onap.so.openstack.exceptions.MsoIOException;
+import org.onap.so.openstack.exceptions.MsoOpenstackException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+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.OpenStackResponse;
+import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.heat.model.Explanation;
+import com.woorea.openstack.keystone.model.Error;
+import com.woorea.openstack.quantum.model.NeutronError;
+
+/**
+ * This class implements test methods of the MsoCommonUtils
+ */
+public class MsoCommonUtilsTest extends BaseTest {
+ @Autowired
+ @Qualifier("CommonUtils")
+ private MsoCommonUtils commonUtils;
+
+ @Mock
+ private OpenStackRequest openstackRequest;
+
+ @Test
+ public final void testExecuteAndRecordOpenstackRequest() {
+ Mockito.when(openstackRequest.endpoint()).thenReturn("localhost");
+ Mockito.when(openstackRequest.path()).thenReturn("/test");
+ //TODO:Must try a real connection
+ assertNull(commonUtils.executeAndRecordOpenstackRequest (openstackRequest));
+ }
+
+ @Test
+ public void testexecuteAndRecordOpenstackRequestResponseException() {
+ expectedException.expect(OpenStackResponseException.class);
+
+ doThrow(OpenStackResponseException.class).when(openstackRequest).execute();
+
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ }
+
+ @Test
+ public void testexecuteAndRecordOpenstackRequestConnectException() {
+ expectedException.expect(OpenStackConnectException.class);
+
+ doThrow(OpenStackConnectException.class).when(openstackRequest).execute();
+
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ }
+
+ @Test
+ public final void testKeystoneErrorToMsoException() throws JsonParseException, JsonMappingException, IOException {
+ OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect");
+
+ OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1);
+
+ MsoException me = commonUtils.keystoneErrorToMsoException(openStackConnectException,"ContextError");
+
+ assertTrue(me instanceof MsoIOException);
+ assertTrue("connect".equals(me.getMessage()));
+
+
+ MsoException me2 = commonUtils.keystoneErrorToMsoException(openStackResponseException,"ContextError");
+ assertTrue(me2 instanceof MsoOpenstackException);
+ assertTrue("ContextError".equals(me2.getContext()));
+ assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+
+
+ OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
+ Error error = mapper.readValue(new File(RESOURCE_PATH + "Error.json"), Error.class);
+
+ doReturn(error).when(openStackResponse).getErrorEntity(eq(Error.class));
+
+ openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
+
+ MsoException me3 = commonUtils.keystoneErrorToMsoException(openStackResponseException,"ContextError");
+
+ assertTrue(me3 instanceof MsoOpenstackException);
+ assertEquals("1 title: message", me3.toString());
+ }
+
+ @Test
+ public final void testHeatExceptionToMsoException() throws JsonParseException, JsonMappingException, IOException {
+ OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect");
+
+ OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1);
+
+ MsoException me = commonUtils.heatExceptionToMsoException(openStackConnectException,"ContextError");
+
+ assertTrue(me instanceof MsoIOException);
+ assertTrue("connect".equals(me.getMessage()));
+
+
+ MsoException me2 = commonUtils.heatExceptionToMsoException(openStackResponseException,"ContextError");
+ assertTrue(me2 instanceof MsoOpenstackException);
+ assertTrue("ContextError".equals(me2.getContext()));
+ assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+
+
+ OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
+ Explanation explanation = mapper.readValue(new File(RESOURCE_PATH + "Explanation.json"), Explanation.class);
+
+ doReturn(explanation).when(openStackResponse).getErrorEntity(eq(Explanation.class));
+
+ openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
+
+ MsoException me3 = commonUtils.heatExceptionToMsoException(openStackResponseException,"ContextError");
+
+ assertTrue(me3 instanceof MsoOpenstackException);
+ assertEquals("1 title: explanation, error.type=null, error.message=null", me3.toString());
+ }
+
+ @Test
+ public final void testNeutronExceptionToMsoException() throws JsonParseException, JsonMappingException, IOException {
+ OpenStackBaseException openStackConnectException = new OpenStackConnectException("connect");
+
+ OpenStackBaseException openStackResponseException = new OpenStackResponseException("response",1);
+
+ MsoException me = commonUtils.neutronExceptionToMsoException(openStackConnectException,"ContextError");
+
+ assertTrue(me instanceof MsoIOException);
+ assertTrue("connect".equals(me.getMessage()));
+
+ MsoException me2 = commonUtils.neutronExceptionToMsoException(openStackResponseException,"ContextError");
+ assertTrue(me2 instanceof MsoOpenstackException);
+ assertTrue("ContextError".equals(me2.getContext()));
+ assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+
+
+ OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
+ NeutronError explanation = mapper.readValue(new File(RESOURCE_PATH + "NeutronError.json"), NeutronError.class);
+
+ doReturn(explanation).when(openStackResponse).getErrorEntity(eq(NeutronError.class));
+
+ openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
+
+ MsoException me3 = commonUtils.neutronExceptionToMsoException(openStackResponseException,"ContextError");
+
+ assertTrue(me3 instanceof MsoOpenstackException);
+ assertEquals("501 type: message", me3.toString());
+ }
+
+ @Test
+ public final void testRuntimeExceptionToMsoException() {
+ RuntimeException re = new RuntimeException("runtime");
+ MsoException me = commonUtils.runtimeExceptionToMsoException(re, "ContextError");
+
+ assertTrue(me instanceof MsoAdapterException);
+ assertTrue("ContextError".equals(me.getContext()));
+ assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory()));
+ }
+
+ @Test
+ public void testIoExceptionToMsoException() {
+ IOException exception = new IOException("IOExceptionTestMessage");
+
+ MsoException msoException = commonUtils.ioExceptionToMsoException(exception, "ContextError");
+
+ assertTrue(msoException instanceof MsoAdapterException);
+ assertEquals("ContextError", msoException.getContext());
+ assertTrue(MsoExceptionCategory.INTERNAL.equals(msoException.getCategory()));
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntryTest.java
new file mode 100644
index 0000000000..700d03dad3
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntryTest.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.onap.so.openstack.utils;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.junit.Test;
+import org.onap.so.TestDataSetup;
+import org.onap.so.db.catalog.beans.HeatTemplateParam;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public class MsoHeatEnvironmentEntryTest extends TestDataSetup {
+
+ 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() throws JsonParseException, JsonMappingException, IOException {
+ StringBuilder sb = new StringBuilder(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY);
+
+ MsoHeatEnvironmentEntry testedObject = new MsoHeatEnvironmentEntry(sb);
+
+ HeatTemplateParam heatTemplateParam = mapper.readValue(new File(RESOURCE_PATH + "HeatTemplateParam.json"), HeatTemplateParam.class);
+
+ assertThat(testedObject.getRawEntry()).isEqualTo(sb);
+ assertThat(testedObject.isValid()).isTrue();
+ assertThat(testedObject.containsParameter(PARAMETER_NAME)).isTrue();
+ assertThat(testedObject.toString()).doesNotContain(RAW_ENTRY_WITH_RESOURCE_REGISTRY);
+ assertTrue(testedObject.containsParameter(PARAMETER_NAME, "dummyAlias"));
+ assertTrue(testedObject.containsParameter("dummyName", PARAMETER_NAME));
+ assertFalse(testedObject.containsParameter("dummyName", "dummyAlias"));
+ assertEquals("parameters:\n " + PARAMETER_NAME + ": " + VALUE_NAME + "\n\n\n", testedObject.toFullString().toString());
+ assertEquals("parameters:\n " + PARAMETER_NAME + ": " + VALUE_NAME + "\n\n\n", testedObject.toFullStringExcludeNonParams(new HashSet<HeatTemplateParam>(Arrays.asList(heatTemplateParam))).toString());
+ assertEquals(1, testedObject.getNumberOfParameters());
+ assertFalse(testedObject.hasResources());
+
+ MsoHeatEnvironmentResource heatResource = new MsoHeatEnvironmentResource("resourceName", "resourceValue");
+ MsoHeatEnvironmentParameter heatParameter = new MsoHeatEnvironmentParameter("parameterName", "parameterValue");
+ testedObject.addResource(heatResource);
+ testedObject.addParameter(heatParameter);
+ assertEquals(1, testedObject.getNumberOfResources());
+ assertEquals(2, testedObject.getNumberOfParameters());
+
+ testedObject.setResources(null);
+ testedObject.setParameters(null);
+ assertNull(testedObject.getParameters());
+ assertNull(testedObject.getResources());
+ }
+
+ @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/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java
new file mode 100644
index 0000000000..182a6d0e02
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentParameterTest.java
@@ -0,0 +1,46 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.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/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java
new file mode 100644
index 0000000000..934c149055
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatEnvironmentResourceTest.java
@@ -0,0 +1,49 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.openstack.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class MsoHeatEnvironmentResourceTest {
+ @Test
+ public void test() {
+ Object op = true;
+
+ MsoHeatEnvironmentResource mre = new MsoHeatEnvironmentResource("name");
+ MsoHeatEnvironmentResource mae = new MsoHeatEnvironmentResource("name", "maeValue");
+ MsoHeatEnvironmentResource msoHER = new MsoHeatEnvironmentResource();
+
+ msoHER.setName("msoHERName");
+ msoHER.setValue("msoHERValue");
+
+ assertEquals("name", mre.getName());
+ assertEquals("maeValue", mae.getValue());
+ assertEquals("\"msoHERName\": msoHERValue", msoHER.toString());
+ assertEquals("\"name\": maeValue", mae.toString());
+ assertFalse(mae.equals(op));
+ assertTrue(mae.equals(mre));
+ assertEquals("name".hashCode(), mae.hashCode());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
new file mode 100644
index 0000000000..6bcb209125
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -0,0 +1,188 @@
+/*-
+ * ============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.onap.so.openstack.utils;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.woorea.openstack.heat.model.CreateStackParam;
+import org.apache.http.HttpStatus;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.so.BaseTest;
+import org.onap.so.StubOpenStack;
+import org.onap.so.adapters.vdu.CloudInfo;
+import org.onap.so.adapters.vdu.PluginAction;
+import org.onap.so.adapters.vdu.VduArtifact;
+import org.onap.so.adapters.vdu.VduArtifact.ArtifactType;
+import org.onap.so.adapters.vdu.VduInstance;
+import org.onap.so.adapters.vdu.VduModelInfo;
+import org.onap.so.adapters.vdu.VduStateType;
+import org.onap.so.adapters.vdu.VduStatus;
+import org.onap.so.openstack.exceptions.MsoException;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class MsoHeatUtilsTest extends BaseTest{
+
+ @Autowired
+ private MsoHeatUtils heatUtils;
+
+ @Test
+ public void instantiateVduTest() throws MsoException, IOException {
+ VduInstance expected = new VduInstance();
+ expected.setVduInstanceId("name/da886914-efb2-4917-b335-c8381528d90b");
+ expected.setVduInstanceName("name");
+ VduStatus status = new VduStatus();
+ status.setState(VduStateType.INSTANTIATED);
+ status.setLastAction((new PluginAction("create", "complete", null)));
+ expected.setStatus(status);
+
+ CloudInfo cloudInfo = new CloudInfo();
+ cloudInfo.setCloudSiteId("regionOne");
+ 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;
+
+ StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json");
+
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceName/stackId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("OpenstackResponse_StackId.json")
+ .withStatus(HttpStatus.SC_OK)));
+
+ VduInstance actual = heatUtils.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+
+ @Test
+ public void queryVduTest() throws Exception {
+ VduInstance expected = new VduInstance();
+ expected.setVduInstanceId("name/da886914-efb2-4917-b335-c8381528d90b");
+ expected.setVduInstanceName("name");
+ VduStatus status = new VduStatus();
+ status.setState(VduStateType.INSTANTIATED);
+ status.setLastAction((new PluginAction("create", "complete",null)));
+ expected.setStatus(status);
+
+ CloudInfo cloudInfo = new CloudInfo();
+ cloudInfo.setCloudSiteId("regionOne");
+ cloudInfo.setTenantId("tenantId");
+ String instanceId = "instanceId";
+
+ StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json");
+
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("OpenstackResponse_StackId.json")
+ .withStatus(HttpStatus.SC_OK)));
+
+ VduInstance actual = heatUtils.queryVdu(cloudInfo, instanceId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void deleteVduTest() throws Exception {
+ VduInstance expected = new VduInstance();
+ expected.setVduInstanceId("instanceId");
+ expected.setVduInstanceName("instanceId");
+ VduStatus status = new VduStatus();
+ status.setState(VduStateType.DELETED);
+ expected.setStatus(status);
+
+ CloudInfo cloudInfo = new CloudInfo();
+ cloudInfo.setCloudSiteId("regionOne");
+ cloudInfo.setTenantId("tenantId");
+ String instanceId = "instanceId";
+
+ int timeoutInMinutes = 1;
+
+ StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
+ StubOpenStack.mockOpenStackDelete("name/da886914-efb2-4917-b335-c8381528d90b");
+ stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK)));
+
+ VduInstance actual = heatUtils.deleteVdu(cloudInfo, instanceId, timeoutInMinutes);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public final void requestToStringBuilderTest() {
+ CreateStackParam param = new CreateStackParam();
+ param.setDisableRollback(false);
+ param.setEnvironment("environment");
+ param.setFiles(new HashMap<String, Object>());
+ param.setParameters(new HashMap<>());
+ param.setStackName("stackName");
+ param.setTemplate("template");
+ param.setTemplateUrl("http://templateUrl");
+ param.setTimeoutMinutes(1);
+
+ StringBuilder stringBuilder = heatUtils.requestToStringBuilder(param);
+
+ Assert.assertTrue(stringBuilder.toString().contains("StackName:"));
+ }
+
+ @Test
+ public final void copyBaseOutputsToInputsTest() {
+ Map<String, Object> inputs = new HashMap<>();
+ inputs.put("str1", "str");
+ Map<String, Object> otherStackOutputs = new HashMap<>();
+ otherStackOutputs.put("str", "str");
+ List<String> paramNames = new ArrayList<>();
+ Map<String, String> aliases = new HashMap<>();
+ aliases.put("str", "str");
+ heatUtils.copyBaseOutputsToInputs(inputs, otherStackOutputs, null, aliases);
+ Assert.assertEquals("str",otherStackOutputs.get("str"));
+ }
+
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
new file mode 100644
index 0000000000..c252f61e7f
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.utils;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.TestDataSetup;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.CloudSite;
+import org.onap.so.openstack.beans.HeatStatus;
+import org.onap.so.openstack.beans.StackInfo;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.core.env.Environment;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.heat.Heat;
+import com.woorea.openstack.heat.StackResource;
+import com.woorea.openstack.heat.StackResource.UpdateStack;
+import com.woorea.openstack.heat.model.Stack;
+import com.woorea.openstack.heat.model.UpdateStackParam;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MsoHeatUtilsWithUpdateTest extends TestDataSetup {
+ @Mock
+ private CloudConfig cloudConfig;
+
+ @Mock
+ private Environment environment;
+
+ @Spy
+ @InjectMocks
+ private MsoHeatUtilsWithUpdate heatUtils;
+
+ private String cloudSiteId;
+ private String tenantId;
+ private String stackName;
+ private String heatTemplate;
+ private Map<String, Object> stackInputs;
+ private boolean pollForCompletion;
+ private int timeoutMinutes;
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+
+ cloudSiteId = "cloudSiteId";
+ tenantId = "tenantId";
+ stackName = "stackName";
+ heatTemplate = "heatTemplate";
+ stackInputs = new HashMap<>();
+ pollForCompletion = true;
+ timeoutMinutes = 0;
+ }
+
+ @Test
+ public void updateStackTest() throws MsoException, JsonParseException, JsonMappingException, IOException {
+ CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ Heat heatClient = new Heat("endpoint");
+ Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
+ Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
+
+ StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
+ expectedStackInfo.setCanonicalName("stackName/id");
+
+ doReturn(Optional.of(cloudSite)).when(cloudConfig).getCloudSite(isA(String.class));
+ doReturn(heatClient).when(heatUtils).getHeatClient(isA(CloudSite.class), isA(String.class));
+ doReturn(heatStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+ doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
+ doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
+ doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+
+ StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, tenantId, stackName,
+ heatTemplate, stackInputs, pollForCompletion, timeoutMinutes);
+
+ assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
+ }
+
+ @Test
+ public void updateStackWithEnvironmentTest() throws JsonParseException, JsonMappingException, IOException, MsoException {
+ String environmentString = "environmentString";
+
+ CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ Heat heatClient = new Heat("endpoint");
+ Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
+ Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
+
+ StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
+ expectedStackInfo.setCanonicalName("stackName/id");
+
+ doReturn(Optional.of(cloudSite)).when(cloudConfig).getCloudSite(isA(String.class));
+ doReturn(heatClient).when(heatUtils).getHeatClient(isA(CloudSite.class), isA(String.class));
+ doReturn(heatStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+ doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
+ doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
+ doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+
+ StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, tenantId, stackName,
+ heatTemplate, stackInputs, pollForCompletion, timeoutMinutes, environmentString);
+
+ assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
+ }
+
+ @Test
+ public void updateStackWithFilesTest() throws MsoException, JsonParseException, JsonMappingException, IOException {
+ String environmentString = "environmentString";
+ Map<String, Object> files = new HashMap<>();
+ files.put("file1", new Object());
+
+ CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class);
+ Heat heatClient = new Heat("endpoint");
+ Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
+ Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
+
+ StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
+ expectedStackInfo.setCanonicalName("stackName/id");
+
+ doReturn(Optional.of(cloudSite)).when(cloudConfig).getCloudSite(isA(String.class));
+ doReturn(heatClient).when(heatUtils).getHeatClient(isA(CloudSite.class), isA(String.class));
+ doReturn(heatStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+ doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
+ doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
+ doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
+
+ StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, tenantId, stackName,
+ heatTemplate, stackInputs, pollForCompletion, timeoutMinutes , environmentString, files);
+
+ assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
new file mode 100644
index 0000000000..706427e985
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.utils;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.BaseTest;
+import org.onap.so.StubOpenStack;
+import org.onap.so.openstack.beans.MsoTenant;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+public class MsoKeystoneUtilsTest extends BaseTest {
+
+ @Autowired
+ private MsoKeystoneUtils msoKeystoneUtils;
+
+ @Before
+ public void before() throws IOException {
+ StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ }
+
+ @Test
+ public void createTenantTest() throws Exception {
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
+
+ StubOpenStack.mockOpenStackGetUserById("john");
+ StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+
+ Assert.assertEquals("tenantId", response);
+ }
+
+ @Test
+ public void createTenantTest_FindUserByName() throws Exception {
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
+
+ StubOpenStack.mockOpenStackGetUserByName("john");
+ StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+ Assert.assertEquals("tenantId", response);
+
+ }
+
+ @Test
+ public void createTenantTest_Exception() throws Exception {
+ expectedException.expect(MsoException.class);
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
+ StubOpenStack.mockOpenStackGetUserByName_500("john");
+ StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true);
+ }
+
+ @Test
+ public void queryTenantTest() throws Exception {
+ StubOpenStack.mockOpenStackGetTenantById("tenantId");
+
+ MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "regionOne");
+
+ Assert.assertEquals("testingTenantName", msoTenant.getTenantName());
+ }
+
+ @Test
+ public void queryTenantByNameTest() throws Exception {
+ StubOpenStack.mockOpenStackGetTenantByName("tenant");
+
+ MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "regionOne");
+
+ Assert.assertEquals("testingTenantName", msoTenant.getTenantName());
+ }
+
+ @Test
+ public void deleteTenantTest() throws Exception {
+ StubOpenStack.mockOpenStackGetTenantById("tenantId");
+ StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
+ boolean result = msoKeystoneUtils.deleteTenant("tenantId", "regionOne");
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void deleteTenantByNameTest() throws Exception {
+ StubOpenStack.mockOpenStackGetTenantByName("tenant");
+ StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
+ boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "regionOne");
+
+ Assert.assertTrue(result);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
new file mode 100644
index 0000000000..9f8b51a3b7
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 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.onap.so.openstack.utils;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.BaseTest;
+import org.onap.so.StubOpenStack;
+import org.onap.so.openstack.beans.NetworkInfo;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MsoNeutronUtilsTest extends BaseTest{
+
+ @Autowired
+ private MsoNeutronUtils msoNeutronUtils;
+
+ private List<Integer> vlans;
+
+ @Before
+ public void before() throws IOException {
+ vlans = new ArrayList<>();
+ vlans.add(3014);
+ StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ }
+
+ @Test
+ public void createNetworkTest_OpenStackBaseException() throws Exception {
+ expectedException.expect(MsoException.class);
+ msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ MsoNeutronUtils.NetworkType.PROVIDER,"networkName", "PROVIDER", vlans);
+ }
+
+ @Test
+ public void createNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
+ StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
+ NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"networkName","PROVIDER", vlans);
+
+ Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
+ }
+
+ @Test
+ public void createNetworkTest() throws Exception {
+ StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
+ NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId",
+ MsoNeutronUtils.NetworkType.PROVIDER,"networkName","PROVIDER", vlans);
+
+ Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
+ }
+
+ @Test
+ public void queryNetworkTest() throws Exception {
+ StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+
+ Assert.assertEquals("net1",networkInfo.getName());
+ }
+
+ @Test
+ public void queryNetworkTest_404() throws Exception {
+ NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+ Assert.assertNull(networkInfo);
+ }
+
+ @Test
+ public void queryNetworkTest_500() throws Exception {
+ expectedException.expect(MsoException.class);
+ StubOpenStack.mockOpenStackGetNeutronNetwork_500("43173f6a-d699-414b-888f-ab243dda6dfe");
+ msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+
+ }
+
+ @Test
+ public void deleteNetworkkTest() throws Exception {
+ StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackDeleteNeutronNetwork("43173f6a-d699-414b-888f-ab243dda6dfe");
+ Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne");
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void updateNetworkTest() throws Exception {
+ StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId",
+ "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.PROVIDER,"PROVIDER", vlans);
+
+ Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
+ }
+
+ @Test
+ public void updateNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
+ StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId",
+ "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"PROVIDER", vlans);
+
+ Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId());
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvtTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvtTest.java
new file mode 100644
index 0000000000..70b5f2699d
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvtTest.java
@@ -0,0 +1,95 @@
+/*
+* ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 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.onap.so.openstack.utils;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Set;
+
+import org.junit.Test;
+import org.onap.so.TestDataSetup;
+import org.onap.so.db.catalog.beans.HeatTemplateParam;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public class MsoYamlEditorWithEnvtTest extends TestDataSetup {
+ private MsoYamlEditorWithEnvt yaml;
+ private static final String PARAMETER_NAME = "keyTest";
+ private static final String PARAMETER_VALUE = "{type : paramType}";
+ private static final String RESOURCE_NAME = "resourceKey";
+ private static final String RESOURCE_VALUE = "resourceValue";
+ private static final String RAW_ENTRY_WITH_RESOURCE_REGISTRY = "resource_registry: {" + RESOURCE_NAME + " : " + RESOURCE_VALUE + "}";
+ private static final String RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY = "parameters: {"
+ + PARAMETER_NAME + ": " + PARAMETER_VALUE + "}";
+
+ @Test
+ public void getParameterListTest() throws JsonParseException, JsonMappingException, IOException {
+ yaml = new MsoYamlEditorWithEnvt(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY.getBytes());
+
+ MsoHeatEnvironmentParameter expectedHeatParam = mapper.readValue(new File(RESOURCE_PATH + "HeatEnvironmentParameter.json"), MsoHeatEnvironmentParameter.class);
+
+ Set<MsoHeatEnvironmentParameter> heatEnvironmentSet = yaml.getParameterListFromEnvt();
+
+ for(MsoHeatEnvironmentParameter heatEnvironment : heatEnvironmentSet) {
+ assertThat(heatEnvironment, sameBeanAs(expectedHeatParam));
+ }
+ }
+
+ @Test
+ public void getResourceListFromEnvtTest() {
+ yaml = new MsoYamlEditorWithEnvt(RAW_ENTRY_WITH_RESOURCE_REGISTRY.getBytes());
+
+ MsoHeatEnvironmentResource expectedHeatResource = new MsoHeatEnvironmentResource(RESOURCE_NAME, RESOURCE_VALUE);
+
+ Set<MsoHeatEnvironmentResource> heatResourceSet = yaml.getResourceListFromEnvt();
+
+ for(MsoHeatEnvironmentResource heatResource : heatResourceSet) {
+ assertThat(heatResource, sameBeanAs(expectedHeatResource));
+ }
+ }
+
+ @Test
+ public void getResourceListFromEnvtExceptionTest() {
+ yaml = new MsoYamlEditorWithEnvt();
+
+ Set<MsoHeatEnvironmentResource> heatResourceSet = yaml.getResourceListFromEnvt();
+
+ assertNull(heatResourceSet);
+ }
+
+ @Test
+ public void getParameterListFromEnvtTest() throws JsonParseException, JsonMappingException, IOException {
+ yaml = new MsoYamlEditorWithEnvt(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY.getBytes());
+
+ HeatTemplateParam expectedHeatParam = mapper.readValue(new File(RESOURCE_PATH + "HeatTemplateParamExpected.json"), HeatTemplateParam.class);
+
+ Set<HeatTemplateParam> heatParamSet = yaml.getParameterList();
+
+ for(HeatTemplateParam heatParam : heatParamSet) {
+ assertThat(heatParam, sameBeanAs(expectedHeatParam));
+ }
+ }
+}