diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2020-09-24 16:26:32 +0200 |
---|---|---|
committer | Adam Wudzinski <adam.wudzinski@nokia.com> | 2020-09-24 16:40:38 +0200 |
commit | 033f66b29c24b8819acefcdb38a9d9376bc0a2ba (patch) | |
tree | 98fb3075862f06a86240b2c09334dec3d98aa9a7 /src/test/java/org | |
parent | d02143c0c616a32dcc095877fea5c87c05e4adab (diff) |
Fix VES problem with subsequent fetching from CBS1.7.6
Issue-ID: DCAEGEN2-2453
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
Change-Id: If6aa6bc79b460d06908022fb4eb6cfbf096a8eb8
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java b/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java index b413a64d..6f729997 100644 --- a/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java +++ b/src/test/java/org/onap/dcae/configuration/cbs/CbsConfigResolverTest.java @@ -24,6 +24,8 @@ import org.json.JSONObject; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration; @@ -34,6 +36,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class CbsConfigResolverTest { @@ -47,20 +50,20 @@ public class CbsConfigResolverTest { public final WireMockRule wireMockRule = new WireMockRule( wireMockConfig().dynamicPort().dynamicPort()); + @Mock + private CbsClientConfigurationResolver cbsClientConfigurationResolver; + + @InjectMocks + private CbsConfigResolver cbsConfigResolver; + @Test public void shouldFetchConfigurationFromCBS() { // given - final int PORT = wireMockRule.port(); stubCBSToReturnAppConfig(); + mockCbsClientConfiguration(); // when - CbsClientConfiguration cbsClientConfiguration = ImmutableCbsClientConfiguration.builder() - .protocol(PROTOCOL) - .hostname(HOSTNAME) - .port(PORT) - .appName(APP_NAME) - .build(); - JSONObject appConfig = new CbsConfigResolver(cbsClientConfiguration).getAppConfig().get(); + JSONObject appConfig = cbsConfigResolver.getAppConfig().get(); // then assertThat(appConfig).isNotNull(); @@ -69,6 +72,17 @@ public class CbsConfigResolverTest { private void stubCBSToReturnAppConfig() { stubFor(get(urlEqualTo("/service_component/VESCollector")) - .willReturn(aResponse().withBody(CbsConfigResolverTest.VES_CONFIG))); + .willReturn(aResponse().withBody(CbsConfigResolverTest.VES_CONFIG))); + } + + private void mockCbsClientConfiguration() { + final int PORT = wireMockRule.port(); + CbsClientConfiguration cbsClientConfiguration = ImmutableCbsClientConfiguration.builder() + .protocol(PROTOCOL) + .hostname(HOSTNAME) + .port(PORT) + .appName(APP_NAME) + .build(); + when(cbsClientConfigurationResolver.resolveCbsClientConfiguration()).thenReturn(cbsClientConfiguration); } }
\ No newline at end of file |