Adjust sparky parent pom
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / aggregatevnf / search / AggregateVnfSearchProviderTest.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.aggregatevnf.search;
23
24
25 import static org.junit.Assert.assertNotNull;
26
27 import javax.ws.rs.core.MediaType;
28
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mockito;
32 import org.onap.aai.restclient.client.OperationResult;
33 import org.onap.aai.restclient.enums.RestAuthenticationMode;
34 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
35 import org.onap.aai.sparky.search.SearchServiceAdapter;
36 import org.onap.aai.sparky.search.entity.QuerySearchEntity;
37
38 public class AggregateVnfSearchProviderTest {
39
40   private AggregateVnfSearchProvider aggregateVnfSearchProvider;
41   private RestEndpointConfig restEndpointConfig;
42   private SearchServiceAdapter searchserviceAdapter;
43   private QuerySearchEntity querySearchEntity;
44   private String successResponsePayload;
45   private OperationResult successResult = null;
46   private OperationResult resultValue = null;
47   private String goodDrTargetUrl = "https://0.0.0.0:9502/ui-request/servicegraph";
48
49   @Before
50   public void init() throws Exception {
51
52     restEndpointConfig = new RestEndpointConfig();
53     successResponsePayload = "good-payload";
54     successResult = new OperationResult(200, successResponsePayload);
55     restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
56     searchserviceAdapter = Mockito.mock(SearchServiceAdapter.class);
57     resultValue = Mockito.mock(OperationResult.class);
58     aggregateVnfSearchProvider =
59         new AggregateVnfSearchProvider(searchserviceAdapter, "auto-suggest", "schema");
60     querySearchEntity = new QuerySearchEntity();
61
62   }
63
64   @Test
65   public void updateValues() {
66
67     assertNotNull(aggregateVnfSearchProvider.search(querySearchEntity));
68     aggregateVnfSearchProvider.setAutoSuggestIndexName("auto-suggest-index-1");
69
70   }
71
72   @Test
73   public void testProxyMessage_Success() {
74     Mockito.when(searchserviceAdapter.doPost(Mockito.eq(goodDrTargetUrl), Mockito.anyString())).thenReturn(successResult);
75     Mockito.when(resultValue.getResultCode()).thenReturn(200);
76     aggregateVnfSearchProvider.search(querySearchEntity);
77
78   }
79
80 }