2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.adapter_utils.tests;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
30 import org.openecomp.mso.cloud.CloudConfig;
31 import org.openecomp.mso.cloud.CloudConfigFactory;
32 import org.openecomp.mso.cloud.CloudIdentity;
33 import org.openecomp.mso.cloud.CloudSite;
37 * This class implements test methods of the CloudConfig features.
41 public class CloudConfigTest {
43 private static CloudConfig con;
44 private static CloudConfigFactory cloudConfigFactory= new CloudConfigFactory();
46 public CloudConfigTest () {
51 * This method is called before any test occurs.
52 * It creates a fake tree from scratch
55 public static final void prepare () {
56 ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
57 String config = classLoader.getResource("cloud_config.json").toString().substring(5);
59 cloudConfigFactory.initializeCloudConfig(config,1);
60 con = cloudConfigFactory.getCloudConfig();
64 * This method implements a test for the getCloudConfig method.
67 public final void testGetCloudConfig () {
72 * This method implements a test for the getCloudSites method.
75 public final void testGetCloudSites () {
76 Map<String,CloudSite> siteMap = con.getCloudSites();
77 assertNotNull(siteMap);
79 CloudSite site1 = siteMap.get("MT");
80 CloudSite site2 = siteMap.get("DAN");
81 CloudSite site3 = siteMap.get("MTINJVCC101");
82 CloudSite site4 = siteMap.get("MTSNJA4LCP1");
84 assertEquals (site1.getRegionId(), "regionOne");
85 assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
86 assertEquals (site2.getRegionId(), "RegionOne");
87 assertEquals (site2.getIdentityServiceId(), "DAN_KEYSTONE");
88 assertEquals (site3.getRegionId(), "regionTwo");
89 assertEquals (site3.getIdentityServiceId(), "MTINJVCC101_DCP");
90 assertEquals (site4.getRegionId(), "mtsnjlcp1");
91 assertEquals (site4.getIdentityServiceId(), "MTSNJA3DCP1");
96 * This method implements a test for the getIdentityServices method.
99 public final void testGetIdentityServices () {
100 Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
101 assertNotNull(identityMap);
103 CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
104 CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE");
105 CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP");
106 CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1");
108 // assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0");
109 // assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0");
110 assertEquals (identity1.getMsoId(), "john");
111 assertEquals (identity1.getMsoPass(), "changeme");
112 assertEquals (identity1.getAdminTenant(), "admin");
113 assertEquals (identity1.getMemberRole(), "_member_");
114 assertEquals (identity1.hasTenantMetadata(), false);
116 // assertEquals (identity2.getKeystoneUrl(), "http://localhost:5000/v2.0");
117 // assertEquals (identity2.getIdentityUrl(), "http://localhost:5000/v2.0");
118 assertEquals (identity2.getMsoId(), "mockId");
119 assertEquals (identity2.getMsoPass(), "stack123");
120 assertEquals (identity2.getAdminTenant(), "service");
121 assertEquals (identity2.getMemberRole(), "_member_");
122 assertEquals (identity2.hasTenantMetadata(), false);
124 // assertEquals (identity3.getKeystoneUrl(), "http://localhost:5000/v2.0");
125 // assertEquals (identity3.getIdentityUrl(), "http://localhost:5000/v2.0");
126 assertEquals (identity3.getMsoId(), "mockIdToo");
127 assertEquals (identity3.getMsoPass(), "AICG@mm@@2015");
128 assertEquals (identity3.getAdminTenant(), "service");
129 assertEquals (identity3.getMemberRole(), "admin");
130 assertEquals (identity3.hasTenantMetadata(), true);
132 // assertEquals (identity4.getKeystoneUrl(), "https://localhost:5000/v2.0");
133 // assertEquals (identity4.getIdentityUrl(), "https://localhost:5000/v2.0");
134 assertEquals (identity4.getMsoId(), "mockIdToo");
135 assertEquals (identity4.getMsoPass(), "2315QRS2015srq");
136 assertEquals (identity4.getAdminTenant(), "service");
137 assertEquals (identity4.getMemberRole(), "admin");
138 assertEquals (identity4.hasTenantMetadata(), true);
143 * This method implements a test for the getCloudSite method.
146 public final void testGetCloudSite () {
147 CloudSite site1 = con.getCloudSite("MT");
148 assertNotNull(site1);
149 assertEquals (site1.getRegionId(), "regionOne");
150 assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
154 * This method implements a test for the getIdentityService method.
157 public final void testGetIdentityService () {
158 CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE");
159 assertNotNull(identity1);
160 // assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0");
161 // assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0");
162 assertEquals (identity1.getMsoId(), "john");
163 assertEquals (identity1.getMsoPass(), "changeme");
164 assertEquals (identity1.getAdminTenant(), "admin");
165 assertEquals (identity1.getMemberRole(), "_member_");
166 assertEquals (identity1.hasTenantMetadata(), false);
168 CloudIdentity identity2 = con.getIdentityService("Test");
169 assertNull(identity2);