summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-03-13 05:16:38 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-13 05:16:38 +0000
commit1eee18cabc9b2729af97f222feb37aa81281d2dc (patch)
tree774af9e458c8d4b87ab5b17a7b8acb052da768a4 /adapters/mso-adapter-utils/src/test/java/org/openecomp
parentd3492feb79c837ed3c33381bc37116d6ebae84a9 (diff)
parentf546e4acc2cc81f734f3b0160069b3e48b9c5be3 (diff)
Merge "junit adding and refactor for CloudConfig"
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org/openecomp')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java164
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java292
2 files changed, 340 insertions, 116 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java
new file mode 100644
index 0000000000..fe768b5774
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigFactoryTest.java
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.cloud;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.Response;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
+
+public class CloudConfigFactoryTest {
+
+ private static final String CLOUD_CONFIG_FIELD_NAME = "cloudConfigCache";
+ private static final int REFRESH_TIMER_VALUE = 1;
+
+ private CloudConfigFactory testedObject;
+ private CloudConfig cloudConfigMock;
+
+ @Before
+ public void init() throws NoSuchFieldException, IllegalAccessException {
+ cloudConfigMock = mock(CloudConfig.class);
+ testedObject = new CloudConfigFactory();
+ setCloudConfig();
+ }
+
+ @Test
+ public void initializeCloudConfigSuccessful() throws MsoCloudIdentityNotFound, IOException {
+ ClassLoader classLoader = CloudConfigFactoryTest.class.getClassLoader();
+ String cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath();
+ testedObject.initializeCloudConfig(cloudConfigJsonFilePath, REFRESH_TIMER_VALUE);
+ verify(cloudConfigMock).loadCloudConfig(cloudConfigJsonFilePath, REFRESH_TIMER_VALUE);
+ }
+
+ @Test
+ public void getValidCloudConfig() {
+ when(cloudConfigMock.isValidCloudConfig()).thenReturn(true);
+
+ testedObject.getCloudConfig();
+
+ verify(cloudConfigMock).clone();
+ }
+
+ @Test
+ public void getNotValidCloudConfig() {
+ when(cloudConfigMock.isValidCloudConfig()).thenReturn(false);
+
+ CloudConfig result = testedObject.getCloudConfig();
+
+ assertThat(result).isNotNull();
+ assertThat(result.getCloudSites()).isEmpty();
+ assertThat(result.getIdentityServices()).isEmpty();
+ }
+
+ @Test
+ public void reload_CloudConfigValid() throws IOException, MsoCloudIdentityNotFound {
+ when(cloudConfigMock.isValidCloudConfig()).thenReturn(true);
+
+ testedObject.reloadCloudConfig();
+
+ verify(cloudConfigMock).clone();
+ verify(cloudConfigMock).reloadPropertiesFile();
+ }
+
+ @Test
+ public void reload_CloudConfigNotValid()
+ throws IOException, MsoCloudIdentityNotFound {
+ when(cloudConfigMock.isValidCloudConfig()).thenReturn(false);
+
+ testedObject.reloadCloudConfig();
+
+ verify(cloudConfigMock).reloadPropertiesFile();
+ }
+
+ @Test
+ public void showCloudConfig() throws NoSuchFieldException, IllegalAccessException {
+ when(cloudConfigMock.isValidCloudConfig()).thenReturn(true);
+ when(cloudConfigMock.clone()).thenReturn(createCloudConfig("IdTest576", "identityTest456"));
+ Response response = testedObject.showCloudConfig();
+
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertThat(response.getEntity().toString()).containsPattern("CloudSite:.*IdTest576")
+ .containsPattern("Cloud Identity Service:.*identityTest456");
+
+ }
+
+ @Test
+ public void resetClientCaches_Successful() {
+ Response response = testedObject.resetClientCaches();
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertThat(response.getEntity().toString()).isEqualTo("Client caches reset. All entries removed.");
+ }
+
+ @Test
+ public void cleanUpClientCache_Successful() {
+ Response response = testedObject.cleanupClientCaches();
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertThat(response.getEntity().toString()).isEqualTo("Client caches cleaned up. All expired entries removed.");
+ }
+
+ @Test
+ public void encryptPassword_Successful() {
+ Response response = testedObject.encryptPassword("passTest123");
+ String expectedEncryptedPassword = CloudIdentity.encryptPassword("passTest123");
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertThat(response.getEntity().toString()).isEqualTo("Encrypted Password = "+expectedEncryptedPassword);
+ }
+
+ private CloudConfig createCloudConfig(String cloudSiteId, String identityServiceId)
+ throws NoSuchFieldException, IllegalAccessException {
+ CloudConfig cloudConfig = new CloudConfig();
+ Map<String, CloudSite> cloudSiteMap = new HashMap<>();
+ CloudSite cs = new CloudSite();
+ cs.setId(cloudSiteId);
+ cloudSiteMap.put("keyTest", cs);
+ Field cloudSitesField = cloudConfig.getClass().getDeclaredField("cloudSites");
+ cloudSitesField.setAccessible(true);
+ cloudSitesField.set(cloudConfig, cloudSiteMap);
+
+ Map<String, CloudIdentity> identityServicesMap = new HashMap<>();
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setId(identityServiceId);
+ identityServicesMap.put("identityKey", cloudIdentity);
+
+ Field identityServicesField = cloudConfig.getClass().getDeclaredField("identityServices");
+ identityServicesField.setAccessible(true);
+ identityServicesField.set(cloudConfig, identityServicesMap);
+
+ return cloudConfig;
+ }
+
+ private void setCloudConfig()
+ throws NoSuchFieldException, IllegalAccessException {
+ Field field = testedObject.getClass().getDeclaredField(CLOUD_CONFIG_FIELD_NAME);
+ field.setAccessible(true);
+ field.set(testedObject, cloudConfigMock);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java
index 1c2501e8e4..5b6be03a22 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java
@@ -20,161 +20,221 @@
package org.openecomp.mso.cloud;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Optional;
-import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import java.util.Map;
import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
public class CloudConfigTest {
- private static String cloudConfigJsonFilePath;
- private static String cloudDefaultConfigJsonFilePath;
- private static String cloudConfigInvalidJsonFilePath;
+ private static final int NUMBER_OF_CLOUD_SITES_IN_JSON_FILE = 4;
+ private static final int NUMBER_OF_IDENTITY_SERVICES_IN_JSON_FILE = 4;
+ private static final String CLOUD_SITES_FIELD_NAME = "cloudSites";
+ private static final String IDENTITY_SERVICE_FIELD_NAME = "identityServices";
+ private static final String CLOUD_SITE_DEFAULT = "default";
+ private static final String CLOUD_CONFIG_JSON_FILE_NAME = "cloud_config.json";
+ private static final String CLOUD_CONFIG_INVALID_JSON_FILE_NAME = "cloud_config_bad.json";
+
+ private CloudConfig testedObject;
+ private CloudSite cloudSite;
+ private CloudSite cloudSiteDefault;
+
+ @Before
+ public void init() {
+ testedObject = new CloudConfig();
+ }
- @BeforeClass
- public static void preparePaths() {
- ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
- cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath();
- cloudDefaultConfigJsonFilePath = classLoader.getResource("cloud_default_config.json").getPath();
- cloudConfigInvalidJsonFilePath = classLoader.getResource("cloud_config_bad.json").getPath();
+ @Test
+ public void cloudSite_returnEmptyOptionalIfIdIsNull() {
+ Optional<CloudSite> cloudConfigOpt = new CloudConfig().getCloudSite(null);
+ assertThat(cloudConfigOpt).isEmpty();
+ }
+
+ @Test
+ public void cloudSiteIsGotById_when_IdFound() throws NoSuchFieldException, IllegalAccessException {
+ setCloudSitesMap();
+ Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite(cloudSite.getId());
+ assertThat(cloudSiteOpt).isPresent();
+ assertThat(cloudSiteOpt.get().getId()).isEqualTo(cloudSite.getId());
+ assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSite.getClli());
+ }
+
+ @Test
+ public void cloudSiteIsGotByClli_when_IdNotFound() throws NoSuchFieldException, IllegalAccessException {
+ setCloudSitesMap();
+ Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite(cloudSite.getClli());
+ assertTrue(cloudSiteOpt.isPresent());
+ assertThat(cloudSiteOpt.get().getId()).isEqualTo(cloudSite.getId());
+ assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSite.getClli());
+ }
+
+ @Test
+ public void cloudSiteIsGotByDefault_when_IdAndClliNotFound() throws NoSuchFieldException, IllegalAccessException {
+ setCloudSitesMap();
+ Optional<CloudSite> cloudSiteOpt = testedObject.getCloudSite("not_existing_id");
+ assertTrue(cloudSiteOpt.isPresent());
+ assertThat(cloudSiteOpt.get().getId()).isEqualTo("not_existing_id");
+ assertThat(cloudSiteOpt.get().getClli()).isEqualTo(cloudSiteDefault.getClli());
+ }
+
+ @Test
+ public void cloudSiteNotFound_returnNull() {
+ assertThat(testedObject.getCloudSite("not_existing_id")).isEmpty();
+ }
+
+ @Test
+ public void identityServiceFoundById() throws NoSuchFieldException, IllegalAccessException {
+ CloudIdentity cloudIdentity = createCloudIdentity();
+ setIdentityServiceMap();
+ CloudIdentity cloudIdentityResult = testedObject.getIdentityService(cloudIdentity.getId());
+
+ assertThat(cloudIdentityResult).isNotNull();
+ assertThat(cloudIdentityResult.getId()).isEqualTo(cloudIdentity.getId());
+ assertThat(cloudIdentityResult.getMsoId()).isEqualTo(cloudIdentity.getMsoId());
}
- private CloudConfig createTestObject(String jsonFilePath) throws MsoCloudIdentityNotFound {
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- cloudConfigFactory.initializeCloudConfig(jsonFilePath, 1);
- return cloudConfigFactory.getCloudConfig();
+ @Test
+ public void defaultClodeSiteNotFound_returnNull() {
+ assertThat(testedObject.getIdentityService("not_existing_id")).isNull();
+ }
+
+ @Test
+ public void loadCloudConfigSuccessful() throws IOException, MsoCloudIdentityNotFound {
+ ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
+ String cloudConfigJsonFilePath = classLoader.getResource(CLOUD_CONFIG_JSON_FILE_NAME).getPath();
+ testedObject.loadCloudConfig(cloudConfigJsonFilePath, 1);
+ assertThat(testedObject.isValidCloudConfig()).isTrue();
+ checkCloudSites();
+ checkIdentityServices();
}
@Test
- public void testGetCloudSites() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudConfigJsonFilePath);
- Map<String, CloudSite> siteMap = con.getCloudSites();
- assertNotNull(siteMap);
+ public void loadCloudConfig_cloudIdentityNotFound() {
+ ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
+ String cloudConfigInvalidJsonFilePath = classLoader.getResource(CLOUD_CONFIG_INVALID_JSON_FILE_NAME).getPath();
+ assertThatThrownBy(() -> testedObject.loadCloudConfig(cloudConfigInvalidJsonFilePath, 1))
+ .isInstanceOf(MsoCloudIdentityNotFound.class)
+ .hasMessage("Cloud Identity [MT Cloud site refers to a non-existing identity service: "
+ + "MT_KEYSTONE_NOT_EXISTING] not found");
+ assertThat(testedObject.isValidCloudConfig()).isFalse();
+ }
+ private void checkCloudSites() {
+ Map<String, CloudSite> siteMap = testedObject.getCloudSites();
+ assertThat(siteMap).isNotEmpty().hasSize(NUMBER_OF_CLOUD_SITES_IN_JSON_FILE);
CloudSite site1 = siteMap.get("MT");
CloudSite site2 = siteMap.get("DAN");
CloudSite site3 = siteMap.get("MTINJVCC101");
CloudSite site4 = siteMap.get("MTSNJA4LCP1");
- assertEquals("regionOne", site1.getRegionId());
- assertEquals("MT_KEYSTONE", site1.getIdentityServiceId());
- assertEquals("RegionOne", site2.getRegionId());
- assertEquals("DAN_KEYSTONE", site2.getIdentityServiceId());
- assertEquals("regionTwo", site3.getRegionId());
- assertEquals("MTINJVCC101_DCP", site3.getIdentityServiceId());
- assertEquals("mtsnjlcp1", site4.getRegionId());
- assertEquals("MTSNJA3DCP1", site4.getIdentityServiceId());
+ assertThat(site1.getId()).isEqualTo("MT");
+ assertThat(site1.getRegionId()).isEqualTo("regionOne");
+ assertThat(site1.getIdentityServiceId()).isEqualTo("MT_KEYSTONE");
+ assertThat(site1.getIdentityService()).isNotNull();
+ assertThat(site1.getIdentityService().getId()).isEqualTo(site1.getIdentityServiceId());
+
+ assertThat(site2.getId()).isEqualTo("DAN");
+ assertThat(site2.getRegionId()).isEqualTo("RegionOne");
+ assertThat(site2.getIdentityServiceId()).isEqualTo("DAN_KEYSTONE");
+ assertThat(site2.getIdentityService()).isNotNull();
+ assertThat(site2.getIdentityService().getId()).isEqualTo(site2.getIdentityServiceId());
+
+ assertThat(site3.getId()).isEqualTo("MTINJVCC101");
+ assertThat(site3.getRegionId()).isEqualTo("regionTwo");
+ assertThat(site3.getIdentityServiceId()).isEqualTo("MTINJVCC101_DCP");
+ assertThat(site3.getIdentityService()).isNotNull();
+ assertThat(site3.getIdentityService().getId()).isEqualTo(site3.getIdentityServiceId());
+
+ assertThat(site4.getId()).isEqualTo("MTSNJA4LCP1");
+ assertThat(site4.getRegionId()).isEqualTo("mtsnjlcp1");
+ assertThat(site4.getIdentityServiceId()).isEqualTo("MTSNJA3DCP1");
+ assertThat(site4.getIdentityService()).isNotNull();
+ assertThat(site4.getIdentityService().getId()).isEqualTo(site4.getIdentityServiceId());
}
- @Test
- public void testGetIdentityServices() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudConfigJsonFilePath);
- Map<String, CloudIdentity> identityMap = con.getIdentityServices();
- assertNotNull(identityMap);
+ private void checkIdentityServices() {
+ Map<String, CloudIdentity> identityMap = testedObject.getIdentityServices();
+ assertThat(identityMap).isNotEmpty().hasSize(NUMBER_OF_IDENTITY_SERVICES_IN_JSON_FILE);
CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE");
CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP");
CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1");
- assertEquals("john", identity1.getMsoId());
- assertEquals("changeme", identity1.getMsoPass());
- assertEquals("admin", identity1.getAdminTenant());
- assertEquals("_member_", identity1.getMemberRole());
- assertFalse(identity1.hasTenantMetadata());
-
- assertEquals("mockId", identity2.getMsoId());
- assertEquals("stack123", identity2.getMsoPass());
- assertEquals("service", identity2.getAdminTenant());
- assertEquals("_member_", identity2.getMemberRole());
- assertFalse(identity2.hasTenantMetadata());
-
- assertEquals("mockIdToo", identity3.getMsoId());
- assertEquals("AICG@mm@@2015", identity3.getMsoPass());
- assertEquals("service", identity3.getAdminTenant());
- assertEquals("admin", identity3.getMemberRole());
- assertTrue(identity3.hasTenantMetadata());
-
- assertEquals("mockIdToo", identity4.getMsoId());
- assertEquals("2315QRS2015srq", identity4.getMsoPass());
- assertEquals("service", identity4.getAdminTenant());
- assertEquals("admin", identity4.getMemberRole());
- assertTrue(identity4.hasTenantMetadata());
+ assertThat(identity1.getMsoId()).isEqualTo("john");
+ assertThat(identity1.getMsoPass()).isEqualTo("changeme");
+ assertThat(identity1.getAdminTenant()).isEqualTo("admin");
+ assertThat(identity1.getMemberRole()).isEqualTo("_member_");
+ assertThat(identity1.hasTenantMetadata()).isFalse();
+
+ assertThat(identity2.getMsoId()).isEqualTo("mockId");
+ assertThat(identity2.getMsoPass()).isEqualTo("stack123");
+ assertThat(identity2.getAdminTenant()).isEqualTo("service");
+ assertThat(identity2.getMemberRole()).isEqualTo("_member_");
+ assertThat(identity2.hasTenantMetadata()).isFalse();
+
+ assertThat(identity3.getMsoId()).isEqualTo("mockIdToo");
+ assertThat(identity3.getMsoPass()).isEqualTo("AICG@mm@@2015");
+ assertThat(identity3.getAdminTenant()).isEqualTo("service");
+ assertThat(identity3.getMemberRole()).isEqualTo("admin");
+ assertThat(identity3.hasTenantMetadata()).isTrue();
+
+ assertThat(identity4.getMsoId()).isEqualTo("mockIdToo");
+ assertThat(identity4.getMsoPass()).isEqualTo("2315QRS2015srq");
+ assertThat(identity4.getAdminTenant()).isEqualTo("service");
+ assertThat(identity4.getMemberRole()).isEqualTo("admin");
+ assertThat(identity4.hasTenantMetadata()).isTrue();
}
@Test
- public void cloudSiteIsGotById_when_IdFound() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudConfigJsonFilePath);
- Optional<CloudSite> cloudSite = con.getCloudSite("MT");
- assertTrue(cloudSite.isPresent());
- assertEquals("regionOne", cloudSite.get().getRegionId());
- assertEquals("MT_KEYSTONE", cloudSite.get().getIdentityServiceId());
+ public void cloneSuccessful() throws NoSuchFieldException, IllegalAccessException {
+ setCloudSitesMap();
+ setIdentityServiceMap();
+ assertThat(testedObject.clone()).isEqualTo(testedObject);
}
- @Test
- public void cloudSiteIsGotByClli_when_IdNotFound() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudConfigJsonFilePath);
- Optional<CloudSite> cloudSite = con.getCloudSite("CS_clli");
- assertTrue(cloudSite.isPresent());
- assertEquals("clliRegion", cloudSite.get().getRegionId());
- assertEquals("CS_clli", cloudSite.get().getClli());
- assertEquals("CS_service", cloudSite.get().getIdentityServiceId());
+ private void setCloudSitesMap() throws NoSuchFieldException, IllegalAccessException {
+ Field field = testedObject.getClass().getDeclaredField(CLOUD_SITES_FIELD_NAME);
+ field.setAccessible(true);
+ Map<String, CloudSite> cloudSites = new HashMap<>();
+ cloudSite = createCloudSite("idTest1", "clliTest1");
+ cloudSiteDefault = createCloudSite(CLOUD_SITE_DEFAULT, "clliTest2");
+ cloudSites.put(cloudSite.getId(), cloudSite);
+ cloudSites.put(cloudSiteDefault.getId(), cloudSiteDefault);
+ field.set(testedObject, cloudSites);
}
- @Test
- public void cloudSiteIsGotByDefault_when_IdAndClliNotFound() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudDefaultConfigJsonFilePath);
- Optional<CloudSite> cloudSite = con.getCloudSite("not_existing_id");
- assertTrue(cloudSite.isPresent());
- assertEquals("not_existing_id", cloudSite.get().getId());
- assertEquals("not_existing_id", cloudSite.get().getRegionId());
- }
+ private void setIdentityServiceMap() throws NoSuchFieldException, IllegalAccessException {
+ Field field = testedObject.getClass().getDeclaredField(IDENTITY_SERVICE_FIELD_NAME);
+ field.setAccessible(true);
- @Test
- public void testGetIdentityService() throws MsoCloudIdentityNotFound {
- CloudConfig con = createTestObject(cloudConfigJsonFilePath);
- CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE");
- assertNotNull(identity1);
- assertEquals("john", identity1.getMsoId());
- assertEquals("changeme", identity1.getMsoPass());
- assertEquals("admin", identity1.getAdminTenant());
- assertEquals("_member_", identity1.getMemberRole());
- assertFalse(identity1.hasTenantMetadata());
-
- CloudIdentity identity2 = con.getIdentityService("Test");
- assertNull(identity2);
+ Map<String, CloudIdentity> cloudIdentityMap = new HashMap<>();
+ CloudIdentity cloudIdentity = createCloudIdentity();
+ cloudIdentityMap.put(cloudIdentity.getId(), cloudIdentity);
+ field.set(testedObject, cloudIdentityMap);
}
- @Test(expected = MsoCloudIdentityNotFound.class)
- public void testLoadWithWrongFile() throws MsoCloudIdentityNotFound {
- createTestObject(cloudConfigInvalidJsonFilePath);
+ private CloudIdentity createCloudIdentity() {
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setId("identityTestId");
+ cloudIdentity.setMsoId("msoTestId");
+ return cloudIdentity;
}
- @Test
- public void testReloadWithWrongFile() {
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- try {
- cloudConfigFactory.initializeCloudConfig(cloudConfigInvalidJsonFilePath, 1);
- Assert.fail("MsoCloudIdentityNotFound was expected");
- } catch (MsoCloudIdentityNotFound e) {
-
- }
- assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getCloudSites().isEmpty());
- assertTrue("Should be an empty CloudConfig",
- cloudConfigFactory.getCloudConfig().getIdentityServices().isEmpty());
- // Now reload the right config
- cloudConfigFactory.changeMsoPropertiesFilePath(cloudConfigJsonFilePath);
- cloudConfigFactory.reloadCloudConfig();
- assertTrue("Flag valid Config should be true now that the cloud_config is correct",
- cloudConfigFactory.getCloudConfig().isValidCloudConfig());
+ private CloudSite createCloudSite(String id, String clli) {
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId(id);
+ cloudSite.setClli(clli);
+ cloudSite.setAic_version("2.5");
+ cloudSite.setIdentityService(createCloudIdentity());
+ return cloudSite;
}
-
}