diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org')
-rw-r--r-- | adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
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 |