From c3b98731e966a4ace2198ce5e4aa4fc324036e81 Mon Sep 17 00:00:00 2001 From: grabinsk Date: Mon, 17 Jun 2019 10:18:23 +0200 Subject: Replace mocks with real object usage in test CbsClientConfigurationResolver test This adds test coverage missing from CbsProperties.toCbsClientConfiguration() method Change-Id: I2da6f4b4392dbace4a8a827406a9b485f9cbfa79 Issue-ID: DCAEGEN2-1544 Signed-off-by: grabinsk --- .../CbsClientConfigurationResolverTest.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/bootstrap/CbsClientConfigurationResolverTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/bootstrap/CbsClientConfigurationResolverTest.java index 2f871618..87dd18ca 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/bootstrap/CbsClientConfigurationResolverTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/bootstrap/CbsClientConfigurationResolverTest.java @@ -20,32 +20,32 @@ package org.onap.dcaegen2.services.bootstrap; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.*; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.mockito.Mockito.when; +import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(MockitoExtension.class) class CbsClientConfigurationResolverTest { - @Mock private CbsProperties cbsProperties; - @Mock - private CbsClientConfiguration defaultCbsClientConfigFromSpringProps; + + @BeforeEach + void setUp() { + cbsProperties = new CbsProperties(); + cbsProperties.setHostname("some-cbs-host"); + cbsProperties.setPort(123); + cbsProperties.setAppName("client-app-name"); + } @Test @DisabledIfEnvironmentVariable(named = "CONFIG_BINDING_SERVICE", matches = ".+") - void whenCbsEnvPropertiesAreNotePresentInEnvironment_ShouldFallbackToLoadingDefaults() { - when(cbsProperties.toCbsClientConfiguration()).thenReturn(defaultCbsClientConfigFromSpringProps); - CbsClientConfigurationResolver cbsClientConfigurationResolver = new CbsClientConfigurationResolver(cbsProperties); - - CbsClientConfiguration config = cbsClientConfigurationResolver.resolveCbsClientConfiguration(); + void whenCbsEnvPropertiesAreNotePresentInEnvironment_ShouldFallbackToLoadingDefaultsFromCbsProperties() { + CbsClientConfiguration config = new CbsClientConfigurationResolver(cbsProperties).resolveCbsClientConfiguration(); - assertSame(defaultCbsClientConfigFromSpringProps, config); + assertThat(config.hostname()).isEqualTo(cbsProperties.getHostname()); + assertThat(config.port()).isEqualTo(cbsProperties.getPort()); + assertThat(config.appName()).isEqualTo(cbsProperties.getAppName()); } } \ No newline at end of file -- cgit 1.2.3-korg