aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Wielebski <piotr.wielebski@nokia.com>2019-03-29 13:34:04 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-29 13:34:04 +0000
commit6c25f486820d1fca8f8aa7c075dec832ca9d1536 (patch)
treedb8c9775748e3246d4f11d2a048b8766d10af8c8
parent83d9cfbba07f622ba090c69b9ea55be35c2aca05 (diff)
parent318c2405310ad369983c169e3b7b4443b2049253 (diff)
Merge "Modified CloudHttpClient in order to be more generic New AaiClients and AaiModels have been added"
-rw-r--r--pom.xml6
-rw-r--r--rest-services/aai-client/pom.xml5
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java3
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java11
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiGetServiceInstanceClient.java77
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java7
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java22
-rw-r--r--rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java12
-rw-r--r--rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java52
-rw-r--r--rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/model/AaiServiceInstanceQueryModel.java31
-rw-r--r--rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java36
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java32
-rw-r--r--rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java5
13 files changed, 221 insertions, 78 deletions
diff --git a/pom.xml b/pom.xml
index 255e4079..4dc5d0d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,7 @@
<mockito.version>2.23.4</mockito.version>
<protobuf.version>3.6.1</protobuf.version>
<vavr.version>0.10.0</vavr.version>
+ <commons-text.version>1.6</commons-text.version>
<jetbrains-annotations.version>16.0.3</jetbrains-annotations.version>
<protoc-jar-maven-plugin.version>3.6.0.2</protoc-jar-maven-plugin.version>
<maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
@@ -180,6 +181,11 @@
<version>${vavr.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ <version>${commons-text.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
diff --git a/rest-services/aai-client/pom.xml b/rest-services/aai-client/pom.xml
index 037f183d..641fc4a4 100644
--- a/rest-services/aai-client/pom.xml
+++ b/rest-services/aai-client/pom.xml
@@ -30,6 +30,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java
index 30bf2538..3a6dbc46 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java
@@ -59,6 +59,9 @@ public abstract class AaiClientConfiguration implements Serializable {
public abstract String aaiPnfPath();
@Value.Parameter
+ public abstract String aaiServiceInstancePath();
+
+ @Value.Parameter
public abstract Map<String, String> aaiHeaders();
@Value.Parameter
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java
index c88ca0ea..317fab2c 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java
@@ -20,9 +20,14 @@
package org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http;
-import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel;
import reactor.core.publisher.Mono;
-public interface AaiHttpClient<T> {
- Mono<T> getAaiResponse(AaiModel aaiModel);
+import java.util.function.Function;
+
+public interface AaiHttpClient<T, U> {
+ Mono<U> getAaiResponse(T aaiModel);
+
+ default <S> AaiHttpClient<T, S> map(final Function<U,S> fn) {
+ return aaiModel -> AaiHttpClient.this.getAaiResponse(aaiModel).map(fn);
+ }
}
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiGetServiceInstanceClient.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiGetServiceInstanceClient.java
new file mode 100644
index 00000000..f8300eb2
--- /dev/null
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiGetServiceInstanceClient.java
@@ -0,0 +1,77 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA 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.dcaegen2.services.sdk.rest.services.aai.client.service.http.get;
+
+import io.vavr.collection.HashMap;
+import io.vavr.collection.Map;
+import org.apache.commons.text.StringSubstitutor;
+import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.AaiHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
+import org.onap.dcaegen2.services.sdk.rest.services.model.AaiServiceInstanceQueryModel;
+import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
+import reactor.core.publisher.Mono;
+
+import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory.createRequestDiagnosticContext;
+
+public class AaiGetServiceInstanceClient implements
+ AaiHttpClient<AaiServiceInstanceQueryModel, HttpResponse> {
+
+ //variables for query "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}"
+ public static final String CUSTOMER = "customer";
+ public static final String SERVICE_TYPE = "serviceType";
+ public static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+
+ private CloudHttpClient httpGetClient;
+ private final AaiClientConfiguration configuration;
+
+ public AaiGetServiceInstanceClient(final AaiClientConfiguration configuration, final CloudHttpClient httpGetClient) {
+ this.configuration = configuration;
+ this.httpGetClient = httpGetClient;
+ }
+
+ @Override
+ public Mono<HttpResponse> getAaiResponse(AaiServiceInstanceQueryModel aaiModel) {
+ final Map<String, String> mapping = HashMap.of(
+ CUSTOMER, aaiModel.customerId(),
+ SERVICE_TYPE, aaiModel.serviceType(),
+ SERVICE_INSTANCE_ID, aaiModel.serviceInstanceId());
+
+ final StringSubstitutor substitutor = new StringSubstitutor(mapping.toJavaMap());
+ final String replaced = substitutor.replace(configuration.aaiServiceInstancePath());
+
+ return httpGetClient.get(
+ getUri(replaced),
+ createRequestDiagnosticContext(),
+ configuration.aaiHeaders());
+ }
+
+ private String getUri(final String endpoint) {
+ return new URI.URIBuilder()
+ .scheme(configuration.aaiProtocol())
+ .host(configuration.aaiHost())
+ .port(configuration.aaiPort())
+ .path(configuration.aaiBasePath() + "/" + endpoint)
+ .build()
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java
index dad1c1f1..1c3f20a6 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java
@@ -23,13 +23,14 @@ package org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.get
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.AaiHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
import reactor.core.publisher.Mono;
import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory.createRequestDiagnosticContext;
-public final class AaiHttpGetClient implements AaiHttpClient<String> {
+public final class AaiHttpGetClient implements AaiHttpClient<AaiModel, HttpResponse> {
private CloudHttpClient httpGetClient;
private final AaiClientConfiguration configuration;
@@ -41,8 +42,8 @@ public final class AaiHttpGetClient implements AaiHttpClient<String> {
}
@Override
- public Mono<String> getAaiResponse(AaiModel aaiModel) {
- return httpGetClient.get(getUri(aaiModel.getCorrelationId()), createRequestDiagnosticContext(), configuration.aaiHeaders(), String.class);
+ public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
+ return httpGetClient.get(getUri(aaiModel.getCorrelationId()), createRequestDiagnosticContext(), configuration.aaiHeaders());
}
private String getUri(String pnfName) {
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java
index 18511008..f92dba99 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java
@@ -20,18 +20,22 @@
package org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.patch;
+import io.vavr.collection.HashMap;
+import io.vavr.collection.Map;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.AaiHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel;
import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI;
import reactor.core.publisher.Mono;
-import reactor.netty.http.client.HttpClientResponse;
+
import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory.createRequestDiagnosticContext;
-public final class AaiHttpPatchClient implements AaiHttpClient<HttpClientResponse> {
+public final class AaiHttpPatchClient implements AaiHttpClient<AaiModel, HttpResponse> {
+ private final static Map<String, String> CONTENT_TYPE = HashMap.of("Content-Type", "application/merge-patch+json");
private CloudHttpClient httpPatchClient;
private final AaiClientConfiguration configuration;
@@ -44,9 +48,15 @@ public final class AaiHttpPatchClient implements AaiHttpClient<HttpClientRespons
this.httpPatchClient = httpPatchClient;
}
- public Mono<HttpClientResponse> getAaiResponse(AaiModel aaiModel) {
- return httpPatchClient
- .patch(getUri(aaiModel.getCorrelationId()), createRequestDiagnosticContext(), configuration.aaiHeaders(), jsonBodyBuilder, aaiModel);
+ public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
+ final Map<String, String> headers = CONTENT_TYPE.merge(HashMap.ofAll(configuration.aaiHeaders()));
+
+ return httpPatchClient.patch(
+ getUri(aaiModel.getCorrelationId()),
+ createRequestDiagnosticContext(),
+ headers.toJavaMap(),
+ jsonBodyBuilder,
+ aaiModel);
}
private String getUri(String pnfName) {
@@ -57,4 +67,4 @@ public final class AaiHttpPatchClient implements AaiHttpClient<HttpClientRespons
.path(configuration.aaiBasePath() + configuration.aaiPnfPath() + "/" + pnfName).build().toString();
}
-}
+} \ No newline at end of file
diff --git a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java
index 33fcfcce..eb1a389f 100644
--- a/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java
+++ b/rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java
@@ -21,17 +21,17 @@
package org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.put;
-import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory.createRequestDiagnosticContext;
-
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.AaiHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel;
import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
import reactor.core.publisher.Mono;
-import reactor.netty.http.client.HttpClientResponse;
-public class AaiHttpPutClient implements AaiHttpClient<HttpClientResponse> {
+import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory.createRequestDiagnosticContext;
+
+public class AaiHttpPutClient implements AaiHttpClient<AaiModel, HttpResponse> {
private CloudHttpClient httpPutClient;
private final AaiClientConfiguration configuration;
@@ -46,8 +46,8 @@ public class AaiHttpPutClient implements AaiHttpClient<HttpClientResponse> {
}
@Override
- public Mono<HttpClientResponse> getAaiResponse(AaiModel aaiModel) {
+ public Mono<HttpResponse> getAaiResponse(AaiModel aaiModel) {
return httpPutClient
- .put(uri, createRequestDiagnosticContext(), configuration.aaiHeaders(), jsonBodyBuilder, aaiModel);
+ .put(uri, createRequestDiagnosticContext(), configuration.aaiHeaders(), jsonBodyBuilder, aaiModel);
}
}
diff --git a/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java
index 132d3d83..7b87511b 100644
--- a/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java
+++ b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java
@@ -31,8 +31,6 @@ import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnos
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
-import reactor.netty.http.client.HttpClientResponse;
-
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 11/15/18
@@ -65,25 +63,32 @@ public class CloudHttpClient {
return get(url, context, Collections.emptyMap(), bodyClass);
}
- public <T> Mono<T> get(
- String url,
- RequestDiagnosticContext context,
- Map<String, String> customHeaders,
- Class<T> bodyClass) {
+ public Mono<HttpResponse> get(
+ String url,
+ RequestDiagnosticContext context,
+ Map<String, String> customHeaders) {
return httpClient.call(
- ImmutableHttpRequest.builder()
- .method(HttpMethod.GET)
- .url(url)
- .customHeaders(HashMap.ofAll(customHeaders))
- .diagnosticContext(context)
- .build())
- .doOnNext(HttpResponse::throwIfUnsuccessful)
- .map(HttpResponse::bodyAsString)
- .map(body -> gson.fromJson(body, bodyClass));
+ ImmutableHttpRequest.builder()
+ .method(HttpMethod.GET)
+ .url(url)
+ .customHeaders(HashMap.ofAll(customHeaders))
+ .diagnosticContext(context)
+ .build());
+ }
+
+ public <T> Mono<T> get(
+ String url,
+ RequestDiagnosticContext context,
+ Map<String, String> customHeaders,
+ Class<T> bodyClass) {
+ return get(url, context, customHeaders)
+ .doOnNext(HttpResponse::throwIfUnsuccessful)
+ .map(HttpResponse::bodyAsString)
+ .map(body -> gson.fromJson(body, bodyClass));
}
- public Mono<HttpClientResponse> post(
+ public Mono<HttpResponse> post(
String url,
RequestDiagnosticContext context,
Map<String, String> customHeaders,
@@ -92,7 +97,7 @@ public class CloudHttpClient {
return callForRawResponse(url, context, customHeaders, jsonBodyBuilder, clientModel, HttpMethod.POST);
}
- public Mono<HttpClientResponse> patch(
+ public Mono<HttpResponse> patch(
String url,
RequestDiagnosticContext context,
Map<String, String> customHeaders,
@@ -101,7 +106,7 @@ public class CloudHttpClient {
return callForRawResponse(url, context, customHeaders, jsonBodyBuilder, clientModel, HttpMethod.PATCH);
}
- public Mono<HttpClientResponse> put(
+ public Mono<HttpResponse> put(
String url,
RequestDiagnosticContext context,
Map<String, String> customHeaders,
@@ -110,7 +115,7 @@ public class CloudHttpClient {
return callForRawResponse(url, context, customHeaders, jsonBodyBuilder, clientModel, HttpMethod.PUT);
}
- private Mono<HttpClientResponse> callForRawResponse(
+ private Mono<HttpResponse> callForRawResponse(
String url,
RequestDiagnosticContext context,
Map<String, String> customHeaders,
@@ -123,17 +128,14 @@ public class CloudHttpClient {
LOGGER.debug("CloudHttpClient url: {}", url);
LOGGER.debug("CloudHttpClient customHeaders: {}", customHeaders);
- return httpClient.prepareRequest(
+ return httpClient.call(
ImmutableHttpRequest.builder()
.url(url)
.customHeaders(HashMap.ofAll(customHeaders))
.diagnosticContext(context)
.body(RequestBody.fromString(jsonBody))
.method(method)
- .build())
- .responseSingle((httpClientResponse, byteBufMono) -> Mono.just(httpClientResponse));
+ .build());
}
-
-
}
diff --git a/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/model/AaiServiceInstanceQueryModel.java b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/model/AaiServiceInstanceQueryModel.java
new file mode 100644
index 00000000..bb4493e8
--- /dev/null
+++ b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/model/AaiServiceInstanceQueryModel.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA 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.dcaegen2.services.sdk.rest.services.model;
+
+import org.immutables.value.Value;
+
+@Value.Style(stagedBuilder = true)
+@Value.Immutable
+public interface AaiServiceInstanceQueryModel extends ClientModel {
+ String customerId();
+ String serviceType();
+ String serviceInstanceId();
+}
diff --git a/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java
index 9844ef1d..d221a809 100644
--- a/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java
+++ b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java
@@ -61,12 +61,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.patch(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.OK, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.OK.code(), httpClientResponse.statusCode());
server.disposeNow();
}
@@ -77,12 +77,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.patch(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), httpClientResponse.statusCode());
server.disposeNow();
}
@@ -93,12 +93,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.post(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.OK, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.OK.code(), httpClientResponse.statusCode());
server.disposeNow();
}
@@ -109,12 +109,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.post(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), httpClientResponse.statusCode());
server.disposeNow();
}
@@ -161,12 +161,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.put(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.OK, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.OK.code(), httpClientResponse.statusCode());
server.disposeNow();
}
@@ -177,12 +177,12 @@ class CloudHttpClientIT {
CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
- Mono<HttpClientResponse> content = cloudHttpClient
+ Mono<HttpResponse> content = cloudHttpClient
.put(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
jsonBodyBuilder, dmaapModel);
- HttpClientResponse httpClientResponse = content.block();
+ HttpResponse httpClientResponse = content.block();
- assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpClientResponse.status());
+ assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), httpClientResponse.statusCode());
server.disposeNow();
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
index 84596cde..0d453e47 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
@@ -21,10 +21,8 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer;
-import java.net.URI;
-import java.util.Map;
-import java.util.Optional;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPAbstractReactiveHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils;
@@ -33,7 +31,10 @@ import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder;
import reactor.core.publisher.Mono;
-import reactor.netty.http.client.HttpClientResponse;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Optional;
/**
@@ -49,10 +50,10 @@ public class DMaaPPublisherReactiveHttpClient extends DMaaPAbstractReactiveHttpC
* Constructor DMaaPPublisherReactiveHttpClient.
*
* @param dmaapPublisherConfiguration - DMaaP producer configuration object
- * @param cloudHttpClient - cloudHttpClient sending http requests
+ * @param cloudHttpClient - cloudHttpClient sending http requests
*/
DMaaPPublisherReactiveHttpClient(DmaapPublisherConfiguration dmaapPublisherConfiguration,
- CloudHttpClient cloudHttpClient, JsonBodyBuilder jsonBodyBuilder) {
+ CloudHttpClient cloudHttpClient, JsonBodyBuilder jsonBodyBuilder) {
this.dmaapPublisherConfiguration = dmaapPublisherConfiguration;
this.cloudHttpClient = cloudHttpClient;
this.jsonBodyBuilder = jsonBodyBuilder;
@@ -65,27 +66,28 @@ public class DMaaPPublisherReactiveHttpClient extends DMaaPAbstractReactiveHttpC
* @return status code of operation
*/
- public Mono<HttpClientResponse> getDMaaPProducerResponse(DmaapModel dmaapModel,
- Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) {
+ public Mono<HttpResponse> getDMaaPProducerResponse(
+ DmaapModel dmaapModel,
+ Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) {
return Mono.defer(() -> {
Map<String, String> headers = DMaaPClientServiceUtils.getHeaders(dmaapPublisherConfiguration.dmaapContentType());
if (requestDiagnosticContextOptional.isPresent()) {
cloudHttpClient
- .post(getUri().toString(), requestDiagnosticContextOptional.get(), headers, jsonBodyBuilder,
- dmaapModel);
+ .post(getUri().toString(), requestDiagnosticContextOptional.get(), headers, jsonBodyBuilder,
+ dmaapModel);
}
return cloudHttpClient
- .post(getUri().toString(), getRequestDiagnosticContext(), headers, jsonBodyBuilder, dmaapModel);
+ .post(getUri().toString(), getRequestDiagnosticContext(), headers, jsonBodyBuilder, dmaapModel);
});
}
URI getUri() {
return URI.create(
- new URIBuilder().scheme(dmaapPublisherConfiguration.dmaapProtocol())
- .host(dmaapPublisherConfiguration.dmaapHostName()).port(dmaapPublisherConfiguration.dmaapPortNumber())
- .path(createRequestPath())
- .build().toString());
+ new URIBuilder().scheme(dmaapPublisherConfiguration.dmaapProtocol())
+ .host(dmaapPublisherConfiguration.dmaapHostName()).port(dmaapPublisherConfiguration.dmaapPortNumber())
+ .path(createRequestPath())
+ .build().toString());
}
private String createRequestPath() {
diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java
index a2b3575a..4f58ffbd 100644
--- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java
+++ b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils;
import org.onap.dcaegen2.services.sdk.rest.services.model.ClientModel;
@@ -77,7 +78,7 @@ class DMaaPPublisherReactiveHttpClientTest {
@Test
void getHttpResponse_Success() {
//given
- Mono<HttpClientResponse> expectedResult = Mono.just(mock(HttpClientResponse.class));
+ Mono<HttpResponse> expectedResult = Mono.just(mock(HttpResponse.class));
//when
when(
cloudHttpClientMock
@@ -85,7 +86,7 @@ class DMaaPPublisherReactiveHttpClientTest {
DMaaPClientServiceUtils.getHeaders(ContentType.APPLICATION_JSON.getMimeType()),
jsonBodyBuilderMock,
mock(ClientModel.class)))
- .thenReturn(Mono.just(mock(HttpClientResponse.class)));
+ .thenReturn(Mono.just(mock(HttpResponse.class)));
//then
StepVerifier.create(expectedResult).expectSubscription()
.expectNextMatches(results -> {