From d43531d4072653b86cc86459816e54806ad589c2 Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Thu, 27 Feb 2020 10:26:32 +0100 Subject: Create adapter for Cmpv2Client connected-with: https://gerrit.onap.org/r/c/aaf/certservice/+/102401 Issue-ID: AAF-997 Signed-off-by: Bartosz Gardziejewski Signed-off-by: Tomasz Golabek Change-Id: Ieb85cd9c93f7a5470fca37a9de4bead3c543199a --- .../configuration/Cmpv2ServerProviderTest.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java') diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java index 20a85783..7e14e470 100644 --- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java +++ b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProviderTest.java @@ -29,10 +29,13 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.onap.aaf.certservice.certification.configuration.model.Authentication; import org.onap.aaf.certservice.certification.configuration.model.CaMode; import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server; +import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException; import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @@ -53,32 +56,32 @@ class Cmpv2ServerProviderTest { @Test void shouldReturnOptionalWithServerWhenServerWithGivenCaNameIsPresentInConfig() { - // given + // Given Cmpv2Server testServer = createTestServer(); when(cmpServersConfig.getCmpServers()).thenReturn(Collections.singletonList(testServer)); - // when + // When Cmpv2Server receivedServer = cmpv2ServerProvider - .getCmpv2Server(TEST_CA) - .get(); + .getCmpv2Server(TEST_CA); - // then + // Then assertThat(receivedServer).isEqualToComparingFieldByField(testServer); } - @Test void shouldReturnEmptyOptionalWhenServerWithGivenCaNameIsNotPresentInConfig() { - // given + // Given + String expectedMessage = "No server found for given CA name"; when(cmpServersConfig.getCmpServers()).thenReturn(Collections.emptyList()); - // when - Boolean isEmpty = cmpv2ServerProvider - .getCmpv2Server(TEST_CA) - .isEmpty(); + // When + Exception exception = assertThrows( + Cmpv2ServerNotFoundException.class, () -> + cmpv2ServerProvider.getCmpv2Server(TEST_CA) + ); - // then - assertThat(isEmpty).isTrue(); + // Then + assertTrue(exception.getMessage().contains(expectedMessage)); } private Cmpv2Server createTestServer() { -- cgit 1.2.3-korg