2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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.aai.sparky.viewandinspect;
24 import java.io.IOException;
25 import java.util.HashMap;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
31 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
32 import org.onap.aai.sparky.util.OxmModelAndProcessorHelper;
33 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
34 import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
35 import org.onap.aai.sparky.viewandinspect.entity.GraphMeta;
36 import org.onap.aai.sparky.viewandinspect.entity.SparkyGraphNode;
37 import org.onap.aai.sparky.viewandinspect.services.VisualizationTransformer;
38 import org.onap.aai.sparky.viewandinspect.util.SchemaVisualizationTestDataBuilder;
40 import com.fasterxml.jackson.core.JsonParseException;
41 import com.fasterxml.jackson.databind.DeserializationFeature;
42 import com.fasterxml.jackson.databind.JsonMappingException;
43 import com.fasterxml.jackson.databind.JsonNode;
44 import com.fasterxml.jackson.databind.ObjectMapper;
46 public class VisualizationTransformerTest {
48 VisualizationTransformer testTransformer;
49 VisualizationConfigs visConfig;
50 SubscriptionConfig subConfig;
52 OxmEntityLookup oxmEntityLookup;
56 public void init() throws Exception {
57 this.visConfig = new VisualizationConfigs();
58 this.subConfig = new SubscriptionConfig();
59 this.graphMeta = new GraphMeta();
60 this.oxmEntityLookup = OxmModelAndProcessorHelper.getInstance().getOxmEntityLookup();
62 this.testTransformer = new VisualizationTransformer(visConfig, subConfig);
66 public void testGenerateVisualizationOutput() throws JsonParseException, JsonMappingException, IOException {
67 ObjectMapper mapper = new ObjectMapper();
68 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
70 JsonNode elasticValue = mapper.readValue(SchemaVisualizationTestDataBuilder.getRawRootNode(), JsonNode.class);
74 public ActiveInventoryNode generateActiveInventoryNode(String id, String type, String selfLink, String primaryKeyName, String primaryKeyValue) {
75 ActiveInventoryNode testAin = new ActiveInventoryNode(visConfig, oxmEntityLookup);
77 testAin.setNodeId(id);
78 testAin.setEntityType(type);
79 testAin.setSelfLink(selfLink);
80 testAin.setPrimaryKeyName(primaryKeyName);
81 testAin.setPrimaryKeyValue(primaryKeyValue);
86 public SparkyGraphNode generateSparkyGraphNode(ActiveInventoryNode ain) {
88 SparkyGraphNode testSparkyGraphNode = new SparkyGraphNode(ain, visConfig, subConfig);
90 return testSparkyGraphNode;
93 public Map<String, ActiveInventoryNode> generateFlatNodeArray() {
94 Map<String, ActiveInventoryNode> nodeArray = new HashMap<String, ActiveInventoryNode>();