Search in sources :

Example 1 with SearchInfoResult

use of com.ibm.cloud.cloudant.v1.model.SearchInfoResult in project cloudant-java-sdk by IBM.

the class Cloudant method getSearchInfo.

/**
 * Retrieve information about a search index.
 *
 * Retrieve search index metadata information, such as the size of the index on disk.
 *
 * @param getSearchInfoOptions the {@link GetSearchInfoOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link SearchInfoResult}
 */
public ServiceCall<SearchInfoResult> getSearchInfo(GetSearchInfoOptions getSearchInfoOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchInfoOptions, "getSearchInfoOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("db", getSearchInfoOptions.db());
    pathParamsMap.put("ddoc", getSearchInfoOptions.ddoc());
    pathParamsMap.put("index", getSearchInfoOptions.index());
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_search_info/{index}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchInfo");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<SearchInfoResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SearchInfoResult>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : SearchInfoResult(com.ibm.cloud.cloudant.v1.model.SearchInfoResult) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap)

Example 2 with SearchInfoResult

use of com.ibm.cloud.cloudant.v1.model.SearchInfoResult in project cloudant-java-sdk by IBM.

the class CloudantTest method testGetSearchInfoWOptions.

@Test
public void testGetSearchInfoWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"name\": \"name\", \"search_index\": {\"committed_seq\": 12, \"disk_size\": 0, \"doc_count\": 0, \"doc_del_count\": 0, \"pending_seq\": 10}}";
    String getSearchInfoPath = "/testString/_design/testString/_search_info/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetSearchInfoOptions model
    GetSearchInfoOptions getSearchInfoOptionsModel = new GetSearchInfoOptions.Builder().db("testString").ddoc("testString").index("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<SearchInfoResult> response = cloudantService.getSearchInfo(getSearchInfoOptionsModel).execute();
    assertNotNull(response);
    SearchInfoResult responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "GET");
    // Check query
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, getSearchInfoPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) SearchInfoResult(com.ibm.cloud.cloudant.v1.model.SearchInfoResult) GetSearchInfoOptions(com.ibm.cloud.cloudant.v1.model.GetSearchInfoOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with SearchInfoResult

use of com.ibm.cloud.cloudant.v1.model.SearchInfoResult in project cloudant-java-sdk by IBM.

the class SearchInfoResultTest method testSearchInfoResult.

@Test
public void testSearchInfoResult() throws Throwable {
    SearchInfoResult searchInfoResultModel = new SearchInfoResult();
    assertNull(searchInfoResultModel.getName());
    assertNull(searchInfoResultModel.getSearchIndex());
}
Also used : SearchInfoResult(com.ibm.cloud.cloudant.v1.model.SearchInfoResult) Test(org.testng.annotations.Test)

Aggregations

SearchInfoResult (com.ibm.cloud.cloudant.v1.model.SearchInfoResult)3 Test (org.testng.annotations.Test)2 GetSearchInfoOptions (com.ibm.cloud.cloudant.v1.model.GetSearchInfoOptions)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 HashMap (java.util.HashMap)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1