From 373aa4076b59a63eae8440a338e2836902e9ebe4 Mon Sep 17 00:00:00 2001 From: Piotr Marcinkiewicz Date: Tue, 24 Aug 2021 11:20:54 +0200 Subject: [PATCH] Update DCAE SDK library Issue-ID: DCAEGEN2-2719 Signed-off-by: Piotr Marcinkiewicz Change-Id: If4086ddf60747b4d87c5067a68df748a7dc2c689 --- Changelog.md | 3 + README.md | 13 +- pom.xml | 951 ++++++++++----------- .../dcae/ApplicationConfigurationListener.java | 22 +- src/main/java/org/onap/dcae/VesApplication.java | 6 +- .../dcae/configuration/ConfigurationHandler.java | 20 +- .../dcae/ApplicationConfigurationListenerTest.java | 4 +- .../configuration/CbsConfigurationHandlerTest.java | 23 +- version.properties | 2 +- 9 files changed, 524 insertions(+), 520 deletions(-) diff --git a/Changelog.md b/Changelog.md index 6e107d7e..1a0c7d2f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -61,3 +61,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - sending event for many topics at once is no longer supported - add backward compatibility status codes - add additional validation for batchEvent +## [1.10.1] - 24/08/2021 + - [DCAEGEN2-1483](https://jira.onap.org/browse/DCAEGEN2-2719) - CBS-Client supporting configMap + - update CBS-Client from 1.8.0 to 1.8.7 in order to enable config file support diff --git a/README.md b/README.md index 407fc7ad..94571b17 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Variables set manually / coming from deployment system: - CONFIG_BINDING_SERVICE - should be a name of CBS - CONFIG_BINDING_SERVICE_SERVICE_PORT - should be an http port of CBS - HOSTNAME - should be a name of VESCollector application as it is registered in CBS catalog +- CBS_CLIENT_CONFIG_PATH - (optional) should contain path to application config file. ### Docker file system layout The main directory where all code resides in docker container @@ -143,14 +144,16 @@ For testing purpose, the docker image includes preset configuration which can be -### Consul - Dynamic configuration +### Dynamic configuration -Application properties like /etc/collector.properties and Dmaap configuration /etc/DmaapConfig.json are updated frequently by configuration stored in Consul(CBS) +Application properties like /etc/collector.properties and Dmaap configuration /etc/DmaapConfig.json are updated frequently by configuration stored in config file or if it doesn't exist, in Consul (CBS) http://:30270/ui/#/dc1/kv/ -Configuration stored in Consul have bigger priority and always will override local configuration so all configuration modification should be done using Consul update on corresponding kv store. -Frequently how often configuration will be fetch from Consul server is manageable in /etc/collector.properties property "collector.dynamic.config.update.frequency={time in minutes}". -To fetch configuration from Consul, VES collector uses CBS client from DCAE SDK. +By default, config file is located in /app-config/application_config.yaml and this path can be changed by CBS_CLIENT_CONFIG_PATH env. +Configuration stored in config file has the biggest priority and always will override local configuration. +If config file doesn't exist then configuration will be fetched from Consul server. +Frequently how often configuration will be dynamically fetched is manageable in /etc/collector.properties property "collector.dynamic.config.update.frequency={time in minutes}". +To fetch configuration, VES collector uses CBS client from DCAE SDK. Sample configuration of VESCollector K-V store can be found under /dpo/data-formats/ConsulConfig.json diff --git a/pom.xml b/pom.xml index b0fe6788..ac8601fc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,476 +1,475 @@ - - - - 4.0.0 - - org.onap.oparent - oparent - 3.2.0 - - - org.onap.dcaegen2.collectors.ves - VESCollector - 1.10.0-SNAPSHOT - dcaegen2-collectors-ves - VESCollector - - - UTF-8 - UTF-8 - 11 - onap/org.onap.dcaegen2.collectors.ves.vescollector - - true - - false - - https://nexus.onap.org - content/repositories/snapshots/ - content/repositories/releases/ - content/sites/site/org/onap/dcaegen2/collectors/ves/${project.artifactId}/${project.version} - yyyyMMdd'T'HHmmss - nexus3.onap.org:10003 - ${java.version} - ${java.version} - - ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml - - - 1.6.5 - 2.4.3 - 3.1.0 - 3.0.1 - 2.9 - 3.0.0-M1 - 1.2.0 - 1.1.1 - 1.0.49 - 2.8.6 - 20210307 - 1.4.9 - 3.2.2 - 1.10 - 0.10.3 - 2.4.3 - 3.0.0 - 3.19.0 - 2.2.13.RELEASE - 1.8.0 - 30.1-jre - 5.11.1 - 1.8.6 - 3.4.0 - 1.15.1 - 1.15.1 - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-assembly-plugin - ${maven-assembly-plugin.version} - - - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - - maven-project-info-reports-plugin - ${maven-project-info-reports-plugin.version} - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - true - - - - - com.spotify - docker-maven-plugin - ${docker-maven-plugin.version} - - - org.apache.maven.plugins - maven-enforcer-plugin - - true - - - - - - - maven-assembly-plugin - - - src/assembly/dep.xml - - false - false - true - - - - make-assembly - package - - single - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - maven-javadoc-plugin - - true - false - false - - - - aggregate - site - - aggregate - - - - attach-javadoc - - jar - - - - - - com.spotify - docker-maven-plugin - - ${onap.nexus.dockerregistry.daily} - ${onap.nexus.dockerregistry.daily}/${docker.image.name} - - ${project.version}-${maven.build.timestamp}Z - ${project.version} - latest - - openjdk:11-jre-slim - vescollector - - /etc/host.aliases - - /opt/app/VESCollector - - - . - ${project.build.directory}/${project.artifactId}-${project.version} - - - - useradd -r -U vescollector - chown -R vescollector:vescollector /opt/app - mkdir /opt/app/VESCollector/logs - chown -R vescollector:vescollector /opt/app/VESCollector/logs - chown -R vescollector:vescollector /opt/app/VESCollector/etc - - chmod +x bin/*.sh - - - - - 8080 - 8443 - - bin/docker-entry.sh - - - - - - - buildForPerfTests - - false - - - - - org.springframework.boot - spring-boot-starter-actuator - ${spring.version} - - - io.micrometer - micrometer-registry-prometheus - ${micrometer.version} - - - io.micrometer - micrometer-core - ${micrometer.version} - - - - - with-system-proxy - - - - com.spotify - docker-maven-plugin - - - ${env.http_proxy} - - - - - - - - - - - maven-project-info-reports-plugin - - - - dependencies - license - - - - - - maven-javadoc-plugin - - false - org.umlgraph.doclet.UmlGraphDoc - - org.umlgraph - umlgraph - 5.6 - - -views - true - - - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.version} - pom - import - - - - - - - com.networknt - json-schema-validator - ${json-schema-validator.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - - com.google.code.gson - gson - ${gson.version} - - - org.json - json - ${json.version} - - - com.google.guava - guava - ${guava.version} - - - - org.onap.dcaegen2.services.sdk.rest.services - dmaap-client - ${dmaap-client.version} - - - ch.qos.logback - logback-classic - - - - - io.projectreactor - reactor-test - ${reactor-test.version} - test - - - org.testcontainers - testcontainers - ${testcontainers.version} - - - org.testcontainers - junit-jupiter - ${junit-jupiter.version} - - - com.mashape.unirest - unirest-java - ${unirest-java.version} - - - - commons-collections - commons-collections - ${commons-collections.version} - - - commons-configuration - commons-configuration - ${commons-configuration.version} - - - io.vavr - vavr - ${vavr.version} - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - ${spring-boot-starter-log4j2.version} - - - io.springfox - springfox-swagger2 - ${springfox-swagger2.version} - - - io.springfox - springfox-swagger-ui - ${springfox-swagger2.version} - compile - - - org.mock-server - mockserver-junit-jupiter - ${mock-server.version} - test - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - org.springframework.boot - spring-boot-starter-test - ${spring-boot-starter-test.version} - test - - - com.vaadin.external.google - android-json - - - - - org.onap.dcaegen2.services.sdk.security.crypt - crypt-password - slim - ${sdk.version} - - - org.onap.dcaegen2.services.sdk - dcaegen2-services-sdk-services-external-schema-manager - ${sdk.version} - - - org.springframework.security - spring-security-crypto - - - org.onap.dcaegen2.services.sdk.standardization - api-custom-header - ${sdk.version} - - - org.onap.dcaegen2.services.sdk.rest.services - cbs-client - ${sdk.version} - - - - - external-repository - https://oss.sonatype.org/content/repositories - - - - - - JCenter - JCenter Repository - http://jcenter.bintray.com - - - Restlet - Restlet Repository - http://maven.restlet.com - - - + + + + 4.0.0 + + org.onap.oparent + oparent + 3.2.0 + + + org.onap.dcaegen2.collectors.ves + VESCollector + 1.10.1-SNAPSHOT + dcaegen2-collectors-ves + VESCollector + + + UTF-8 + UTF-8 + 11 + onap/org.onap.dcaegen2.collectors.ves.vescollector + + true + + false + + https://nexus.onap.org + content/repositories/snapshots/ + content/repositories/releases/ + content/sites/site/org/onap/dcaegen2/collectors/ves/${project.artifactId}/${project.version} + yyyyMMdd'T'HHmmss + nexus3.onap.org:10003 + ${java.version} + ${java.version} + + ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml + + + 1.6.5 + 2.4.3 + 3.1.0 + 3.0.1 + 2.9 + 3.0.0-M1 + 1.2.0 + 1.1.1 + 1.0.49 + 2.8.6 + 20210307 + 1.4.9 + 3.2.2 + 1.10 + 0.10.3 + 2.4.3 + 3.0.0 + 3.19.0 + 2.2.13.RELEASE + 1.8.7 + 30.1-jre + 5.11.1 + 3.4.0 + 1.15.1 + 1.15.1 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + maven-project-info-reports-plugin + ${maven-project-info-reports-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + true + + + + + com.spotify + docker-maven-plugin + ${docker-maven-plugin.version} + + + org.apache.maven.plugins + maven-enforcer-plugin + + true + + + + + + + maven-assembly-plugin + + + src/assembly/dep.xml + + false + false + true + + + + make-assembly + package + + single + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + maven-javadoc-plugin + + true + false + false + + + + aggregate + site + + aggregate + + + + attach-javadoc + + jar + + + + + + com.spotify + docker-maven-plugin + + ${onap.nexus.dockerregistry.daily} + ${onap.nexus.dockerregistry.daily}/${docker.image.name} + + ${project.version}-${maven.build.timestamp}Z + ${project.version} + latest + + openjdk:11-jre-slim + vescollector + + /etc/host.aliases + + /opt/app/VESCollector + + + . + ${project.build.directory}/${project.artifactId}-${project.version} + + + + useradd -r -U vescollector + chown -R vescollector:vescollector /opt/app + mkdir /opt/app/VESCollector/logs + chown -R vescollector:vescollector /opt/app/VESCollector/logs + chown -R vescollector:vescollector /opt/app/VESCollector/etc + + chmod +x bin/*.sh + + + + + 8080 + 8443 + + bin/docker-entry.sh + + + + + + + buildForPerfTests + + false + + + + + org.springframework.boot + spring-boot-starter-actuator + ${spring.version} + + + io.micrometer + micrometer-registry-prometheus + ${micrometer.version} + + + io.micrometer + micrometer-core + ${micrometer.version} + + + + + with-system-proxy + + + + com.spotify + docker-maven-plugin + + + ${env.http_proxy} + + + + + + + + + + + maven-project-info-reports-plugin + + + + dependencies + license + + + + + + maven-javadoc-plugin + + false + org.umlgraph.doclet.UmlGraphDoc + + org.umlgraph + umlgraph + 5.6 + + -views + true + + + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.version} + pom + import + + + + + + + com.networknt + json-schema-validator + ${json-schema-validator.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + com.google.code.gson + gson + ${gson.version} + + + org.json + json + ${json.version} + + + com.google.guava + guava + ${guava.version} + + + + org.onap.dcaegen2.services.sdk.rest.services + dmaap-client + ${sdk.version} + + + ch.qos.logback + logback-classic + + + + + io.projectreactor + reactor-test + ${reactor-test.version} + test + + + org.testcontainers + testcontainers + ${testcontainers.version} + + + org.testcontainers + junit-jupiter + ${junit-jupiter.version} + + + com.mashape.unirest + unirest-java + ${unirest-java.version} + + + + commons-collections + commons-collections + ${commons-collections.version} + + + commons-configuration + commons-configuration + ${commons-configuration.version} + + + io.vavr + vavr + ${vavr.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + ${spring-boot-starter-log4j2.version} + + + io.springfox + springfox-swagger2 + ${springfox-swagger2.version} + + + io.springfox + springfox-swagger-ui + ${springfox-swagger2.version} + compile + + + org.mock-server + mockserver-junit-jupiter + ${mock-server.version} + test + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot-starter-test.version} + test + + + com.vaadin.external.google + android-json + + + + + org.onap.dcaegen2.services.sdk.security.crypt + crypt-password + slim + ${sdk.version} + + + org.onap.dcaegen2.services.sdk + dcaegen2-services-sdk-services-external-schema-manager + ${sdk.version} + + + org.springframework.security + spring-security-crypto + + + org.onap.dcaegen2.services.sdk.standardization + api-custom-header + ${sdk.version} + + + org.onap.dcaegen2.services.sdk.rest.services + cbs-client + ${sdk.version} + + + + + external-repository + https://oss.sonatype.org/content/repositories + + + + + + JCenter + JCenter Repository + http://jcenter.bintray.com + + + Restlet + Restlet Repository + http://maven.restlet.com + + + diff --git a/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java b/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java index b86bc1ec..c847cddc 100644 --- a/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java +++ b/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. 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. @@ -29,7 +29,7 @@ import reactor.core.Disposable; import java.time.Duration; /** - * ApplicationConfigurationListener is used to listen at notifications with configuration updates send from Consul. + * ApplicationConfigurationListener is used to listen at notifications with configuration updates. */ public class ApplicationConfigurationListener implements Runnable { @@ -42,7 +42,7 @@ public class ApplicationConfigurationListener implements Runnable { /** * Constructor * @param interval defines period of time when notification can come - * @param configurationHandler handles notifications send by Consul + * @param configurationHandler handles notifications */ public ApplicationConfigurationListener(Duration interval, ConfigurationHandler configurationHandler) { this.interval = interval; @@ -50,7 +50,7 @@ public class ApplicationConfigurationListener implements Runnable { } /** - * Reload listener to start listening for Consul notifications with defined interval. + * Reload listener to start listening for configurations notifications with defined interval. * @param interval defines period of time when notification can come */ public synchronized void reload(Duration interval) { @@ -64,23 +64,23 @@ public class ApplicationConfigurationListener implements Runnable { } /** - * Start listening for Consul notification. + * Start listening for configurations notification. */ @Override public void run() { - Disposable consulListener = null; + Disposable configListener = null; do { try { - consulListener = listenForConfigurationUpdates(); + configListener = listenForConfigurationUpdates(); synchronized (this) { - log.info("Switch to configuration handler thread. Active waiting for configuration from Consul."); + log.info("Switch to configuration handler thread. Active waiting for configuration."); this.wait(); } } catch (Exception e) { - log.error("Unexpected error occurred during handling data from Consul.", e); + log.error("Unexpected error occurred during handling data.", e); terminate(); } finally { - stopListeningForConfigurationUpdates(consulListener); + stopListeningForConfigurationUpdates(configListener); } } while (!this.terminate); } @@ -95,7 +95,7 @@ public class ApplicationConfigurationListener implements Runnable { /** * Release resources when there is a need to stop listener - * @param consulListener Handler to Consul listener + * @param consulListener Handler to configurations listener */ void stopListeningForConfigurationUpdates(Disposable consulListener) { if (consulListener != null) { diff --git a/src/main/java/org/onap/dcae/VesApplication.java b/src/main/java/org/onap/dcae/VesApplication.java index f8cd74ad..75fd4594 100644 --- a/src/main/java/org/onap/dcae/VesApplication.java +++ b/src/main/java/org/onap/dcae/VesApplication.java @@ -3,7 +3,7 @@ * PROJECT * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. 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. @@ -66,7 +66,7 @@ public class VesApplication { applicationLock.lock(); try { startApplication(args); - startListeningForApplicationConfigurationStoredInConsul(); + startListeningForApplicationConfiguration(); } finally { applicationLock.unlock(); } @@ -110,7 +110,7 @@ public class VesApplication { context = SpringApplication.run(VesApplication.class); } - private static void startListeningForApplicationConfigurationStoredInConsul() { + private static void startListeningForApplicationConfiguration() { ConfigurationHandler cbsHandler = new ConfigurationHandler(new CbsClientConfigurationProvider(), configUpdater); ApplicationConfigurationListener applicationConfigProvider = new ApplicationConfigurationListener(Duration.ofMinutes(DEFAULT_CONFIGURATION_FETCH_PERIOD), cbsHandler); diff --git a/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java b/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java index ebdf0474..aa3561b6 100644 --- a/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java +++ b/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved.s + * Copyright (C) 2020-2021 Nokia. All rights reserved.s * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ import reactor.core.publisher.Mono; import java.time.Duration; /** - * ConfigurationHandler is responsible for receiving configuration updates from Consul. - * Any change made in the Consul will be reported as a notification. + * ConfigurationHandler is responsible for receiving configuration updates from config file or Consul (if config file doesn't exist). + * Any change made in the configuration will be reported as a notification. */ public class ConfigurationHandler { @@ -61,12 +61,12 @@ public class ConfigurationHandler { /** * Start listen for application configuration notifications with configuration changes * @param interval defines period of time when notification can come - * @return {@link Disposable} handler to close Consul listener at the end + * @return {@link Disposable} handler to close configuration listener at the end */ public Disposable startListen(Duration interval) { - log.info("Start listening for configuration from Consul ..."); - log.info(String.format("Consul configuration will be fetched in %s period.", interval)); + log.info("Start listening for configuration ..."); + log.info(String.format("Configuration will be fetched in %s period.", interval)); // Polling properties final Duration initialDelay = Duration.ofSeconds(5); @@ -78,7 +78,7 @@ public class ConfigurationHandler { return createCbsClient(cbsClientConfiguration) .flatMapMany(cbsClient -> cbsClient.updates(request, initialDelay, period)) .subscribe( - this::handleConfigurationFromConsul, + this::handleConfiguration, this::handleError ); } @@ -87,8 +87,8 @@ public class ConfigurationHandler { return CbsClientFactory.createCbsClient(cbsClientConfiguration); } - void handleConfigurationFromConsul(JsonObject jsonObject) { - log.info("Configuration update from Consul {}", jsonObject); + void handleConfiguration(JsonObject jsonObject) { + log.info("Configuration update {}", jsonObject); if(jsonObject.has(CONFIG_DICT)) { JsonObject config = jsonObject.getAsJsonObject(CONFIG_DICT); JSONObject jObject = new JSONObject(config.toString()); @@ -99,7 +99,7 @@ public class ConfigurationHandler { } private void handleError(Throwable throwable) { - log.error("Unexpected error occurred during fetching configuration from Consul", throwable); + log.error("Unexpected error occurred during fetching configuration", throwable); } private CbsRequest createCbsRequest() { diff --git a/src/test/java/org/onap/dcae/ApplicationConfigurationListenerTest.java b/src/test/java/org/onap/dcae/ApplicationConfigurationListenerTest.java index 49132f1e..1aa54257 100644 --- a/src/test/java/org/onap/dcae/ApplicationConfigurationListenerTest.java +++ b/src/test/java/org/onap/dcae/ApplicationConfigurationListenerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. 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. @@ -43,7 +43,7 @@ public class ApplicationConfigurationListenerTest { private ApplicationConfigurationListener applicationConfigurationListener; @Test - public void shouldStopJobAndCloseConnectionWhenErrorOccurredDuringListenAtConsulChange() { + public void shouldStopJobAndCloseConnectionWhenErrorOccurredDuringListenAtConfigChange() { // given Mockito.doThrow(new RuntimeException("Simulate exception")).when(configurationHandler).startListen(any()); diff --git a/src/test/java/org/onap/dcae/configuration/CbsConfigurationHandlerTest.java b/src/test/java/org/onap/dcae/configuration/CbsConfigurationHandlerTest.java index 7b1af1de..8ad1dd0a 100644 --- a/src/test/java/org/onap/dcae/configuration/CbsConfigurationHandlerTest.java +++ b/src/test/java/org/onap/dcae/configuration/CbsConfigurationHandlerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved.s + * Copyright (C) 2020-2021 Nokia. All rights reserved.s * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,9 +41,9 @@ import java.time.Duration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class CbsConfigurationHandlerTest { @@ -67,9 +67,8 @@ public class CbsConfigurationHandlerTest { @Test public void shouldCreateCbsConfigurationHandler() { // given - - when(cbsConfigurationHandler.createCbsClient(cbsClientConfiguration)).thenReturn(cbsClient); - when(cbsClientConfigurationProvider.get()).thenReturn(cbsClientConfiguration); + doReturn(cbsClient).when(cbsConfigurationHandler).createCbsClient(cbsClientConfiguration); + doReturn(cbsClientConfiguration).when(cbsClientConfigurationProvider).get(); // when final Disposable handler = cbsConfigurationHandler.startListen(Duration.ofMinutes(5)); @@ -81,10 +80,10 @@ public class CbsConfigurationHandlerTest { @Test public void shouldUpdateAppConfigurationWhenConfigurationIsValid() { // given - final JsonObject configuration = createConsulConfiguration(VES_CONSUL_CONFIG); + final JsonObject configuration = createConfiguration(VES_CONSUL_CONFIG); // when - this.cbsConfigurationHandler.handleConfigurationFromConsul(configuration); + this.cbsConfigurationHandler.handleConfiguration(configuration); // then final ArgumentCaptor> acConfiguration = ArgumentCaptor.forClass(Option.class); @@ -93,12 +92,12 @@ public class CbsConfigurationHandlerTest { } @Test - public void shouldReportAnErrorWhenConsulReturnsEmptyConfiguration() { + public void shouldReportAnErrorWhenConfigHandlerReturnsEmptyConfiguration() { // given - final JsonObject configuration = createConsulConfiguration("{}"); + final JsonObject configuration = createConfiguration("{}"); // when - assertThatThrownBy(() -> this.cbsConfigurationHandler.handleConfigurationFromConsul(configuration)) + assertThatThrownBy(() -> this.cbsConfigurationHandler.handleConfiguration(configuration)) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining(String.format("Invalid application configuration: %s ", "{}")); // then @@ -109,8 +108,8 @@ public class CbsConfigurationHandlerTest { return new JSONObject(vesConfig).toString(); } - private JsonObject createConsulConfiguration(String vesConsulConfig) { - return new JsonParser().parse(vesConsulConfig).getAsJsonObject(); + private JsonObject createConfiguration(String vesConfig) { + return new JsonParser().parse(vesConfig).getAsJsonObject(); } diff --git a/version.properties b/version.properties index e9e55960..81b72c03 100644 --- a/version.properties +++ b/version.properties @@ -1,6 +1,6 @@ major=1 minor=10 -patch=0 +patch=1 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- 2.16.6