Bugfix, no response sent to Dmaap for PUT 66/2666/1
authorPatrikBuhr <patrik.buhr@est.tech>
Wed, 4 Mar 2020 08:37:29 +0000 (09:37 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 4 Mar 2020 08:39:13 +0000 (09:39 +0100)
The asynch Web client by default emits Mono.empty() when there is no body,
now an empty string is returned instead.

Change-Id: I8963a93bd41c7654cddd9e01700883d472c0d3f0
Issue-ID: NONRTRIC-107
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
policy-agent/src/test/java/org/oransc/policyagent/clients/AsyncRestClientTest.java

index 0d27bd6..12c0745 100644 (file)
@@ -57,7 +57,8 @@ public class AsyncRestClient {
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
-            .bodyToMono(String.class);
+            .bodyToMono(String.class) //
+            .defaultIfEmpty("");
     }
 
     public Mono<String> postWithAuthHeader(String uri, String body, String username, String password) {
@@ -70,7 +71,8 @@ public class AsyncRestClient {
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
-            .bodyToMono(String.class);
+            .bodyToMono(String.class) //
+            .defaultIfEmpty("");
     }
 
     public Mono<String> put(String uri, String body) {
@@ -82,7 +84,8 @@ public class AsyncRestClient {
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
-            .bodyToMono(String.class);
+            .bodyToMono(String.class) //
+            .defaultIfEmpty("");
     }
 
     public Mono<String> get(String uri) {
@@ -92,7 +95,8 @@ public class AsyncRestClient {
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
-            .bodyToMono(String.class);
+            .bodyToMono(String.class) //
+            .defaultIfEmpty("");
     }
 
     public Mono<String> delete(String uri) {
@@ -102,6 +106,7 @@ public class AsyncRestClient {
             .retrieve() //
             .onStatus(HttpStatus::isError,
                 response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //
-            .bodyToMono(String.class);
+            .bodyToMono(String.class) //
+            .defaultIfEmpty("");
     }
 }
index 84fcae2..11f2409 100644 (file)
@@ -109,7 +109,7 @@ public class AsyncRestClientTest {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE));
 
         Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
-        StepVerifier.create(returnedMono).expectComplete().verify();
+        StepVerifier.create(returnedMono).expectNext("").expectComplete().verify();
     }
 
     @Test