From c08a515bbb5a63401f13d260e2d41c6e472caf95 Mon Sep 17 00:00:00 2001 From: Tomasz Gwozdecki Date: Thu, 13 Dec 2018 03:19:02 -0500 Subject: junits for MsoTenantUtilsFactory -Added new test for MsoTenantUtilsFactory Change-Id: I06719de861fc5d01bb5a8b71d5444eefd7b8b766 Issue-ID: SO-1339 Signed-off-by: Tomasz Gwozdecki --- .../openstack/utils/MsoTenantUtilsFactoryTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java (limited to 'adapters/mso-adapter-utils/src/test/java/org/onap') diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java new file mode 100644 index 0000000000..fa4c6bfe6f --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java @@ -0,0 +1,38 @@ +package org.onap.so.openstack.utils; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowableOfType; +import static org.mockito.BDDMockito.given; + +import java.util.Optional; +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.so.cloud.CloudConfig; +import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; + +@RunWith(MockitoJUnitRunner.class) +public class MsoTenantUtilsFactoryTest { + + @Mock + private CloudConfig cloudConfig; + @InjectMocks + private MsoTenantUtilsFactory msoTenantUtilsFactory; + + @Test + public void getTenantUtils_shouldThrowException_whenNoCloudSiteFoundForGivenId() { + // GIVEN + String cloudSiteId = "CloudSiteId"; + given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.empty()); + + // WHEN + MsoCloudSiteNotFound msoCloudSiteNotFound = catchThrowableOfType( + () -> msoTenantUtilsFactory.getTenantUtils(cloudSiteId), MsoCloudSiteNotFound.class); + + // THEN + assertThat(msoCloudSiteNotFound.getMessage()).contains(cloudSiteId); + } + +} \ No newline at end of file -- cgit 1.2.3-korg