summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-06-17 10:18:23 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-06-24 12:43:55 +0200
commitc3b98731e966a4ace2198ce5e4aa4fc324036e81 (patch)
tree5e3d4197b8b7c4bc9e9c1fcf7c92c7f86bc76907 /prh-app-server/src/test/java
parent5763275d59e628eabcc08eae2aa1d32120d4c072 (diff)
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 <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src/test/java')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/bootstrap/CbsClientConfigurationResolverTest.java32
1 files 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