TCA: Support for VES/A&AI enrichment
[dcaegen2/analytics/tca.git] / dcae-analytics-aai / src / test / java / org / openecomp / dcae / apod / analytics / aai / it / AAIClientFactoryIT.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
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
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
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===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.aai.it;
22
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;
31
32 import java.util.Collections;
33 import java.util.Map;
34
35 /**
36  * @author Rajiv Singla . Creation Date: 9/19/2017.
37  */
38 @Ignore
39 public class AAIClientFactoryIT extends BaseAnalyticsAAIIT {
40
41     private AAIEnrichmentClient enrichmentClient;
42
43     @Before
44     public void before() {
45         enrichmentClient = AAIClientFactory.create().getEnrichmentClient(getAAIHttpClientConfig());
46     }
47
48     @Test
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);
55
56     }
57
58     @Test
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);
65
66         LOG.info("Fetched Vserver Object Resource Link A&AI Enrichment Response: \n{}", serverResourceLink);
67
68     }
69
70     @Test
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(),
78                         AAI_HEADERS);
79         LOG.info("Fetched Vserver enrichment details: \n{}", vServerEnrichmentDetails);
80     }
81 }