diff options
author | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-12-15 13:45:37 +0100 |
---|---|---|
committer | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-12-17 12:04:05 +0100 |
commit | 26c6238bd7e5a48363b86122b9b40f013ed29f1a (patch) | |
tree | 329736e49b1fca0f9dd54dcc36f5b30f626c3186 /sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java | |
parent | 64079b27bdfff509fe610b1d46e09bdf1e43e4c6 (diff) |
Remove old content of CI project and create integration tests
Issue-ID: SDC-3400
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: I1b46858cfae199aefcdeb8dfc14a33f50f4da7d6
Diffstat (limited to 'sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java')
-rw-r--r-- | sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java | 78 |
1 files changed, 78 insertions, 0 deletions
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 new file mode 100644 index 0000000..e4c2241 --- /dev/null +++ b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.test.core.service; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verify; + +@Testcontainers +@ExtendWith(MockitoExtension.class) +class ClientInitializerTest { + + + 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 + DistributionClientConfig clientConfig = new DistributionClientConfig(); + List<ArtifactsValidator> validators = new ArrayList<>(); + DistributionClientImpl client = new DistributionClientImpl(); + ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); + ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + final ArgumentCaptor<String> exceptionCaptor = ArgumentCaptor.forClass(String.class); + //when + clientInitializer.log = log; + clientInitializer.initialize(); + verify(log, Mockito.atLeastOnce()).info(exceptionCaptor.capture()); + List<String> allValues = exceptionCaptor.getAllValues(); + //then + assertThat(allValues.get(SUCCESSFUL_INIT_MSG_INDEX)).isEqualTo("distribution client initialized successfuly"); + assertThat(allValues.get(SUCCESSFUL_DIST_MSG_INDEX)).isEqualTo("distribution client started successfuly"); + } + +}
\ No newline at end of file |