1 package org.onap.aai.sparky.viewandinspect;
3 import java.io.IOException;
4 import java.util.HashMap;
7 import org.junit.Before;
9 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
10 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
11 import org.onap.aai.sparky.util.OxmModelAndProcessorHelper;
12 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
13 import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
14 import org.onap.aai.sparky.viewandinspect.entity.GraphMeta;
15 import org.onap.aai.sparky.viewandinspect.entity.SparkyGraphNode;
16 import org.onap.aai.sparky.viewandinspect.services.VisualizationTransformer;
17 import org.onap.aai.sparky.viewandinspect.util.SchemaVisualizationTestDataBuilder;
19 import com.fasterxml.jackson.core.JsonParseException;
20 import com.fasterxml.jackson.databind.DeserializationFeature;
21 import com.fasterxml.jackson.databind.JsonMappingException;
22 import com.fasterxml.jackson.databind.JsonNode;
23 import com.fasterxml.jackson.databind.ObjectMapper;
25 public class VisualizationTransformerTest {
27 VisualizationTransformer testTransformer;
28 VisualizationConfigs visConfig;
29 SubscriptionConfig subConfig;
31 OxmEntityLookup oxmEntityLookup;
35 public void init() throws Exception {
36 this.visConfig = new VisualizationConfigs();
37 this.subConfig = new SubscriptionConfig();
38 this.graphMeta = new GraphMeta();
39 this.oxmEntityLookup = OxmModelAndProcessorHelper.getInstance().getOxmEntityLookup();
41 this.testTransformer = new VisualizationTransformer(visConfig, subConfig);
45 public void testGenerateVisualizationOutput() throws JsonParseException, JsonMappingException, IOException {
46 ObjectMapper mapper = new ObjectMapper();
47 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
49 JsonNode elasticValue = mapper.readValue(SchemaVisualizationTestDataBuilder.getRawRootNode(), JsonNode.class);
53 public ActiveInventoryNode generateActiveInventoryNode(String id, String type, String selfLink, String primaryKeyName, String primaryKeyValue) {
54 ActiveInventoryNode testAin = new ActiveInventoryNode(visConfig, oxmEntityLookup);
56 testAin.setNodeId(id);
57 testAin.setEntityType(type);
58 testAin.setSelfLink(selfLink);
59 testAin.setPrimaryKeyName(primaryKeyName);
60 testAin.setPrimaryKeyValue(primaryKeyValue);
65 public SparkyGraphNode generateSparkyGraphNode(ActiveInventoryNode ain) {
67 SparkyGraphNode testSparkyGraphNode = new SparkyGraphNode(ain, visConfig, subConfig);
69 return testSparkyGraphNode;
72 public Map<String, ActiveInventoryNode> generateFlatNodeArray() {
73 Map<String, ActiveInventoryNode> nodeArray = new HashMap<String, ActiveInventoryNode>();