junits for MsoTenantUtilsFactory 01/74601/1
authorTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Thu, 13 Dec 2018 08:19:02 +0000 (03:19 -0500)
committerTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Thu, 13 Dec 2018 08:19:02 +0000 (03:19 -0500)
-Added new test for MsoTenantUtilsFactory

Change-Id: I06719de861fc5d01bb5a8b71d5444eefd7b8b766
Issue-ID: SO-1339
Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java [new file with mode: 0644]

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 (file)
index 0000000..fa4c6bf
--- /dev/null
@@ -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