Search in sources :

Example 1 with GeoIndexInformation

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

the class CloudantTest method testGetGeoIndexInformationWOptions.

@Test
public void testGetGeoIndexInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"geo_index\": {\"data_size\": 0, \"disk_size\": 0, \"doc_count\": 0}, \"name\": \"name\"}";
    String getGeoIndexInformationPath = "/testString/_design/testString/_geo_info/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetGeoIndexInformationOptions model
    GetGeoIndexInformationOptions getGeoIndexInformationOptionsModel = new GetGeoIndexInformationOptions.Builder().db("testString").ddoc("testString").index("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<GeoIndexInformation> response = cloudantService.getGeoIndexInformation(getGeoIndexInformationOptionsModel).execute();
    assertNotNull(response);
    GeoIndexInformation 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, getGeoIndexInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetGeoIndexInformationOptions(com.ibm.cloud.cloudant.v1.model.GetGeoIndexInformationOptions) GeoIndexInformation(com.ibm.cloud.cloudant.v1.model.GeoIndexInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with GeoIndexInformation

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

the class Cloudant method getGeoIndexInformation.

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

Example 3 with GeoIndexInformation

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

the class GeoIndexInformationTest method testGeoIndexInformation.

@Test
public void testGeoIndexInformation() throws Throwable {
    GeoIndexInformation geoIndexInformationModel = new GeoIndexInformation();
    assertNull(geoIndexInformationModel.getGeoIndex());
    assertNull(geoIndexInformationModel.getName());
}
Also used : GeoIndexInformation(com.ibm.cloud.cloudant.v1.model.GeoIndexInformation) Test(org.testng.annotations.Test)

Aggregations

GeoIndexInformation (com.ibm.cloud.cloudant.v1.model.GeoIndexInformation)3 Test (org.testng.annotations.Test)2 GetGeoIndexInformationOptions (com.ibm.cloud.cloudant.v1.model.GetGeoIndexInformationOptions)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