aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2018-12-13 03:19:02 -0500
committerTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2018-12-13 03:19:02 -0500
commitc08a515bbb5a63401f13d260e2d41c6e472caf95 (patch)
treed99676498910279164874b6e083755d7ccec809c
parenta8845f591e6725721cae22c2bb832a5061b53cf6 (diff)
junits for MsoTenantUtilsFactory
-Added new test for MsoTenantUtilsFactory Change-Id: I06719de861fc5d01bb5a8b71d5444eefd7b8b766 Issue-ID: SO-1339 Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java38
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