From a224b4adbe65b476cdbd74efb3169aacbf292382 Mon Sep 17 00:00:00 2001 From: micdzied Date: Tue, 8 Jan 2019 09:38:12 +0100 Subject: use sdk-cbs Change-Id: I615d57927c163d022683ad3cae2703adda48cf88 Issue-ID: DCAEGEN2-1064 Signed-off-by: micdzied --- .../datafile/configuration/CloudConfiguration.java | 18 ++-- .../configuration/EnvironmentProcessor.java | 4 +- .../collectors/datafile/model/EnvProperties.java | 41 --------- .../service/DatafileConfigurationProvider.java | 102 --------------------- .../collectors/datafile/service/HttpGetClient.java | 91 ------------------ .../datafile/tasks/XnfCollectorTaskImpl.java | 2 - .../service/DatafileConfigurationProviderTest.java | 90 ------------------ .../datafile/service/HttpGetClientTest.java | 75 --------------- 8 files changed, 11 insertions(+), 412 deletions(-) delete mode 100644 datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/EnvProperties.java delete mode 100644 datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProvider.java delete mode 100644 datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClient.java delete mode 100644 datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProviderTest.java delete mode 100644 datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClientTest.java (limited to 'datafile-app-server/src') diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfiguration.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfiguration.java index f7722053..34ccd76c 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfiguration.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfiguration.java @@ -23,13 +23,14 @@ import java.util.Properties; import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration; import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration; -import org.onap.dcaegen2.collectors.datafile.model.EnvProperties; -import org.onap.dcaegen2.collectors.datafile.service.DatafileConfigurationProvider; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.http.configuration.EnvProperties; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.ReactiveCloudConfigurationProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.scheduling.annotation.EnableScheduling; @@ -42,14 +43,13 @@ import reactor.core.scheduler.Schedulers; * @author Henrik Andersson */ @Configuration +@ComponentScan("org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers") @EnableConfigurationProperties @EnableScheduling @Primary -public class CloudConfiguration extends AppConfig { - +public class CloudConfiguration extends AppConfig { private static final Logger logger = LoggerFactory.getLogger(CloudConfiguration.class); - - private DatafileConfigurationProvider datafileConfigurationProvider; + private ReactiveCloudConfigurationProvider reactiveCloudConfigurationProvider; private DmaapPublisherConfiguration dmaapPublisherCloudConfiguration; private DmaapConsumerConfiguration dmaapConsumerCloudConfiguration; private FtpesConfig ftpesCloudConfiguration; @@ -58,8 +58,8 @@ public class CloudConfiguration extends AppConfig { private Properties systemEnvironment; @Autowired - public void setThreadPoolTaskScheduler(DatafileConfigurationProvider datafileConfigurationProvider) { - this.datafileConfigurationProvider = datafileConfigurationProvider; + public void setThreadPoolTaskScheduler(ReactiveCloudConfigurationProvider reactiveCloudConfigurationProvider) { + this.reactiveCloudConfigurationProvider = reactiveCloudConfigurationProvider; } @@ -78,7 +78,7 @@ public class CloudConfiguration extends AppConfig { private void parsingConfigSuccess(EnvProperties envProperties) { logger.info("Fetching Datafile Collector configuration from ConfigBindingService/Consul"); - datafileConfigurationProvider.callForDataFileCollectorConfiguration(envProperties) + reactiveCloudConfigurationProvider.callForServiceConfigurationReactive(envProperties) .subscribe(this::parseCloudConfig, this::cloudConfigError); } diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/EnvironmentProcessor.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/EnvironmentProcessor.java index 9f6b2737..106725ce 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/EnvironmentProcessor.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/EnvironmentProcessor.java @@ -21,8 +21,8 @@ package org.onap.dcaegen2.collectors.datafile.configuration; import java.util.Optional; import java.util.Properties; import org.onap.dcaegen2.collectors.datafile.exceptions.EnvironmentLoaderException; -import org.onap.dcaegen2.collectors.datafile.model.EnvProperties; -import org.onap.dcaegen2.collectors.datafile.model.ImmutableEnvProperties; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.http.configuration.EnvProperties; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.http.configuration.ImmutableEnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/EnvProperties.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/EnvProperties.java deleted file mode 100644 index 86549343..00000000 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/EnvProperties.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import org.immutables.value.Value; - -/** - * @author Przemysław Wąsala on 9/19/18 - */ -@Value.Immutable(prehash = true) -public interface EnvProperties { - - @Value.Parameter - String consulHost(); - - @Value.Parameter - Integer consulPort(); - - @Value.Parameter - String cbsName(); - - @Value.Parameter - String appName(); - -} diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProvider.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProvider.java deleted file mode 100644 index aca87e5b..00000000 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProvider.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.service; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.onap.dcaegen2.collectors.datafile.model.EnvProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; -import org.springframework.web.util.DefaultUriBuilderFactory; -import reactor.core.publisher.Mono; - -/** - * @author Przemysław Wąsala on 9/19/18 - */ -@Service -public class DatafileConfigurationProvider { - - private static final Logger logger = LoggerFactory.getLogger(DatafileConfigurationProvider.class); - - private final HttpGetClient httpGetClient; - - DatafileConfigurationProvider() { - this(new HttpGetClient()); - } - - DatafileConfigurationProvider(HttpGetClient httpGetClient) { - this.httpGetClient = httpGetClient; - } - - public Mono callForDataFileCollectorConfiguration(EnvProperties envProperties) { - return callConsulForConfigBindingServiceEndpoint(envProperties) - .flatMap(this::callConfigBindingServiceForDatafileConfiguration); - } - - private Mono callConsulForConfigBindingServiceEndpoint(EnvProperties envProperties) { - logger.info("Retrieving Config Binding Service endpoint from Consul"); - return httpGetClient.callHttpGet(getConsulUrl(envProperties), JsonArray.class) - .flatMap(jsonArray -> this.createConfigBindingServiceUrl(jsonArray, envProperties.appName())); - - } - - private String getConsulUrl(EnvProperties envProperties) { - return getUri(envProperties.consulHost(), envProperties.consulPort(), "/v1/catalog/service", - envProperties.cbsName()); - } - - private Mono callConfigBindingServiceForDatafileConfiguration(String configBindingServiceUri) { - logger.info("Retrieving Datafile configuration"); - return httpGetClient.callHttpGet(configBindingServiceUri, JsonObject.class); - } - - - private Mono createConfigBindingServiceUrl(JsonArray jsonArray, String appName) { - return getConfigBindingObject(jsonArray) - .flatMap(jsonObject -> buildConfigBindingServiceUrl(jsonObject, appName)); - } - - private Mono buildConfigBindingServiceUrl(JsonObject jsonObject, String appName) { - return Mono.just(getUri(jsonObject.get("ServiceAddress").getAsString(), - jsonObject.get("ServicePort").getAsInt(), "/service_component", appName)); - } - - private Mono getConfigBindingObject(JsonArray jsonArray) { - try { - if (jsonArray.size() > 0) { - return Mono.just(jsonArray.get(0).getAsJsonObject()); - } else { - throw new IllegalStateException("JSON Array was empty"); - } - } catch (IllegalStateException e) { - logger.warn("Failed to retrieve JSON Object from array", e); - return Mono.error(e); - } - } - - private String getUri(String host, Integer port, String... paths) { - return new DefaultUriBuilderFactory().builder() - .scheme("http") - .host(host) - .port(port) - .path(String.join("/", paths)) - .build().toString(); - } -} diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClient.java deleted file mode 100644 index 796dbbd8..00000000 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClient.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.service; - -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.ExchangeFilterFunction; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - - -public class HttpGetClient { - - private static final Logger logger = LoggerFactory.getLogger(HttpGetClient.class); - - private final WebClient webClient; - private final Gson gson; - - HttpGetClient() { - this(WebClient.builder().filter(logRequest()).filter(logResponse()).build()); - } - - HttpGetClient(WebClient webClient) { - this.webClient = webClient; - this.gson = new Gson(); - } - - Mono callHttpGet(String url, Class genericClassDeclaration) { - return webClient - .get() - .uri(url) - .retrieve() - .onStatus(HttpStatus::is4xxClientError, response -> Mono.error(getException(response))) - .onStatus(HttpStatus::is5xxServerError, response -> Mono.error(getException(response))) - .bodyToMono(String.class) - .flatMap(body -> getJsonFromRequest(body, genericClassDeclaration)); - } - - private RuntimeException getException(ClientResponse response) { - return new RuntimeException(String.format("Request for cloud config failed: HTTP %d", - response.statusCode().value())); - } - - private Mono getJsonFromRequest(String body, Class genericClassDeclaration) { - try { - return Mono.just(parseJson(body, genericClassDeclaration)); - } catch (JsonSyntaxException | IllegalStateException e) { - return Mono.error(e); - } - } - - private T parseJson(String body, Class genericClassDeclaration) { - return gson.fromJson(body, genericClassDeclaration); - } - - private static ExchangeFilterFunction logResponse() { - return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> { - logger.info("Response status {}", clientResponse.statusCode()); - return Mono.just(clientResponse); - }); - } - - private static ExchangeFilterFunction logRequest() { - return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> { - logger.info("Request: {} {}", clientRequest.method(), clientRequest.url()); - clientRequest.headers() - .forEach((name, values) -> values.forEach(value -> logger.info("{}={}", name, value))); - return Mono.just(clientRequest); - }); - } -} diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/XnfCollectorTaskImpl.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/XnfCollectorTaskImpl.java index b861653a..c03d903a 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/XnfCollectorTaskImpl.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/XnfCollectorTaskImpl.java @@ -47,10 +47,8 @@ public class XnfCollectorTaskImpl implements XnfCollectorTask { private static final String FTPES = "ftpes"; private static final String FTPS = "ftps"; private static final String SFTP = "sftp"; - private static final Logger logger = LoggerFactory.getLogger(XnfCollectorTaskImpl.class); private Config datafileAppConfig; - private final FtpsClient ftpsClient; private final SftpClient sftpClient; private RetryTimer retryTimer; diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProviderTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProviderTest.java deleted file mode 100644 index efd89837..00000000 --- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DatafileConfigurationProviderTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.service; - - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.collectors.datafile.model.EnvProperties; -import org.onap.dcaegen2.collectors.datafile.model.ImmutableEnvProperties; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -class DatafileConfigurationProviderTest { - private static final Gson gson = new Gson(); - private static final String configBindingService = "[{\"ID\":\"9c8dd674-34ce-7049-d318-e98d93a64303\",\"Node\"" - + ":\"dcae-bootstrap\",\"Address\":\"10.42.52.82\",\"Datacenter\":\"dc1\",\"TaggedAddresses\":" - + "{\"lan\":\"10.42.52.82\",\"wan\":\"10.42.52.82\"},\"NodeMeta\":{\"consul-network-segment\":\"\"}," - + "\"ServiceID\":\"dcae-cbs1\",\"ServiceName\":\"config-binding-service\",\"ServiceTags\":[]," - + "\"ServiceAddress\":\"config-binding-service\",\"ServicePort\":10000,\"ServiceEnableTagOverride\":false," - + "\"CreateIndex\":14352,\"ModifyIndex\":14352},{\"ID\":\"35c6f540-a29c-1a92-23b0-1305bd8c81f5\",\"Node\":" - + "\"dev-consul-server-1\",\"Address\":\"10.42.165.51\",\"Datacenter\":\"dc1\",\"TaggedAddresses\":" - + "{\"lan\":\"10.42.165.51\",\"wan\":\"10.42.165.51\"},\"NodeMeta\":{\"consul-network-segment\":\"\"}," - + "\"ServiceID\":\"dcae-cbs1\",\"ServiceName\":\"config-binding-service\",\"ServiceTags\":[]," - + "\"ServiceAddress\":\"config-binding-service\",\"ServicePort\":10000,\"ServiceEnableTagOverride\":false," - + "\"CreateIndex\":803,\"ModifyIndex\":803}]"; - private static final JsonArray configBindingServiceJson = gson.fromJson(configBindingService, JsonArray.class); - private static final JsonArray emptyConfigBindingServiceJson = gson.fromJson("[]", JsonArray.class); - private static final String datafileCollectorMockConfiguration = "{\"test\":1}"; - private static final JsonObject datafileCollectorMockConfigurationJson = gson.fromJson(datafileCollectorMockConfiguration, JsonObject.class); - - private EnvProperties envProperties = ImmutableEnvProperties.builder() - .appName("dcae-datafile-collector") - .cbsName("config-binding-service") - .consulHost("consul") - .consulPort(8500) - .build(); - - @Test - void shouldReturnDatafileCollectorConfiguration() { - // given - HttpGetClient webClient = mock(HttpGetClient.class); - when( - webClient.callHttpGet("http://consul:8500/v1/catalog/service/config-binding-service", JsonArray.class)) - .thenReturn(Mono.just(configBindingServiceJson)); - when(webClient.callHttpGet("http://config-binding-service:10000/service_component/dcae-datafile-collector", JsonObject.class)) - .thenReturn(Mono.just(datafileCollectorMockConfigurationJson)); - - DatafileConfigurationProvider provider = new DatafileConfigurationProvider(webClient); - - //when/then - StepVerifier.create(provider.callForDataFileCollectorConfiguration(envProperties)).expectSubscription() - .expectNext(datafileCollectorMockConfigurationJson).verifyComplete(); - } - - @Test - void shouldReturnMonoErrorWhenConsuleDoesntHaveConfigBindingServiceEntry() { - // given - HttpGetClient webClient = mock(HttpGetClient.class); - when( - webClient.callHttpGet("http://consul:8500/v1/catalog/service/config-binding-service", JsonArray.class)) - .thenReturn(Mono.just(emptyConfigBindingServiceJson)); - - DatafileConfigurationProvider provider = new DatafileConfigurationProvider(webClient); - - //when/then - StepVerifier.create(provider.callForDataFileCollectorConfiguration(envProperties)).expectSubscription() - .expectError(IllegalStateException.class).verify(); - } -} \ No newline at end of file diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClientTest.java deleted file mode 100644 index d95e3417..00000000 --- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/HttpGetClientTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.service; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; -import org.junit.jupiter.api.Test; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -class HttpGetClientTest { - - private static final String SOMEURL = "http://someurl"; - private static final String DATA = "{}"; - private Gson gson = new Gson(); - private WebClient webClient = mock(WebClient.class); - private WebClient.RequestHeadersUriSpec requestBodyUriSpec = mock(WebClient.RequestBodyUriSpec.class); - private WebClient.ResponseSpec responseSpec = mock(WebClient.ResponseSpec.class); - - @Test - void shouldReturnJsonObjectOnGetCall() { - //given - mockWebClientDependantObject(); - HttpGetClient httpGetClient = new HttpGetClient(webClient); - when(responseSpec.bodyToMono(String.class)).thenReturn(Mono.just(DATA)); - - //when/then - StepVerifier.create(httpGetClient.callHttpGet(SOMEURL, JsonObject.class)).expectSubscription() - .expectNext(gson.fromJson(DATA, JsonObject.class)).verifyComplete(); - } - - @Test - void shouldReturnMonoErrorOnGetCall() { - //given - mockWebClientDependantObject(); - HttpGetClient httpGetClient = new HttpGetClient(webClient); - when(responseSpec.bodyToMono(String.class)).thenReturn(Mono.just("some wrong data")); - - //when/then - StepVerifier.create(httpGetClient.callHttpGet(SOMEURL, JsonObject.class)).expectSubscription() - .expectError(JsonSyntaxException.class).verify(); - } - - - private void mockWebClientDependantObject() { - doReturn(requestBodyUriSpec).when(webClient).get(); - when(requestBodyUriSpec.uri(SOMEURL)).thenReturn(requestBodyUriSpec); - doReturn(responseSpec).when(requestBodyUriSpec).retrieve(); - doReturn(responseSpec).when(responseSpec).onStatus(any(), any()); - doReturn(responseSpec).when(responseSpec).onStatus(any(), any()); - } -} \ No newline at end of file -- cgit 1.2.3-korg