summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2024-08-26 17:52:34 +0100
committerToineSiebelink <toine.siebelink@est.tech>2024-08-26 17:52:57 +0100
commit0ae8299c8a4c811cc5bc001a8531f367687f0678 (patch)
tree55cb0aaca90fcc4bc33e1040c311f76719b7e215 /cps-ncmp-service
parent3a4dcb5af00b85ae3f48709dfa0f9d797e02aabd (diff)
Policy Executor, refactor(move) common http classes
Issue-ID: CPS-2343 Change-Id: Ia9655364462826a794a2af78214311cb38c40de9 Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImpl.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java1
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfiguration.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfiguration.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilder.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilder.java)35
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/UrlTemplateParameters.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/UrlTemplateParameters.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/WebClientConfiguration.java)2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImplSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImplSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy1
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDogSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilderSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilderSpec.groovy)15
19 files changed, 54 insertions, 54 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
index 8be57fed3d..0cedeae0a4 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
@@ -45,12 +45,12 @@ import org.onap.cps.ncmp.impl.data.policyexecutor.PolicyExecutor;
import org.onap.cps.ncmp.impl.data.utils.DmiDataOperationsHelper;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
import org.onap.cps.ncmp.impl.inventory.InventoryPersistence;
import org.onap.cps.ncmp.impl.inventory.models.CmHandleState;
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
import org.onap.cps.ncmp.impl.models.DmiRequestBody;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.http.ResponseEntity;
@@ -213,7 +213,7 @@ public class DmiDataOperations {
final String optionsParamInQuery,
final String topicParamInQuery) {
final String dmiServiceName = yangModelCmHandle.resolveDmiServiceName(DATA);
- return DmiServiceUrlTemplateBuilder.newInstance()
+ return RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("ch")
.variablePathSegment("cmHandleId", yangModelCmHandle.getId())
.fixedPathSegment("data")
@@ -228,7 +228,7 @@ public class DmiDataOperations {
private UrlTemplateParameters getUrlTemplateParameters(final String dmiServiceName,
final String requestId,
final String topicParamInQuery) {
- return DmiServiceUrlTemplateBuilder.newInstance()
+ return RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("data")
.queryParameter("requestId", requestId)
.queryParameter("topic", topicParamInQuery)
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImpl.java
index 031cedc78b..8934c088a1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImpl.java
@@ -24,8 +24,8 @@ import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.api.datajobs.DataJobResultService;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.springframework.stereotype.Service;
@Service
@@ -41,7 +41,7 @@ public class DataJobResultServiceImpl implements DataJobResultService {
final String dataProducerId,
final String dataProducerJobId,
final String destination) {
- final UrlTemplateParameters urlTemplateParameters = DmiServiceUrlTemplateBuilder.newInstance()
+ final UrlTemplateParameters urlTemplateParameters = RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("cmwriteJob")
.fixedPathSegment("dataProducer")
.variablePathSegment("dataProducerId", dataProducerId)
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java
index fb17f066ce..1cfb8a9dff 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java
@@ -24,8 +24,8 @@ import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.api.datajobs.DataJobStatusService;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.springframework.stereotype.Service;
/**
@@ -54,7 +54,7 @@ public class DataJobStatusServiceImpl implements DataJobStatusService {
private UrlTemplateParameters buildUrlParameters(final String dmiServiceName,
final String dataProducerId,
final String dataProducerJobId) {
- return DmiServiceUrlTemplateBuilder.newInstance()
+ return RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("cmwriteJob")
.fixedPathSegment("dataProducer")
.variablePathSegment("dataProducerId", dataProducerId)
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
index 0d14dace5e..a118d53e7e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java
@@ -33,9 +33,9 @@ import org.onap.cps.ncmp.api.datajobs.models.SubJobWriteRequest;
import org.onap.cps.ncmp.api.datajobs.models.SubJobWriteResponse;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
import org.onap.cps.ncmp.impl.models.RequiredDmiService;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -88,7 +88,7 @@ public class DmiSubJobRequestHandler {
}
private UrlTemplateParameters getUrlTemplateParameters(final String destination, final ProducerKey producerKey) {
- return DmiServiceUrlTemplateBuilder.newInstance()
+ return RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("cmwriteJob")
.queryParameter("destination", destination)
.createUrlTemplateParameters(producerKey.dmiServiceName(), dmiProperties.getDmiBasePath());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
index c10132060d..a177272dff 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java
@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.data.models.OperationType;
import org.onap.cps.ncmp.api.exceptions.DmiClientRequestException;
import org.onap.cps.ncmp.impl.models.RequiredDmiService;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpHeaders;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfiguration.java
index 265d284239..4134a56ead 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfiguration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfiguration.java
@@ -22,7 +22,7 @@ package org.onap.cps.ncmp.impl.dmi;
import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.config.DmiHttpClientConfig;
-import org.onap.cps.ncmp.impl.utils.WebClientConfiguration;
+import org.onap.cps.ncmp.impl.utils.http.WebClientConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
index 433c67f100..8ba70b3a31 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
@@ -36,10 +36,10 @@ import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.api.inventory.models.YangResource;
import org.onap.cps.ncmp.impl.dmi.DmiProperties;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
import org.onap.cps.ncmp.impl.models.DmiRequestBody;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.http.ResponseEntity;
@@ -107,7 +107,7 @@ public class DmiModelOperations {
final String jsonRequestBody,
final String cmHandle,
final String resourceName) {
- final UrlTemplateParameters urlTemplateParameters = DmiServiceUrlTemplateBuilder.newInstance()
+ final UrlTemplateParameters urlTemplateParameters = RestServiceUrlTemplateBuilder.newInstance()
.fixedPathSegment("ch")
.variablePathSegment("cmHandleId", cmHandle)
.fixedPathSegment(resourceName)
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java
index c81e9b7840..94c5ef75f1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java
@@ -26,9 +26,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.inventory.models.TrustLevel;
import org.onap.cps.ncmp.impl.dmi.DmiRestClient;
-import org.onap.cps.ncmp.impl.dmi.DmiServiceUrlTemplateBuilder;
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters;
import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService;
+import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder;
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@@ -73,7 +73,7 @@ public class DmiPluginTrustLevelWatchDog {
}
private String getDmiHealthStatus(final String dmiServiceBaseUrl) {
- final UrlTemplateParameters urlTemplateParameters = DmiServiceUrlTemplateBuilder.newInstance()
+ final UrlTemplateParameters urlTemplateParameters = RestServiceUrlTemplateBuilder.newInstance()
.createUrlTemplateParametersForHealthCheck(dmiServiceBaseUrl);
return dmiRestClient.getDmiHealthStatus(urlTemplateParameters).block();
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfiguration.java
index a927764825..333030ccd2 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfiguration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfiguration.java
@@ -22,7 +22,7 @@ package org.onap.cps.ncmp.impl.policyexecutor;
import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.config.PolicyExecutorHttpClientConfig;
-import org.onap.cps.ncmp.impl.utils.WebClientConfiguration;
+import org.onap.cps.ncmp.impl.utils.http.WebClientConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilder.java
index e7dbea83f2..fafb09007d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilder.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilder.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.impl.dmi;
+package org.onap.cps.ncmp.impl.utils.http;
import java.util.Collections;
import java.util.HashMap;
@@ -30,7 +30,7 @@ import org.apache.logging.log4j.util.Strings;
import org.springframework.web.util.UriComponentsBuilder;
@NoArgsConstructor
-public class DmiServiceUrlTemplateBuilder {
+public class RestServiceUrlTemplateBuilder {
private final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance();
private static final String FIXED_PATH_SEGMENT = null;
@@ -43,8 +43,8 @@ public class DmiServiceUrlTemplateBuilder {
*
* @return a new instance of DmiServiceUrlTemplateBuilder
*/
- public static DmiServiceUrlTemplateBuilder newInstance() {
- return new DmiServiceUrlTemplateBuilder();
+ public static RestServiceUrlTemplateBuilder newInstance() {
+ return new RestServiceUrlTemplateBuilder();
}
/**
@@ -53,7 +53,7 @@ public class DmiServiceUrlTemplateBuilder {
* @param pathSegment the path segment
* @return this builder instance
*/
- public DmiServiceUrlTemplateBuilder fixedPathSegment(final String pathSegment) {
+ public RestServiceUrlTemplateBuilder fixedPathSegment(final String pathSegment) {
pathSegments.put(pathSegment, FIXED_PATH_SEGMENT);
return this;
}
@@ -66,7 +66,7 @@ public class DmiServiceUrlTemplateBuilder {
* @param value the value to be insert in teh URL for the given variable path segment
* @return this builder instance
*/
- public DmiServiceUrlTemplateBuilder variablePathSegment(final String pathSegment, final String value) {
+ public RestServiceUrlTemplateBuilder variablePathSegment(final String pathSegment, final String value) {
pathSegments.put(pathSegment, value);
return this;
}
@@ -80,8 +80,8 @@ public class DmiServiceUrlTemplateBuilder {
*
* @return this builder instance
*/
- public DmiServiceUrlTemplateBuilder queryParameter(final String queryParameterName,
- final String queryParameterValue) {
+ public RestServiceUrlTemplateBuilder queryParameter(final String queryParameterName,
+ final String queryParameterValue) {
if (Strings.isNotBlank(queryParameterValue)) {
queryParameters.put(queryParameterName, queryParameterValue);
}
@@ -91,12 +91,12 @@ public class DmiServiceUrlTemplateBuilder {
/**
* Constructs a URL template with variables based on the accumulated path segments and query parameters.
*
- * @param dmiServiceBaseUrl the base URL of the DMI service, e.g., "http://dmi-service.com".
- * @param dmiBasePath the base path of the DMI service
+ * @param serviceBaseUrl the base URL of the service, e.g., "http://dmi-service.com".
+ * @param basePath the base path of the service
* @return a UrlTemplateParameters instance containing the complete URL template and URL variables
*/
- public UrlTemplateParameters createUrlTemplateParameters(final String dmiServiceBaseUrl, final String dmiBasePath) {
- this.uriComponentsBuilder.pathSegment(dmiBasePath)
+ public UrlTemplateParameters createUrlTemplateParameters(final String serviceBaseUrl, final String basePath) {
+ this.uriComponentsBuilder.pathSegment(basePath)
.pathSegment(VERSION_SEGMENT);
final Map<String, String> urlTemplateVariables = new HashMap<>();
@@ -115,22 +115,21 @@ public class DmiServiceUrlTemplateBuilder {
urlTemplateVariables.put(paramName, paramValue);
});
- final String urlTemplate = dmiServiceBaseUrl + this.uriComponentsBuilder.build().toUriString();
+ final String urlTemplate = serviceBaseUrl + this.uriComponentsBuilder.build().toUriString();
return new UrlTemplateParameters(urlTemplate, urlTemplateVariables);
}
/**
* Constructs a URL for DMI health check based on the given base URL.
*
- * @param dmiServiceBaseUrl the base URL of the DMI service, e.g., "http://dmi-service.com".
+ * @param serviceBaseUrl the base URL of the service, e.g., "http://dmi-service.com".
* @return a {@link UrlTemplateParameters} instance containing the complete URL template and empty URL variables,
* suitable for DMI health check.
*/
- public UrlTemplateParameters createUrlTemplateParametersForHealthCheck(final String dmiServiceBaseUrl) {
- this.uriComponentsBuilder.pathSegment("actuator")
- .pathSegment("health");
+ public UrlTemplateParameters createUrlTemplateParametersForHealthCheck(final String serviceBaseUrl) {
+ this.uriComponentsBuilder.pathSegment("actuator").pathSegment("health");
- final String urlTemplate = dmiServiceBaseUrl + this.uriComponentsBuilder.build().toUriString();
+ final String urlTemplate = serviceBaseUrl + this.uriComponentsBuilder.build().toUriString();
return new UrlTemplateParameters(urlTemplate, Collections.emptyMap());
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/UrlTemplateParameters.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/UrlTemplateParameters.java
index f51511116a..839af71823 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/UrlTemplateParameters.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/UrlTemplateParameters.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.impl.dmi;
+package org.onap.cps.ncmp.impl.utils.http;
import java.util.Map;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/WebClientConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java
index 967f74e942..d8e8350345 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/WebClientConfiguration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/http/WebClientConfiguration.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.impl.utils;
+package org.onap.cps.ncmp.impl.utils.http;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.ChannelOption;
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
index 2324d48a93..ec13aee4bb 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
@@ -31,9 +31,9 @@ import org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
import org.onap.cps.ncmp.impl.data.policyexecutor.PolicyExecutor
import org.onap.cps.ncmp.impl.dmi.DmiOperationsBaseSpec
import org.onap.cps.ncmp.impl.dmi.DmiProperties
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImplSpec.groovy
index 3af474040e..74bd0484df 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobResultServiceImplSpec.groovy
@@ -22,7 +22,7 @@ package org.onap.cps.ncmp.impl.datajobs
import org.onap.cps.ncmp.impl.dmi.DmiProperties
import org.onap.cps.ncmp.impl.dmi.DmiRestClient
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import reactor.core.publisher.Mono
import spock.lang.Specification
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImplSpec.groovy
index d231dfa755..be46d885e0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImplSpec.groovy
@@ -22,7 +22,7 @@ package org.onap.cps.ncmp.impl.datajobs
import org.onap.cps.ncmp.impl.dmi.DmiProperties
import org.onap.cps.ncmp.impl.dmi.DmiRestClient
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import reactor.core.publisher.Mono
import spock.lang.Specification
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
index d92e69a136..4d47ef14a0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiRestClientSpec.groovy
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.cps.ncmp.api.exceptions.DmiClientRequestException
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.springframework.http.HttpHeaders
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
index 196a1cd360..c80aa7b242 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.impl.dmi.DmiOperationsBaseSpec
import org.onap.cps.ncmp.impl.dmi.DmiProperties
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDogSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDogSpec.groovy
index 0a34d267c5..3a1cd14c48 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDogSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDogSpec.groovy
@@ -22,8 +22,8 @@ package org.onap.cps.ncmp.impl.inventory.trustlevel
import org.onap.cps.ncmp.api.inventory.models.TrustLevel
import org.onap.cps.ncmp.impl.dmi.DmiRestClient
-import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
import org.onap.cps.ncmp.impl.inventory.CmHandleQueryService
+import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import reactor.core.publisher.Mono
import spock.lang.Specification
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilderSpec.groovy
index 9e1b37023b..9e051156f7 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiServiceUrlTemplateBuilderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/http/RestServiceUrlTemplateBuilderSpec.groovy
@@ -18,14 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.impl.dmi
-
+package org.onap.cps.ncmp.impl.utils.http
import spock.lang.Specification
-class DmiServiceUrlTemplateBuilderSpec extends Specification {
+class RestServiceUrlTemplateBuilderSpec extends Specification {
- def objectUnderTest = new DmiServiceUrlTemplateBuilder()
+ def objectUnderTest = new RestServiceUrlTemplateBuilder()
def 'Build URL template parameters with (variable) path segments and query parameters.'() {
given: 'the URL details are given to the builder'
@@ -35,9 +34,9 @@ class DmiServiceUrlTemplateBuilderSpec extends Specification {
objectUnderTest.queryParameter('param1', 'abc')
objectUnderTest.queryParameter('param2', 'value?with#special:characters')
when: 'the URL template parameters are created'
- def result = objectUnderTest.createUrlTemplateParameters('myDmiServer', 'myBasePath')
+ def result = objectUnderTest.createUrlTemplateParameters('myServer', 'myBasePath')
then: 'the URL template contains variable names instead of value and un-encoded fixed segment'
- assert result.urlTemplate == 'myDmiServer/myBasePath/v1/segment/{myVariableSegment}/segment?with:special&characters?param1={param1}&param2={param2}'
+ assert result.urlTemplate == 'myServer/myBasePath/v1/segment/{myVariableSegment}/segment?with:special&characters?param1={param1}&param2={param2}'
and: 'URL variables contains name and un-encoded value pairs'
assert result.urlVariables == ['myVariableSegment': 'someValue', 'param1': 'abc', 'param2': 'value?with#special:characters']
}
@@ -46,7 +45,7 @@ class DmiServiceUrlTemplateBuilderSpec extends Specification {
given: 'the query parameter is given to the builder'
objectUnderTest.queryParameter('my&param', 'special&characters=are?not\\encoded')
when: 'the URL template parameters are created'
- def result = objectUnderTest.createUrlTemplateParameters('myDmiServer', 'myBasePath')
+ def result = objectUnderTest.createUrlTemplateParameters('myServer', 'myBasePath')
then: 'Special characters are not encoded'
assert result.urlVariables == ['my&param': 'special&characters=are?not\\encoded']
}
@@ -55,7 +54,7 @@ class DmiServiceUrlTemplateBuilderSpec extends Specification {
when: 'the query parameter is given to the builder'
objectUnderTest.queryParameter('param', value)
and: 'the URL template parameters are create'
- def result = objectUnderTest.createUrlTemplateParameters('myDmiServer', 'myBasePath')
+ def result = objectUnderTest.createUrlTemplateParameters('myServer', 'myBasePath')
then: 'no parameter gets added'
assert result.urlVariables.isEmpty()
where: 'the following parameter values are used'