diff options
Diffstat (limited to 'adapters/mso-adapter-utils')
6 files changed, 72 insertions, 21 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 14e5b80d2e..4479a7f6c2 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -121,8 +121,8 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoCloudifyUtils.class); // Properties names and variables (with default values) - protected String createPollIntervalProp = "ecomp.mso.adapters.po.pollInterval"; - private String deletePollIntervalProp = "ecomp.mso.adapters.po.pollInterval"; + protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; + private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval"; protected String createPollIntervalDefault = "15"; private String deletePollIntervalDefault = "15"; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/config/beans/PoConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/config/beans/PoConfig.java index 3098a5410a..9995a23668 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/config/beans/PoConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/config/beans/PoConfig.java @@ -24,12 +24,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @Configuration -@ConfigurationProperties(prefix="adapters.po") +@ConfigurationProperties(prefix="org.onap.so.adapters.po") public class PoConfig { private String retryCodes; private int retryDelay; private int retryCount; + private int pollTimeout; + private int pollInterval; public String getRetryCodes() { return retryCodes; @@ -49,5 +51,17 @@ public class PoConfig { public void setRetryCount(int retryCount) { this.retryCount = retryCount; } + public int getPollTimeout() { + return pollTimeout; + } + public void setPollTimeout(int pollTimeout) { + this.pollTimeout = pollTimeout; + } + public int getPollInterval() { + return pollInterval; + } + public void setPollInterval(int pollInterval) { + this.pollInterval = pollInterval; + } } 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 1f9b6bd910..f132f10ebb 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 @@ -127,9 +127,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 = "onap.so.adapters.po.pollInterval"; - private String deletePollIntervalProp = "onap.so.adapters.po.pollInterval"; - private String deletePollTimeoutProp = "onap.so.adapters.po.pollTimeout"; + protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; + private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval"; + private String deletePollTimeoutProp = "org.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/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 829f6c1445..c9b70610d1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -21,16 +21,17 @@ package org.onap.so.openstack.utils; import java.net.MalformedURLException; +import java.net.URL; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; -import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; import javax.ws.rs.core.Response; +import org.onap.so.client.HttpClientFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.so.adapters.vdu.CloudInfo; @@ -48,7 +49,6 @@ import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.client.HttpClient; import org.onap.so.client.RestClient; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.logger.MessageEnum; @@ -56,13 +56,8 @@ import org.onap.so.logger.MsoLogger; import org.onap.so.utils.TargetEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.heat.model.CreateStackParam; @@ -80,11 +75,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class); private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Autowired private Environment environment; - /****************************************************************************** * * Methods (and associated utilities) to implement the VduPlugin interface @@ -603,8 +598,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ private RestClient getMulticloudClient(String endpoint) { RestClient client = null; try { - client = new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(), - MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD); + client = httpClientFactory.newJsonClient( + new URL(endpoint), + TargetEntity.MULTICLOUD); } catch (MalformedURLException e) { logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage())); } catch (IllegalArgumentException e) { diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java new file mode 100644 index 0000000000..fa4c6bfe6f --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java @@ -0,0 +1,38 @@ +package org.onap.so.openstack.utils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowableOfType; +import static org.mockito.BDDMockito.given; + +import java.util.Optional; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.cloud.CloudConfig; +import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; + +@RunWith(MockitoJUnitRunner.class) +public class MsoTenantUtilsFactoryTest { + + @Mock + private CloudConfig cloudConfig; + @InjectMocks + private MsoTenantUtilsFactory msoTenantUtilsFactory; + + @Test + public void getTenantUtils_shouldThrowException_whenNoCloudSiteFoundForGivenId() { + // GIVEN + String cloudSiteId = "CloudSiteId"; + given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.empty()); + + // WHEN + MsoCloudSiteNotFound msoCloudSiteNotFound = catchThrowableOfType( + () -> msoTenantUtilsFactory.getTenantUtils(cloudSiteId), MsoCloudSiteNotFound.class); + + // THEN + assertThat(msoCloudSiteNotFound.getMessage()).contains(cloudSiteId); + } + +}
\ No newline at end of file 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 011bb1416b..368df847be 100644 --- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml +++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml @@ -22,11 +22,14 @@ cloud_config: clli: "MTN6" aic_version: "3.0" identity_service_id: "ORDM3" -adapters: - po: - retryCodes: "504" - retryDelay: "5" - retryCount: "3" +org: + onap: + so: + adapters: + po: + retryCodes: "504" + retryDelay: "5" + retryCount: "3" tenant: tenant_description: "ECOMP Tenant" region_type: "single" |