add post request test

Change-Id: I8d488a48b68d99d72439901616a5e3053aa836fd
Issue-ID: DCAEGEN2-1315
Signed-off-by: micdzied <michal.1.dziedzic@nokia.com>
diff --git a/pom.xml b/pom.xml
index d81808f..51ec777 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
     <vavr.version>0.10.0</vavr.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.22.1</maven-failsafe-plugin.version>
+    <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
   </properties>
 
   <modules>
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 37c189e..936ef0c 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
@@ -20,6 +20,7 @@
 
 package org.onap.dcaegen2.services.sdk.rest.services.adapters.http;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -27,7 +28,6 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel;
 import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
@@ -53,7 +53,6 @@
     private DmaapModel dmaapModel = mock(DmaapModel.class);
     private JsonBodyBuilder<DmaapModel> jsonBodyBuilder = mock(JsonBodyBuilder.class);
 
-    @Disabled
     @Test
     void successfulPatchResponse() {
         DisposableServer server = createValidServer();
@@ -63,15 +62,12 @@
         when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
         Mono<HttpClientResponse> content = cloudHttpClient.patch(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
             jsonBodyBuilder, dmaapModel);
+        HttpClientResponse httpClientResponse = content.block();
 
-        StepVerifier.create(content)
-            .expectNext(content.block())
-            .expectComplete()
-            .verify();
+        assertEquals(HttpResponseStatus.OK, httpClientResponse.status());
         server.disposeNow();
     }
 
-    @Disabled
     @Test
     void errorPatchRequest() {
         DisposableServer server = createInvalidServer();
@@ -81,11 +77,39 @@
         when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
         Mono<HttpClientResponse> content = cloudHttpClient.patch(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
             jsonBodyBuilder, dmaapModel);
+        HttpClientResponse httpClientResponse = content.block();
 
-        StepVerifier.create(content)
-            .expectNext(content.block())
-            .expectComplete()
-            .verify();
+        assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpClientResponse.status());
+        server.disposeNow();
+    }
+
+    @Test
+    void successfulPostResponse() {
+        DisposableServer server = createValidServer();
+        HttpClient httpClient = createHttpClientForContextWithAddress(server, connectionProvider);
+        CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
+
+        when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
+        Mono<HttpClientResponse> content = cloudHttpClient.post(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
+            jsonBodyBuilder, dmaapModel);
+        HttpClientResponse httpClientResponse = content.block();
+
+        assertEquals(HttpResponseStatus.OK, httpClientResponse.status());
+        server.disposeNow();
+    }
+
+    @Test
+    void errorPostRequest() {
+        DisposableServer server = createInvalidServer();
+        HttpClient httpClient = createHttpClientForContextWithAddress(server, connectionProvider);
+        CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
+
+        when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
+        Mono<HttpClientResponse> content = cloudHttpClient.post(SAMPLE_URL, createRequestDiagnosticContext(), createCustomHeaders(),
+            jsonBodyBuilder, dmaapModel);
+        HttpClientResponse httpClientResponse = content.block();
+
+        assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, httpClientResponse.status());
         server.disposeNow();
     }
 
@@ -95,14 +119,22 @@
         HttpClient httpClient = createHttpClientForContextWithAddress(server, connectionProvider);
         CloudHttpClient cloudHttpClient = new CloudHttpClient(httpClient);
 
+        when(jsonBodyBuilder.createJsonBody(dmaapModel)).thenReturn(JSON_BODY);
         Mono<String> content = cloudHttpClient.get(SAMPLE_URL, String.class);
+        Mono<String> contentWithHeaders = cloudHttpClient.get(SAMPLE_URL, createRequestDiagnosticContext(),
+            createCustomHeaders(), String.class);
 
         StepVerifier.create(content)
             .expectNext(SAMPLE_STRING)
             .expectComplete()
             .verify();
+        StepVerifier.create(contentWithHeaders)
+            .expectNext(SAMPLE_STRING)
+            .expectComplete()
+            .verify();
         server.disposeNow();
     }
+
     @Test
     void errorGetRequest() {
         DisposableServer server = createInvalidServer();
@@ -120,7 +152,6 @@
     private Map<String, String> createCustomHeaders() {
         Map<String, String> customHeaders = new HashMap<>();
         customHeaders.put("X_INVOCATION_ID", UUID.randomUUID().toString());
-
         return customHeaders;
     }