update sparky with configurable features
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / viewandinspect / entity / ActiveInventoryNodeTest.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25
26 package org.onap.aai.sparky.viewandinspect.entity;
27
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;
33
34 import java.util.ArrayList;
35
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.util.NodeUtils;
41 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
42
43 public class ActiveInventoryNodeTest {
44
45          private ActiveInventoryNode activeInventoryNode; 
46         private ArrayList<String> lst = new ArrayList<String>();
47          private OperationResult opResult; 
48          private VisualizationConfigs visualConfig; 
49          private OxmEntityLookup oxmEntityLookup; 
50          
51                 @Before
52                   public void init() throws Exception {
53                         
54                          visualConfig = new VisualizationConfigs(); 
55                          oxmEntityLookup = new OxmEntityLookup(); 
56                         activeInventoryNode = new ActiveInventoryNode(visualConfig,oxmEntityLookup);
57                  
58                   }
59                 
60                 @Test 
61                 public void successfulInitializationAndUpdate() {
62                         
63                         activeInventoryNode.addQueryParam("query-1");
64                         activeInventoryNode.clearQueryParams();
65                         activeInventoryNode.addQueryParams(lst);
66                         assertNotNull(activeInventoryNode.getQueryParams());
67                         assertNull(activeInventoryNode.getOxmModelLoader());
68                         activeInventoryNode.setSelfLinkDeterminationPending(true);
69                         assertTrue(activeInventoryNode.isSelfLinkDeterminationPending());
70                         assertNotNull(activeInventoryNode.getState());
71                         assertNotNull(activeInventoryNode.getComplexGroups());
72                         assertNotNull(activeInventoryNode.getRelationshipLists());
73                         activeInventoryNode.setOpResult(opResult);
74                         assertNull(activeInventoryNode.getOpResult());
75                         activeInventoryNode.setPrimaryKeyName("PrimaryKeyName");
76                         assertNotNull(activeInventoryNode.getPrimaryKeyName());
77                         activeInventoryNode.setNodeDepth(2);
78                         assertEquals(2,activeInventoryNode.getNodeDepth());
79                         activeInventoryNode.setvisualizationConfig(visualConfig);
80                         assertNotNull(activeInventoryNode.getvisualizationConfigs());
81                         activeInventoryNode.setNodeValidated(true);
82                         assertTrue(activeInventoryNode.isNodeValidated());
83                         activeInventoryNode.setPrimaryKeyValue("PrimaryKeyValue");
84                         assertNotNull(activeInventoryNode.getPrimaryKeyValue());
85                         activeInventoryNode.setIgnoredByFilter(true);
86                         assertTrue(activeInventoryNode.isIgnoredByFilter());
87                         activeInventoryNode.setNodeIssue(true);
88                         assertTrue(activeInventoryNode.isNodeIssue());
89                         activeInventoryNode.setProcessedNeighbors(true);
90                         assertTrue(activeInventoryNode.hasProcessedNeighbors());
91                         activeInventoryNode.setResolvedSelfLink(true);
92                         assertTrue(activeInventoryNode.hasResolvedSelfLink());
93                         activeInventoryNode.addInboundNeighbor("InBoundNodeID");
94                         activeInventoryNode.addOutboundNeighbor("OutBoundNodeID");
95                         assertTrue(activeInventoryNode.hasNeighbors());
96                         activeInventoryNode.addInboundNeighbor(null);
97                         activeInventoryNode.addOutboundNeighbor(null);
98                         assertNotNull(activeInventoryNode.getInboundNeighbors());
99                         assertNotNull(activeInventoryNode.getOutboundNeighbors());
100                         assertTrue(activeInventoryNode.isAtMaxDepth());
101                         activeInventoryNode.setSelfLinkPendingResolve(true);
102                         assertTrue(activeInventoryNode.isSelfLinkPendingResolve());
103                         activeInventoryNode.setRootNode(true);
104                         assertTrue(activeInventoryNode.isRootNode());
105                         activeInventoryNode.setSelflinkRetrievalFailure(true);
106                         assertTrue(activeInventoryNode.isSelflinkRetrievalFailure());
107                         activeInventoryNode.setSelfLinkProcessed(true);
108                         assertTrue(activeInventoryNode.getSelfLinkProcessed());
109                         activeInventoryNode.setNodeIntegrityProcessed(true);
110                         assertTrue(activeInventoryNode.getNodeIntegrityProcessed());
111                         assertFalse(activeInventoryNode.isDirectSelfLink());
112                         activeInventoryNode.setProcessingErrorOccurred(true);
113                         assertTrue(activeInventoryNode.isProcessingErrorOccurred());
114                         activeInventoryNode.setNodeId("NodeId-1");
115                         assertNotNull(activeInventoryNode.getNodeId());
116                         activeInventoryNode.setSelfLink("selfLinkSet");
117                         assertNotNull(activeInventoryNode.getSelfLink());
118                         activeInventoryNode.setEntityType("EntityId-1");
119                         assertNotNull(activeInventoryNode.getEntityType());
120                         assertNotNull(activeInventoryNode.dumpNodeTree(true));
121                         assertNotNull(activeInventoryNode.getProcessingErrorCauses());
122                         assertNull(NodeUtils.calculateEditAttributeUri("Invalid-link"));
123                         assertNull(NodeUtils.calculateEditAttributeUri("aai/v[\\d]/"));
124                         activeInventoryNode.processPathedSelfLinkResponse("jsonResp","startNodeType","startNodeResourceKey");
125                         activeInventoryNode.processPathedSelfLinkResponse(null,"startNodeType","startNodeResourceKey");
126                         activeInventoryNode.processPathedSelfLinkResponse("","startNodeType","startNodeResourceKey");
127                    
128                 }
129 }