2 * ===============================LICENSE_START======================================
4 * ================================================================================
5 * Copyright © 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.onap.dcae.apod.analytics.aai;
23 import org.onap.dcae.apod.analytics.aai.domain.config.AAIHttpClientConfig;
24 import org.onap.dcae.apod.analytics.aai.domain.config.AAIHttpClientConfigBuilder;
25 import org.onap.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest;
27 import java.net.MalformedURLException;
29 import java.util.LinkedHashMap;
33 * @author Rajiv Singla . Creation Date: 9/18/2017.
35 public class BaseAnalyticsAAIUnitTest extends BaseDCAEAnalyticsUnitTest {
37 protected static final String AAI_HOST_NAME = "1.2.3.4";
38 protected static final Integer AAI_HOST_PORT_NUMBER = 1234;
39 protected static final String AAI_HOST_PROTOCOL = "https";
40 protected static final String AAI_VNF_ENRICHMENT_PATH = "/aai/v11/network/generic-vnfs/generic-vnf";
41 protected static final String AAI_VSERVER_NODE_QUERY_PATH = "/aai/v11/search/nodes-query";
42 protected static final String AAI_VSERVER_QUERY_RESPONSE_LOCATION = "data/json/aai/aai_vserver_resource_data.json";
44 protected static final Map<String, String> AAI_HEADERS = new LinkedHashMap<>();
47 AAI_HEADERS.put("X-FromAppId", "vv-temp");
48 AAI_HEADERS.put("X-TransactionId", "vv-temp");
49 AAI_HEADERS.put("Accept", "application/json");
50 AAI_HEADERS.put("Real-Time", "true");
51 AAI_HEADERS.put("Content-Type", "application/json");
54 protected static final String PROXY_HOST = "proxy.att.com";
55 protected static final Integer PROXY_PORT = 80;
56 protected static final String PROXY_URL = String.format("http://username:password@%s:%s", PROXY_HOST, PROXY_PORT);
58 protected static final String AAI_USER_NAME = "DCAE";
59 protected static final String AAI_USER_PASSWORD = "DCAE";
60 protected static final boolean IGNORE_SSL_CERTIFICATE_ERRORS = true;
62 protected AAIHttpClientConfig getAAIHttpClientTestConfig(final boolean ignoreSSLCertificateErrors,
63 final String proxyURLString) {
65 if (proxyURLString != null) {
67 proxyURL = new URL(proxyURLString);
68 } catch (MalformedURLException e) {
69 throw new IllegalArgumentException("Proxy URL format is Invalid", e);
74 return new AAIHttpClientConfigBuilder(AAI_HOST_NAME)
75 .setAaiProtocol(AAI_HOST_PROTOCOL)
76 .setAaiHostPortNumber(AAI_HOST_PORT_NUMBER)
77 .setAaiUserName(AAI_USER_NAME)
78 .setAaiUserPassword(AAI_USER_PASSWORD)
79 .setAaiProxyURL(proxyURL)
80 .setAaiIgnoreSSLCertificateErrors(ignoreSSLCertificateErrors).build();