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.services;
24 import static org.junit.Assert.assertEquals;
26 import java.security.SecureRandom;
27 import java.util.ArrayList;
28 import java.util.HashSet;
30 import java.util.concurrent.ExecutorService;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.mockito.Mockito;
35 import org.onap.aai.cl.api.Logger;
36 import org.onap.aai.cl.eelf.LoggerFactory;
37 import org.onap.aai.cl.mdc.MdcContext;
38 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
39 import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
40 import org.onap.aai.sparky.dal.GizmoAdapter;
41 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
42 import org.onap.aai.sparky.util.NodeUtils;
43 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
44 import org.onap.aai.sparky.viewandinspect.context.BaseGizmoVisualizationContext;
46 public class BaseGizmoVisualizationContextTest {
50 private static SecureRandom secureRandom = new SecureRandom();
51 private static Logger LOG =
52 LoggerFactory.getInstance().getLogger(BaseGizmoVisualizationContextTest.class);
54 private BaseGizmoVisualizationContext baseGizmoVisualizationContext;
55 private ExecutorService graphExecutorService;
56 private VisualizationConfigs visualizationConfig;
58 private OxmEntityLookup oxmEntityLookup;
60 private GizmoAdapter gizmoAdapter;
61 private RestEndpointConfig gizmoRestEndPointConfig;
64 public void init() throws Exception {
65 long contextId = secureRandom.nextLong();
66 baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
67 graphExecutorService, visualizationConfig, oxmEntityLookup);
69 graphExecutorService = NodeUtils.createNamedExecutor("SLNC-WORKER", 5, LOG);
70 visualizationConfig = new VisualizationConfigs();
72 ArrayList<String> shallowEntities = new ArrayList<String>();
73 shallowEntities.add("cloud-region");
75 visualizationConfig.setShallowEntities(shallowEntities);
76 visualizationConfig.setMaxSelfLinkTraversalDepth(2);
78 oxmEntityLookup = new OxmEntityLookup();
80 gizmoAdapter = Mockito.mock(GizmoAdapter.class);
83 Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>();
85 processors.add(oxmEntityLookup);
89 gizmoRestEndPointConfig = new RestEndpointConfig();
90 gizmoRestEndPointConfig.setNumRequestRetries(5);
92 Mockito.when(gizmoAdapter.getEndpointConfig()).thenReturn(gizmoRestEndPointConfig);
94 MdcContext.initialize("" + secureRandom.nextLong(), "AAI-UI", "", "partner-name",
101 public void validateBasicConstruction() throws Exception {
103 long contextId = secureRandom.nextLong();
105 baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
106 graphExecutorService, visualizationConfig, oxmEntityLookup);
108 assertEquals(contextId, baseGizmoVisualizationContext.getContextId());