Adjust sparky parent pom
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / viewandinspect / BaseVisualizationServiceTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.aai.sparky.viewandinspect;
23
24 import static org.junit.Assert.assertEquals;
25
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.Mockito;
29 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
30 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
31 import org.onap.aai.sparky.search.SearchServiceAdapter;
32 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
33 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
34 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
35 import org.onap.aai.sparky.viewandinspect.entity.QueryRequest;
36 import org.onap.aai.sparky.viewandinspect.services.BaseVisualizationService;
37 import org.onap.aai.sparky.viewandinspect.util.SchemaVisualizationTestDataBuilder;
38
39 public class BaseVisualizationServiceTest {
40   private ActiveInventoryAdapter mockAaiAdapter;
41   private SearchServiceAdapter mocksearchServiceAdapter;
42   private VisualizationConfigs visualizationConfigs;
43   private SubscriptionConfig subConfig;
44   private RestEndpointConfig endpointEConfig;
45   private ElasticSearchSchemaConfig schemaEConfig;
46   private VisualizationContextBuilder contextBuilder;
47
48   private BaseVisualizationService baseVisService;
49
50   @Before
51   public void init() throws Exception {
52     this.mockAaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
53     this.mocksearchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
54     this.visualizationConfigs = new VisualizationConfigs();
55     this.subConfig = new SubscriptionConfig();
56     this.endpointEConfig = new RestEndpointConfig();
57     this.schemaEConfig = new ElasticSearchSchemaConfig();
58
59     this.contextBuilder = Mockito.mock(VisualizationContextBuilder.class);
60
61     this.baseVisService = new BaseVisualizationService(contextBuilder, visualizationConfigs,
62         mocksearchServiceAdapter, endpointEConfig, schemaEConfig, subConfig);
63   }
64
65   @Test
66   public void testAnalyzeQueryRequestBody() {
67     QueryRequest validResquest = baseVisService
68         .analyzeQueryRequestBody(SchemaVisualizationTestDataBuilder.getQueryRequest());
69     assertEquals(SchemaVisualizationTestDataBuilder.ROOT_NODE_HASH_ID, validResquest.getHashId());
70
71     QueryRequest nullRequest = baseVisService
72         .analyzeQueryRequestBody("This String should make the request return null eh!");
73     assertEquals(null, nullRequest);
74   }
75
76   @Test
77   public void testBuildVisualizationUsingGenericQuery() {
78
79     initializeMocksForBuildVisualizationUsingGenericQueryTest();
80
81     QueryRequest rootNodeQuery = baseVisService
82         .analyzeQueryRequestBody(SchemaVisualizationTestDataBuilder.getQueryRequest());
83
84   }
85
86   private void initializeMocksForBuildVisualizationUsingGenericQueryTest() {
87     Mockito.when(mockAaiAdapter.queryActiveInventoryWithRetries(Mockito.anyString(),
88         Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())).thenReturn(null);
89   }
90
91 }