diff options
Diffstat (limited to 'sdc-distribution-ci')
-rw-r--r-- | sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java | 7 | ||||
-rw-r--r-- | sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java | 39 |
2 files changed, 38 insertions, 8 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java index 64e6a6f..72b47d7 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java @@ -50,4 +50,11 @@ public class ClientInitializer { log.info(SEPARATOR); } + public void stop() { + IDistributionClientResult stopResult = client.stop(); + log.info(SEPARATOR); + log.info(stopResult.getDistributionMessageResult()); + log.info(SEPARATOR); + } + } diff --git a/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java index e4c2241..40278b1 100644 --- a/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java +++ b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java @@ -19,6 +19,7 @@ */ package org.onap.test.core.service; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; @@ -42,28 +43,37 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) class ClientInitializerTest { + private static final int SUCCESSFUL_STOP_MSG_INDEX = 2; + private static final int SUCCESSFUL_UNREGISTER_MSG_INDEX = 3; + private static final int SUCCESSFUL_INIT_MSG_INDEX = 0; + private static final int SUCCESSFUL_DIST_MSG_INDEX = 3; + private ClientInitializer clientInitializer; - public static final int SUCCESSFUL_INIT_MSG_INDEX = 0; - public static final int SUCCESSFUL_DIST_MSG_INDEX = 3; @Container public GenericContainer mockDmaap = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap:latest") .withNetworkMode("host"); @Container public GenericContainer mockSdc = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:latest") - .dependsOn(mockDmaap) .withNetworkMode("host"); @Mock Logger log; - @Test - public void shouldRegisterToDmaapAfterClientInitialization() { - //given + @Mock + Logger distClientLog; + + @BeforeEach + public void initializeClient() { DistributionClientConfig clientConfig = new DistributionClientConfig(); List<ArtifactsValidator> validators = new ArrayList<>(); - DistributionClientImpl client = new DistributionClientImpl(); + DistributionClientImpl client = new DistributionClientImpl(distClientLog); ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); - ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + clientInitializer = new ClientInitializer(clientConfig, callback, client); + } + + @Test + public void shouldRegisterToDmaapAfterClientInitialization() { + //given final ArgumentCaptor<String> exceptionCaptor = ArgumentCaptor.forClass(String.class); //when clientInitializer.log = log; @@ -75,4 +85,17 @@ class ClientInitializerTest { assertThat(allValues.get(SUCCESSFUL_DIST_MSG_INDEX)).isEqualTo("distribution client started successfuly"); } + @Test + public void shouldUnregisterAndStopClient() { + //given + final ArgumentCaptor<String> exceptionCaptor = ArgumentCaptor.forClass(String.class); + //when + clientInitializer.initialize(); + clientInitializer.stop(); + verify(distClientLog, Mockito.atLeastOnce()).info(exceptionCaptor.capture()); + List<String> allValues = exceptionCaptor.getAllValues(); + //then + assertThat(allValues.get(SUCCESSFUL_STOP_MSG_INDEX)).isEqualTo("stop DistributionClient"); + assertThat(allValues.get(SUCCESSFUL_UNREGISTER_MSG_INDEX)).isEqualTo("client unregistered from topics successfully"); + } }
\ No newline at end of file |