2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.onap.aai.sparky.viewandinspect.entity;
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertFalse;
30 import static org.junit.Assert.assertNotNull;
31 import static org.junit.Assert.assertNull;
32 import static org.junit.Assert.assertTrue;
34 import java.util.ArrayList;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.onap.aai.restclient.client.OperationResult;
39 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
40 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
42 public class ActiveInventoryNodeTest {
44 private ActiveInventoryNode activeInventoryNode;
45 private ArrayList<String> lst = new ArrayList<String>();
46 private OperationResult opResult;
47 private VisualizationConfigs visualConfig;
48 private OxmEntityLookup oxmEntityLookup;
51 public void init() throws Exception {
53 visualConfig = new VisualizationConfigs();
54 oxmEntityLookup = new OxmEntityLookup();
55 activeInventoryNode = new ActiveInventoryNode(visualConfig,oxmEntityLookup);
60 public void successfulInitializationAndUpdate() {
62 activeInventoryNode.addQueryParam("query-1");
63 activeInventoryNode.clearQueryParams();
64 activeInventoryNode.addQueryParams(lst);
65 assertNotNull(activeInventoryNode.getQueryParams());
66 assertNull(activeInventoryNode.getOxmModelLoader());
67 activeInventoryNode.setSelfLinkDeterminationPending(true);
68 assertTrue(activeInventoryNode.isSelfLinkDeterminationPending());
69 assertNotNull(activeInventoryNode.getState());
70 assertNotNull(activeInventoryNode.getComplexGroups());
71 assertNotNull(activeInventoryNode.getRelationshipLists());
72 activeInventoryNode.setOpResult(opResult);
73 assertNull(activeInventoryNode.getOpResult());
74 activeInventoryNode.setPrimaryKeyName("PrimaryKeyName");
75 assertNotNull(activeInventoryNode.getPrimaryKeyName());
76 activeInventoryNode.setNodeDepth(2);
77 assertEquals(2,activeInventoryNode.getNodeDepth());
78 activeInventoryNode.setvisualizationConfig(visualConfig);
79 assertNotNull(activeInventoryNode.getvisualizationConfigs());
80 activeInventoryNode.setNodeValidated(true);
81 assertTrue(activeInventoryNode.isNodeValidated());
82 activeInventoryNode.setPrimaryKeyValue("PrimaryKeyValue");
83 assertNotNull(activeInventoryNode.getPrimaryKeyValue());
84 activeInventoryNode.setIgnoredByFilter(true);
85 assertTrue(activeInventoryNode.isIgnoredByFilter());
86 activeInventoryNode.setNodeIssue(true);
87 assertTrue(activeInventoryNode.isNodeIssue());
88 activeInventoryNode.setProcessedNeighbors(true);
89 assertTrue(activeInventoryNode.hasProcessedNeighbors());
90 activeInventoryNode.setResolvedSelfLink(true);
91 assertTrue(activeInventoryNode.hasResolvedSelfLink());
92 activeInventoryNode.addInboundNeighbor("InBoundNodeID");
93 activeInventoryNode.addOutboundNeighbor("OutBoundNodeID");
94 assertTrue(activeInventoryNode.hasNeighbors());
95 activeInventoryNode.addInboundNeighbor(null);
96 activeInventoryNode.addOutboundNeighbor(null);
97 assertNotNull(activeInventoryNode.getInboundNeighbors());
98 assertNotNull(activeInventoryNode.getOutboundNeighbors());
99 assertTrue(activeInventoryNode.isAtMaxDepth());
100 activeInventoryNode.setSelfLinkPendingResolve(true);
101 assertTrue(activeInventoryNode.isSelfLinkPendingResolve());
102 activeInventoryNode.setRootNode(true);
103 assertTrue(activeInventoryNode.isRootNode());
104 activeInventoryNode.setSelflinkRetrievalFailure(true);
105 assertTrue(activeInventoryNode.isSelflinkRetrievalFailure());
106 activeInventoryNode.setSelfLinkProcessed(true);
107 assertTrue(activeInventoryNode.getSelfLinkProcessed());
108 activeInventoryNode.setNodeIntegrityProcessed(true);
109 assertTrue(activeInventoryNode.getNodeIntegrityProcessed());
110 assertFalse(activeInventoryNode.isDirectSelfLink());
111 activeInventoryNode.setProcessingErrorOccurred(true);
112 assertTrue(activeInventoryNode.isProcessingErrorOccurred());
113 activeInventoryNode.setNodeId("NodeId-1");
114 assertNotNull(activeInventoryNode.getNodeId());
115 activeInventoryNode.setSelfLink("selfLinkSet");
116 assertNotNull(activeInventoryNode.getSelfLink());
117 activeInventoryNode.setEntityType("EntityId-1");
118 assertNotNull(activeInventoryNode.getEntityType());
119 assertNotNull(activeInventoryNode.dumpNodeTree(true));
120 assertNotNull(activeInventoryNode.getProcessingErrorCauses());
121 assertNull(activeInventoryNode.calculateEditAttributeUri("Invalid-link"));
122 assertNull(activeInventoryNode.calculateEditAttributeUri("aai/v[\\d]/"));
123 activeInventoryNode.processPathedSelfLinkResponse("jsonResp","startNodeType","startNodeResourceKey");
124 activeInventoryNode.processPathedSelfLinkResponse(null,"startNodeType","startNodeResourceKey");
125 activeInventoryNode.processPathedSelfLinkResponse("","startNodeType","startNodeResourceKey");