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.openecomp.dcae.apod.analytics.aai.it;
23 import com.fasterxml.jackson.databind.JsonNode;
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import com.google.common.collect.ImmutableMap;
26 import org.junit.Before;
27 import org.junit.Ignore;
28 import org.junit.Test;
29 import org.openecomp.dcae.apod.analytics.aai.AAIClientFactory;
30 import org.openecomp.dcae.apod.analytics.aai.service.AAIEnrichmentClient;
32 import java.util.Collections;
36 * @author Rajiv Singla . Creation Date: 9/19/2017.
39 public class AAIClientFactoryIT extends BaseAnalyticsAAIIT {
41 private AAIEnrichmentClient enrichmentClient;
44 public void before() {
45 enrichmentClient = AAIClientFactory.create().getEnrichmentClient(getAAIHttpClientConfig());
49 public void testGetEnrichmentClientForVNF() throws Exception {
50 final String vnfName = "vCPEInfraVNF13";
51 Map<String, String> queryParams = ImmutableMap.of("vnf-name", vnfName);
52 final String vCPEInfraVNF13 =
53 enrichmentClient.getEnrichmentDetails(AAI_VNF_ENRICHMENT_PATH, queryParams, AAI_HEADERS);
54 LOG.info("Fetched VNF A&AI Enrichment Response: \n{}", vCPEInfraVNF13);
59 public void testGetVServerObjectResourceLink() throws Exception {
60 final String vServerName = "example-vserver-name-val-2";
61 Map<String, String> queryParams = ImmutableMap.of("search-node-type", "vserver", "filter",
62 "vserver-name:EQUALS:" + vServerName);
63 final String serverResourceLink =
64 enrichmentClient.getEnrichmentDetails(AAI_VSERVER_NODE_QUERY_PATH, queryParams, AAI_HEADERS);
66 LOG.info("Fetched Vserver Object Resource Link A&AI Enrichment Response: \n{}", serverResourceLink);
71 public void testGetVServerEnrichmentDetails() throws Exception {
72 final String serverResourceLink = fromStream(AAI_VSERVER_QUERY_RESPONSE_LOCATION);
73 final ObjectMapper objectMapper = new ObjectMapper();
74 final JsonNode jsonNode = objectMapper.readTree(serverResourceLink);
75 final String resourceLink = jsonNode.findPath("resource-link").asText();
76 final String vServerEnrichmentDetails =
77 enrichmentClient.getEnrichmentDetails(resourceLink, Collections.<String, String>emptyMap(),
79 LOG.info("Fetched Vserver enrichment details: \n{}", vServerEnrichmentDetails);