2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.adaptors.aai;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
28 import java.io.FileNotFoundException;
29 import java.io.InputStream;
31 import java.util.Enumeration;
32 import java.util.HashMap;
33 import java.util.LinkedList;
34 import java.util.List;
36 import java.util.Properties;
38 import org.apache.commons.lang.StringUtils;
39 import org.junit.AfterClass;
40 import org.junit.BeforeClass;
41 import org.junit.FixMethodOrder;
42 import org.junit.Test;
43 import org.junit.runners.MethodSorters;
44 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
45 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
46 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
51 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
52 public class RegressionTest {
55 System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
56 // System.setProperty(org.slf4j.impl.SimpleLogger.LOG_FILE_KEY, String.format("RegressionTest-%d.txt", System.currentTimeMillis()));
59 private static final Logger LOG = LoggerFactory.getLogger(RegressionTest.class);
61 protected static AAIService client;
64 public static void setUp() throws Exception {
66 URL url = AAIService.class.getResource(AAIService.AAICLIENT_PROPERTIES);
67 client = new AAIService(url);
68 LOG.info("\nTaicAAIResourceTest.setUp\n");
72 public static void tearDown() throws Exception {
75 LOG.info("----------------------- AAIResourceTest.tearDown -----------------------");
79 // public void R1510Test05GenericVnfDataRequestDelete() {
80 // LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
83 // String vnf_id = "bpsx0001v-7071";
84 // boolean response = client.deleteGenericVnfData(vnf_id, null);
85 // assertTrue(response);
88 // catch (Throwable e)
95 public void R1604TestWanConnectorSave01Request()
97 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
101 SvcLogicContext ctx = new SvcLogicContext();
103 Map<String, String> data = new HashMap<String, String>();
104 data.put("resource-instance-id", "12345");
105 data.put("resource-model-uuid", "45678");
107 data.put("relationship-list.relationship[0].related-to", "service-instance");
109 data.put("relationship-list.relationship[0].relationship-data[0].relationship-key", "customer.global-customer-id");
110 data.put("relationship-list.relationship[0].relationship-data[0].relationship-value", "$global-customer-id");
112 data.put("relationship-list.relationship[0].relationship-data[1].relationship-key", "service-subscription.service-type");
113 data.put("relationship-list.relationship[0].relationship-data[1].relationship-value", "$service-type");
115 data.put("relationship-list.relationship[0].relationship-data[2].relationship-key", "service-instance.service-instance-id");
116 data.put("relationship-list.relationship[0].relationship-data[2].relationship-value", "$serviceInstanceID");
120 //(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx)
121 QueryStatus resp = client.save("connector", false, false, "resource-instance-id = '12345'", data, "aaidata", ctx);
123 LOG.info("AAIResponse: " + resp.toString());
133 public void R1604TestWanConnectorSave02Request()
135 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
139 SvcLogicContext ctx = new SvcLogicContext();
141 Map<String, String> data = new HashMap<String, String>();
142 data.put("resource-instance-id", "11012345");
143 data.put("widget-model-id", "45678");
144 data.put("persona-model-version", "0.1");
145 data.put("persona-model-id", "dc700a83-c507-47d9-b775-1fdfcdd5f9eb");
146 data.put("relationship-list.relationship[0].relationship-data[0].relationship-key", "customer.global-customer-id");
147 data.put("metadata.metadatum[0].meta-value", "100640");
148 data.put("metadata.metadatum[0].meta-key", "vni");
149 data.put("relationship-list.relationship[0].relationship-data[1].relationship-value", "ATT-COLLABORATE");
150 data.put("relationship-list.relationship[0].relationship-data[0].relationship-value", "ds828e091614l");
151 data.put("relationship-list.relationship[0].relationship-data[2].relationship-key", "service-instance.service-instance-id");
152 data.put("relationship-list.relationship[0].relationship-data[1].relationship-key", "service-subscription.service-type");
153 data.put("relationship-list.relationship[0].related-to", "service-instance");
154 data.put("relationship-list.relationship[0].relationship-data[2].relationship-value", "1990e84d-546d-4b61-8069-e0db1318ade2");
157 //(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx)
158 QueryStatus resp = client.save("connector", false, false, "resource-instance-id = '11012345'", data, "aaidata", ctx);
160 LOG.info("AAIResponse: " + resp.toString());
170 public void R1604TestLogicalLinkSaveRequest()
172 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
176 SvcLogicContext ctx = new SvcLogicContext();
178 Map<String, String> data = new HashMap<String, String>();
179 data.put("link-name" , "1252541");
180 data.put("link-type" , "L2 Bridge between IPE and BorderElement");
181 data.put("speed-value" , "1000");
183 data.put("speed-units" , "MBPS");
184 data.put("ip-version" , "IP-V6");
185 data.put("routing-protocol" , "BGP");
186 data.put("resource-version" , "1.0.0");
187 data.put("resource-model-uuid" , "TEST01");
189 data.put("relationship-list.relationship[0].related-to" , "virtual-data-center");
190 data.put("relationship-list.relationship[0].relationship-data[0].relationship-key", "virtual-data-center.vdc-id");
191 data.put("relationship-list.relationship[0].relationship-data[0].relationship-value", "dpa2_cci_att_com-1068");
193 data.put("relationship-list.relationship[1].related-to" , "generic-vnf");
194 data.put("relationship-list.relationship[1].relationship-data[0].relationship-key", "generic-vnf.vnf-id");
195 data.put("relationship-list.relationship[1].relationship-data[0].relationship-value" , "basx0001v-1189");
197 data.put("relationship-list.relationship[2].related-to" , "l-interface");
198 data.put("relationship-list.relationship[2].relationship-data[0].relationship-key", "pserver.hostname");
199 data.put("relationship-list.relationship[2].relationship-data[0].relationship-value" , "ptpbe101snd");
201 data.put("relationship-list.relationship[2].relationship-data[1].relationship-key", "lag-interface.interface-name");
202 data.put("relationship-list.relationship[2].relationship-data[1].relationship-value" , "$name");
204 data.put("relationship-list.relationship[2].relationship-data[2].relationship-key", "l-interface.interface-name");
205 data.put("relationship-list.relationship[2].relationship-data[2].relationship-value" , "$hostname");
209 //(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx)
210 QueryStatus resp = client.save("logical-link", false, false, "link-name = '1252541'", data, "aaidata", ctx);
212 LOG.info("AAIResponse: " + resp.toString());
221 public void R1604TestVDCISaveRequest()
223 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
227 SvcLogicContext ctx = new SvcLogicContext();
229 Map<String, String> data = new HashMap<String, String>();
230 data.put("vdc-id" , "1252541");
231 data.put("vdc-name" , "put.the.variable.of.your.data.here");
233 data.put("relationship-list.relationship[0].related-to" , "connector");
235 data.put("relationship-list.relationship[0].relationship-data[0].relationship-key" , "connector.resource-instance-id");
236 data.put("relationship-list.relationship[0].relationship-data[0].relationship-value" , "$resource-instance-id");
240 //(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx)
241 QueryStatus resp = client.save("virtual-data-center", false, false, "vdc-id = '1252541'", data, "aaidata", ctx);
243 LOG.info("AAIResponse: " + resp.toString());
252 public void R1510Test03RequestGenericVnfDataRequest()
254 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
258 SvcLogicContext ctx = new SvcLogicContext();
260 QueryStatus response = client.query("generic-vnf:relationship-list", false, null, "vnf-id = '34e94596-bdfa-411d-a664-16dea8583139' AND related-to = 'l3-network' ", "aaiTest", null, ctx);
261 // QueryStatus response = client.delete("generic-vnf:relationship-list", "vnf-id = '34e94596-bdfa-411d-a664-16dea8583139' AND related-to = 'pserver' ", ctx);
263 assertTrue(response == QueryStatus.SUCCESS);
264 LOG.info("AAIResponse: " + response.toString());
268 LOG.error("Caught exception", e);
269 fail("Caught exception");
274 public void R1510Test03RequestVserverDataRequest()
276 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
280 SvcLogicContext ctx = new SvcLogicContext();
281 QueryStatus response = client.query("vserver", false, null,
282 "vserver.vserver-id = 'FRNKGEFF1' AND depth = 'all' AND cloud-region.cloud-owner = 'att-aic' AND tenant.tenant-id = '1710vPEPROJECTS::297135PROJECT' AND cloud-region.cloud-region-id = 'FRN1'"
283 , "aaiTest", null, ctx);
285 assertNotNull(response);
289 LOG.error("Caught exception", e);
290 fail("Caught exception");
295 public void R1510Test03UpdateVserverDataRequest()
297 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
301 Properties prop = new Properties();
302 String propFileName = "vserver-issue.txt";
304 InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
306 if (inputStream != null) {
307 prop.load(inputStream);
309 throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
313 SvcLogicContext ctx = new SvcLogicContext();
315 Map<String, String> data = new HashMap<String, String>();
317 Enumeration keys = prop.keys();
318 while(keys.hasMoreElements()) {
319 String key = keys.nextElement().toString();
320 String value = prop.getProperty(key);
321 data.put(key, value);
324 QueryStatus response = client.update("vserver", "vserver-id = '59567c27-706e-4f41-953f-b5d3a525812f' AND tenant-id = 'USITUCAB3NJ0101UJZZ01::uCPE-VMS'", data, "aaiTest", ctx);
326 assertTrue(response == QueryStatus.SUCCESS);
327 LOG.info("AAIResponse: " + response.toString());
331 LOG.error("Caught exception", e);
332 fail("Caught exception");
337 public void R1510Test03RequestVCloudRegionDataRequest()
339 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
343 SvcLogicContext ctx = new SvcLogicContext();
344 // QueryStatus response = client.query("vserver", false, null, "tenant-id = '3220171995171220' AND vserver-id = '4b491df8-cf0e-4f08-88a2-133e82b63432'", "aaiTest", null, ctx);
345 // QueryStatus response = client.query("vserver", false, null, "vserver-name = 'bpsx0001vm001bps001'", "aaiTest", null, ctx);
346 QueryStatus response = client.query("cloud-region", false, null,
347 "depth = '0' AND cloud-region.cloud-owner = 'att-aic' AND cloud-region.cloud-region-id = 'mtn6'"
348 , "aaiTest", null, ctx);
350 assertTrue(response == QueryStatus.SUCCESS);
351 LOG.info("AAIResponse: " + response.toString());
355 LOG.error("Caught exception", e);
356 fail("Caught exception");
361 public void R1510Test03RequestVCloudRegionData1Request()
363 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
367 List<String> data = new LinkedList<String>();
368 data.add("depth = 0");
369 data.add("cloud-region.cloud-owner = 'att-aic'");
370 data.add("cloud-region.cloud-region-id = 'mtn6'");
373 SvcLogicContext ctx = new SvcLogicContext();
374 QueryStatus response = client.query("cloud-region", false, null, StringUtils.join(data, " AND ")
375 // "depth = '0' AND cloud-region.cloud-owner = 'att-aic' AND cloud-region.cloud-region-id = 'mtn6'"
376 , "aaiTest", null, ctx);
378 assertTrue(response == QueryStatus.SUCCESS);
379 LOG.info("AAIResponse: " + response.toString());
383 LOG.error("Caught exception", e);
384 fail("Caught exception");
389 public void R1510Test03RequestVCloudRegionData2Request()
391 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
395 Map<String, String> nameValues = new HashMap<String, String>();
396 nameValues.put("depth","0");
397 nameValues.put("cloud-region.cloud-owner", "att-aic");
398 nameValues.put("cloud-region.cloud-region-id","mtn6");
400 AAIRequest request = AAIRequest.createRequest("cloud-region", nameValues);
402 for(String key : nameValues.keySet()) {
403 request.addRequestProperty(key, nameValues.get(key).toString());
406 String response = client.query(request);
407 AAIDatum datum = request.jsonStringToObject(response);
409 // assertTrue(response == QueryStatus.SUCCESS);
410 LOG.info("AAIResponse: " + datum.toString());
414 LOG.error("Caught exception", e);