aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java92
-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.java133
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java12
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/application-test.yaml2
7 files changed, 10 insertions, 377 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index d44857ce72..e36d0ff30e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -119,9 +119,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoHeatUtils.class);
// Properties names and variables (with default values)
- protected String createPollIntervalProp = "ecomp.mso.adapters.po.pollInterval";
- private String deletePollIntervalProp = "ecomp.mso.adapters.po.pollInterval";
- private String deletePollTimeoutProp = "ecomp.mso.adapters.po.pollTimeout";
+ protected String createPollIntervalProp = "onap.so.adapters.po.pollInterval";
+ private String deletePollIntervalProp = "onap.so.adapters.po.pollInterval";
+ private String deletePollTimeoutProp = "onap.so.adapters.po.pollTimeout";
protected static final String createPollIntervalDefault = "15";
private static final String deletePollIntervalDefault = "15";
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
index d688960a1c..c1705508ce 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -24,7 +24,7 @@ import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
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
deleted file mode 100644
index c3777ca810..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapter_utils.tests;
-
-
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.so.BaseTest;
-import org.onap.so.db.catalog.beans.AuthenticationType;
-import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.db.catalog.beans.ServerType;
-import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-
-/**PoConfigTest
- * This class implements test methods of the MsoHeatUtils
- *
- *
- */
-public class MsoHeatUtilsRefactorTest extends BaseTest {
-
- @Autowired
- private MsoHeatUtils msoHeatUtils;
-
- @Before
- public void init() throws IOException {
- CloudIdentity identity = new CloudIdentity();
-
- identity.setId("MTN13");
- identity.setMsoId("m93945");
- identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
- identity.setAdminTenant("admin");
- identity.setMemberRole("admin");
- identity.setTenantMetadata(true);
- identity.setIdentityUrl("http://localhost:28090/v2.0");
- identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
-
- CloudSite cloudSite = new CloudSite();
- cloudSite.setId("MTN13");
- cloudSite.setCloudVersion("3.0");
- cloudSite.setClli("MDT13");
- cloudSite.setRegionId("MTN13");
- identity.setIdentityServerType(ServerType.KEYSTONE);
- cloudSite.setIdentityService(identity);
-
-
- stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
- .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
- .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
- .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
- .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_OK)));
- }
-
- @Test
- public final void testGetKeystoneUrl() throws MsoCloudSiteNotFound {
- String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN");
- assertEquals("http://localhost:28090/v2.0", keyUrl);
- }
-}
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
deleted file mode 100644
index abb0a10af5..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.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.TestApplication;
-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 = TestApplication.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
deleted file mode 100644
index 50fc17511b..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapter_utils.tests;
-
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.when;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.db.catalog.beans.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/openstack/utils/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java
index 1a8f4fb098..b735e735c9 100644
--- 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
@@ -22,8 +22,8 @@ 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.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
@@ -40,7 +40,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.TestDataSetup;
import org.onap.so.cloud.CloudConfig;
import org.onap.so.db.catalog.beans.CloudSite;
@@ -100,7 +100,6 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup {
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));
@@ -125,7 +124,7 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup {
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));
@@ -151,8 +150,7 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup {
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(heatClient).when(heatUtils).getHeatClient(isA(CloudSite.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));
diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
index f9467d3c12..011bb1416b 100644
--- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
+++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml
@@ -61,7 +61,7 @@ mso:
queue-capacity: 500
spring:
datasource:
- url: jdbc:mariadb://localhost:3307/catalogdb
+ jdbc-url: jdbc:mariadb://localhost:3307/catalogdb
username: root
password: password
driver-class-name: org.mariadb.jdbc.Driver