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.aggregatevnf.search;
25 import static org.junit.Assert.assertNotNull;
27 import javax.ws.rs.core.MediaType;
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;
38 public class AggregateVnfSearchProviderTest {
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";
50 public void init() throws Exception {
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();
65 public void updateValues() {
67 assertNotNull(aggregateVnfSearchProvider.search(querySearchEntity));
68 aggregateVnfSearchProvider.setAutoSuggestIndexName("auto-suggest-index-1");
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);