aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src')
-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);
+ }
}