Merge "Filtering the producer in the frontend"
[portal/nonrtric-controlpanel.git] / webapp-backend / src / test / java / org / oransc / portal / nonrtric / controlpanel / util / AsyncRestClientTest.java
index 8135ad3..f668803 100644 (file)
@@ -33,13 +33,14 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.reactive.function.client.WebClientResponseException;
 
 import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 import reactor.util.Loggers;
 
-public class AsyncRestClientTest {
+class AsyncRestClientTest {
     private static final String BASE_URL = "BaseUrl";
     private static final String REQUEST_URL = "/test";
     private static final String TEST_JSON = "{\"type\":\"type1\"}";
@@ -65,7 +66,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testGetNoError() {
+    void testGetNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -75,7 +76,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testGetError() {
+    void testGetError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL);
@@ -84,7 +85,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPutNoError() {
+    void testPutNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -94,7 +95,16 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPutError() {
+    void testPutWithoutBodyNoError() {
+        mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
+            .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE));
+
+        Mono<ResponseEntity<String>> returnedMono = clientUnderTest.putForEntity(REQUEST_URL);
+        StepVerifier.create(returnedMono).expectNextCount(1).expectComplete().verify();
+    }
+
+    @Test
+    void testPutError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON);
@@ -103,7 +113,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testDeleteNoError() {
+    void testDeleteNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE));
 
         Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
@@ -111,7 +121,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testDeleteError() {
+    void testDeleteError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);