From 373aa4076b59a63eae8440a338e2836902e9ebe4 Mon Sep 17 00:00:00 2001 From: Piotr Marcinkiewicz Date: Tue, 24 Aug 2021 11:20:54 +0200 Subject: Update DCAE SDK library Issue-ID: DCAEGEN2-2719 Signed-off-by: Piotr Marcinkiewicz Change-Id: If4086ddf60747b4d87c5067a68df748a7dc2c689 --- .../dcae/ApplicationConfigurationListenerTest.java | 4 ++-- .../configuration/CbsConfigurationHandlerTest.java | 23 +++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/test') 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(); } -- cgit 1.2.3-korg