Modified CloudHttpClient in order to be more generic 51/83551/2
authorandrzejszukuc <andrzej.szukuc@nokia.com>
Thu, 28 Mar 2019 05:16:08 +0000 (06:16 +0100)
committerandrzejszukuc <andrzej.szukuc@nokia.com>
Thu, 28 Mar 2019 15:05:21 +0000 (16:05 +0100)
New AaiClients and AaiModels have been added

Change-Id: I80151e8296482e39f7f36123210861702c205b7b
Signed-off-by: andrzejszukuc <andrzej.szukuc@nokia.com>
Issue-ID: DCAEGEN2-1059

13 files changed:
pom.xml
rest-services/aai-client/pom.xml
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/config/AaiClientConfiguration.java
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/AaiHttpClient.java
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiGetServiceInstanceClient.java [new file with mode: 0644]
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/get/AaiHttpGetClient.java
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/patch/AaiHttpPatchClient.java
rest-services/aai-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/aai/client/service/http/put/AaiHttpPutClient.java
rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java
rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/model/AaiServiceInstanceQueryModel.java [new file with mode: 0644]
rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java
rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClientTest.java

diff --git a/pom.xml b/pom.xml
index 8bc59ce..77ab593 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,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>
         <artifactId>vavr</artifactId>
         <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>
index 037f183..641fc4a 100644 (file)
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-text</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
index 30bf253..3a6dbc4 100644 (file)
@@ -58,6 +58,9 @@ public abstract class AaiClientConfiguration implements Serializable {
     @Value.Parameter
     public abstract String aaiPnfPath();
 
+    @Value.Parameter
+    public abstract String aaiServiceInstancePath();
+
     @Value.Parameter
     public abstract Map<String, String> aaiHeaders();
 
index c88ca0e..317fab2 100644 (file)
 
 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 (file)
index 0000000..f8300eb
--- /dev/null
@@ -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
index dad1c1f..1c3f20a 100644 (file)
@@ -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) {
index 1851100..f92dba9 100644 (file)
 
 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
index 33fcfcc..eb1a389 100644 (file)
 
 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);
     }
 }
index 132d3d8..7b87511 100644 (file)
@@ -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 (file)
index 0000000..bb4493e
--- /dev/null
@@ -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();
+}
index 9844ef1..d221a80 100644 (file)
@@ -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();
     }
 
index 84596cd..0d453e4 100644 (file)
 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() {
index a2b3575..4f58ffb 100644 (file)
@@ -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 -> {