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;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertTrue;
29 import java.util.ArrayList;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.aai.restclient.enums.RestAuthenticationMode;
34 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
36 public class SearchServiceAdapterTest {
38 private SearchServiceAdapter searchServiceAdapter;
39 private RestEndpointConfig endpointConfig;
42 public void init() throws Exception {
44 endpointConfig = new RestEndpointConfig();
45 endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
46 searchServiceAdapter = new SearchServiceAdapter(endpointConfig, "1.0");
51 public void updateValues() {
53 searchServiceAdapter.setServiceApiVersion("2.0");
54 assertNotNull(searchServiceAdapter.getServiceApiVersion());
55 searchServiceAdapter.setEndpointConfig(endpointConfig);
56 assertNotNull(searchServiceAdapter.getEndpointConfig());
57 assertNotNull(searchServiceAdapter.doPost("https://aai.search.service:8000", "{maxResults:10, queryStr: f}"));
58 assertNotNull(searchServiceAdapter.doGet("https://aai.search.service:8000", "application/json"));
59 assertNotNull(searchServiceAdapter.doPut("https://aai.search.service:8000",
60 "{maxResults:10, queryStr: f}", "application/json"));
61 assertNotNull(searchServiceAdapter.doDelete("https://aai.search.service:8000", "application/json"));
62 assertNotNull(searchServiceAdapter.getTxnHeader());
63 assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
65 searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost", "2.0"));
66 assertNotNull(searchServiceAdapter.buildSuggestServiceQueryUrl("searchentity-localhost"));
68 assertEquals(searchServiceAdapter.buildBulkImportOperationRequest("testIndex", "1", "4", "{\"payload\":\"value\"}"),
69 "[{\"update\":{\"metaData\":{\"url\":\"/services/search-data-service/2.0/search/indexes/testIndex/documents/1\", "
70 + "\"etag\":\"4\"},\"document\":{\"payload\":\"value\"}}}]\n");