summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml2
-rw-r--r--rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClientIT.java55
2 files changed, 44 insertions, 13 deletions
diff --git a/pom.xml b/pom.xml
index d81808f7..51ec777c 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 37c189ee..936ef0c5 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 io.netty.handler.codec.http.HttpResponseStatus;
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 @@ class CloudHttpClientIT {
private DmaapModel dmaapModel = mock(DmaapModel.class);
private JsonBodyBuilder<DmaapModel> jsonBodyBuilder = mock(JsonBodyBuilder.class);
- @Disabled
@Test
void successfulPatchResponse() {
DisposableServer server = createValidServer();
@@ -63,15 +62,12 @@ class CloudHttpClientIT {
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 @@ class CloudHttpClientIT {
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 @@ class CloudHttpClientIT {
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 @@ class CloudHttpClientIT {
private Map<String, String> createCustomHeaders() {
Map<String, String> customHeaders = new HashMap<>();
customHeaders.put("X_INVOCATION_ID", UUID.randomUUID().toString());
-
return customHeaders;
}