aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2019-01-14 13:56:32 +0100
committerMichal Kabaj <michal.kabaj@nokia.com>2019-01-15 09:45:27 +0100
commit95ac2e00966646914f0c03f1d97cb4a48b6342c7 (patch)
tree2c0f6c02113f4c92aaf0feb75e83e9976cf85c17
parent2b10e4fab723c069ba255c693a6a0abe8bda8f6c (diff)
MsoTenantUtilsFactoryTest unit tests
-added new test cases for factory class Change-Id: Iddd221d1ff5fa6748657b635bc07b6c795b8b9d8 Issue-ID: SO-1339 Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoTenantUtilsFactoryTest.java36
1 files changed, 34 insertions, 2 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
index c3c473591a..f2717ab7ce 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
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2019 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,6 +36,7 @@ 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.db.catalog.beans.ServerType;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
@RunWith(MockitoJUnitRunner.class)
@@ -41,6 +44,10 @@ public class MsoTenantUtilsFactoryTest {
@Mock
private CloudConfig cloudConfig;
+ @Mock
+ private MsoKeystoneUtils msoKeystoneUtils;
+ @Mock
+ private MsoKeystoneV3Utils msoKeystoneV3Utils;
@InjectMocks
private MsoTenantUtilsFactory msoTenantUtilsFactory;
@@ -71,4 +78,29 @@ public class MsoTenantUtilsFactoryTest {
// THEN
assertThat(tenantUtils).isNull();
}
+
+ @Test
+ public void getTenantUtils_shouldReturnKeystoneUtils_forKeystoneServerType() throws MsoCloudSiteNotFound {
+ shouldReturnAppropriateUtilsInstanceForGivenServerType(ServerType.KEYSTONE, msoKeystoneUtils);
+ }
+
+ @Test
+ public void getTenantUtils_shouldReturnKeystoneV3Utils_forKeystoneV3ServerType() throws MsoCloudSiteNotFound {
+ shouldReturnAppropriateUtilsInstanceForGivenServerType(ServerType.KEYSTONE_V3, msoKeystoneV3Utils);
+ }
+
+ private <T extends MsoTenantUtils> void shouldReturnAppropriateUtilsInstanceForGivenServerType(
+ ServerType serverType, T expectedInstance) throws MsoCloudSiteNotFound {
+ // GIVEN
+ String cloudSiteId = "CloudSiteId";
+ CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS);
+ given(cloudSite.getIdentityService().getIdentityServerType()).willReturn(serverType);
+ given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite));
+
+ // WHEN
+ MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId);
+
+ // THEN
+ assertThat(tenantUtils).isEqualTo(expectedInstance);
+ }
}