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.search;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.aai.restclient.enums.RestAuthenticationMode;
30 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
32 public class SearchServiceAdapterTest {
34 private SearchServiceAdapter searchServiceAdapter;
35 private RestEndpointConfig endpointConfig;
38 public void init() throws Exception {
40 endpointConfig = new RestEndpointConfig();
41 endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
42 searchServiceAdapter = new SearchServiceAdapter(endpointConfig, "1.0");
47 public void updateValues() {
49 searchServiceAdapter.setServiceApiVersion("2.0");
50 assertNotNull(searchServiceAdapter.getServiceApiVersion());
51 searchServiceAdapter.setEndpointConfig(endpointConfig);
52 assertNotNull(searchServiceAdapter.getEndpointConfig());
53 assertNotNull(searchServiceAdapter.doPost("https://aai.search.service:8000", "{maxResults:10, queryStr: f}"));
54 assertNotNull(searchServiceAdapter.doGet("https://aai.search.service:8000", "application/json"));
55 assertNotNull(searchServiceAdapter.doPut("https://aai.search.service:8000",
56 "{maxResults:10, queryStr: f}", "application/json"));
57 assertNotNull(searchServiceAdapter.doDelete("https://aai.search.service:8000", "application/json"));
58 assertNotNull(searchServiceAdapter.getTxnHeader());
59 assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
61 searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost", "2.0"));
62 assertNotNull(searchServiceAdapter.buildSuggestServiceQueryUrl("searchentity-localhost"));
64 assertEquals(searchServiceAdapter.buildBulkImportOperationRequest("testIndex", "1", "4", "{\"payload\":\"value\"}"),
65 "[{\"update\":{\"metaData\":{\"url\":\"/services/search-data-service/2.0/search/indexes/testIndex/documents/1\", "
66 + "\"etag\":\"4\"},\"document\":{\"payload\":\"value\"}}}]\n");