diff options
author | Marcin Migdal <marcin.migdal@nokia.com> | 2019-03-19 13:14:24 +0100 |
---|---|---|
committer | Marcin Migdal <marcin.migdal@nokia.com> | 2019-03-19 13:14:24 +0100 |
commit | 7abe2954d3783cb8a6484f012507be95d59c82b9 (patch) | |
tree | 2c7f414a9d1ed4c38f868807e5378c99c27c3458 | |
parent | c852448b1e6ca5e28e0b0dab26c2af3d5af3f390 (diff) |
Change CloudHttpClient API parse Array
Change-Id: I1127ab28ee4f0e482540829f26acfc1bc8f5667c
Issue-ID: DCAEGEN2-1310
Signed-off-by: mmigdal <marcin.migdal@nokia.com>
Signed-off-by: Marcin Migdal <marcin.migdal@nokia.com>
4 files changed, 14 insertions, 7 deletions
diff --git a/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java index e142081e..596c6614 100644 --- a/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java +++ b/rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/CloudHttpClient.java @@ -64,10 +64,14 @@ public class CloudHttpClient { } + + + @Deprecated public <T> Mono<T> get(String url, RequestDiagnosticContext context, Class<T> bodyClass) { return get(url, context, Collections.EMPTY_MAP, bodyClass); } + @Deprecated public <T> Mono<T> get(String url, RequestDiagnosticContext context, Map<String, String> customHeaders, Class<T> bodyClass) { final HttpClient clientWithHeaders = getHttpClientWithHeaders(context, customHeaders); diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java index d0f95f6e..b37ac3dc 100644 --- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java +++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java @@ -20,6 +20,7 @@ package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer; +import com.google.gson.JsonArray; import java.net.URI; import java.util.Map; import java.util.Optional; @@ -59,15 +60,15 @@ public class DMaaPConsumerReactiveHttpClient extends DMaaPAbstractReactiveHttpCl * * @return reactive response from DMaaP in string format */ - public Mono<String> getDMaaPConsumerResponse(Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) { + public Mono<JsonArray> getDMaaPConsumerResponse(Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) { Map<String,String> headers = DMaaPClientServiceUtils.getHeaders(consumerConfiguration.dmaapContentType()); if (requestDiagnosticContextOptional.isPresent()) { return cloudHttpClient - .get(getUri().toString(), requestDiagnosticContextOptional.get(), headers, String.class); + .get(getUri().toString(), requestDiagnosticContextOptional.get(), headers, JsonArray.class); } RequestDiagnosticContext requestDiagnosticContext = ImmutableRequestDiagnosticContext.builder() .invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build(); - return cloudHttpClient.get(getUri().toString(), requestDiagnosticContext, headers, String.class); + return cloudHttpClient.get(getUri().toString(), requestDiagnosticContext, headers, JsonArray.class); } URI getUri() { diff --git a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java index d2ca5d12..c37514eb 100644 --- a/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java +++ b/rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClientTest.java @@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consum import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.google.gson.JsonArray; import java.net.URI; import java.util.Optional; import org.apache.http.entity.ContentType; @@ -44,7 +45,7 @@ class DMaaPConsumerReactiveHttpClientTest { private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}"; private DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient; private DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class); - private Mono<String> expectedResult; + private Mono<JsonArray> expectedResult; private CloudHttpClient httpClient = mock(CloudHttpClient.class); private URI exampleTestUri = URI .create("https://54.45.33.2:1234/unauthenticated.SEC_OTHER_OUTPUT/OpenDCAE-c12/c12"); @@ -67,11 +68,11 @@ class DMaaPConsumerReactiveHttpClientTest { @Test void getHttpResponse_Success() { //given - expectedResult = Mono.just(JSON_MESSAGE); - when(httpClient.get(exampleTestUri.toString(), requestDiagnosticContext, DMaaPClientServiceUtils.getHeaders(ContentType.APPLICATION_JSON.getMimeType()), String.class)) + expectedResult = Mono.just(mock(JsonArray.class)); + when(httpClient.get(exampleTestUri.toString(), requestDiagnosticContext, DMaaPClientServiceUtils.getHeaders(ContentType.APPLICATION_JSON.getMimeType()), JsonArray.class)) .thenReturn(expectedResult); //when - Mono<String> response = dmaapConsumerReactiveHttpClient + Mono<JsonArray> response = dmaapConsumerReactiveHttpClient .getDMaaPConsumerResponse(Optional.of(requestDiagnosticContext)); //then StepVerifier.create(response).expectSubscription() diff --git a/rest-services/dmaap-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/rest-services/dmaap-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 00000000..ca6ee9ce --- /dev/null +++ b/rest-services/dmaap-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline
\ No newline at end of file |