From de5958dddd97b086ec8b603974f434fd814386ac Mon Sep 17 00:00:00 2001 From: Tomasz Gwozdecki Date: Thu, 10 Jan 2019 03:08:59 -0500 Subject: junits for MsoTenantUtilsFactory -Added new test for MsoTenantUtilsFactory Change-Id: I9ba756a1f1c569dc7d0c1528272cca1ccfe3aad4 Issue-ID: SO-1339 Signed-off-by: Tomasz Gwozdecki --- .../so/openstack/utils/MsoTenantUtilsFactoryTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'adapters/mso-adapter-utils/src/test/java/org') 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 index fa4c6bfe6f..0ef54a07e8 100644 --- 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 @@ -3,6 +3,8 @@ 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 static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; import java.util.Optional; import org.junit.Test; @@ -11,6 +13,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.cloud.CloudConfig; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @RunWith(MockitoJUnitRunner.class) @@ -35,4 +38,17 @@ public class MsoTenantUtilsFactoryTest { assertThat(msoCloudSiteNotFound.getMessage()).contains(cloudSiteId); } + @Test + public void getTenantUtils_shouldReturnNull_forInvalidServerType() throws MsoCloudSiteNotFound { + // GIVEN + String cloudSiteId = "CloudSiteId"; + CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS); + given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite)); + + // WHEN + MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId); + + // THEN + assertThat(tenantUtils).isNull(); + } } \ No newline at end of file -- cgit 1.2.3-korg