Search in sources :

Example 1 with PostGeoCleanupOptions

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

the class CloudantTest method testPostGeoCleanupWOptions.

@Test
public void testPostGeoCleanupWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"ok\": true}";
    String postGeoCleanupPath = "/testString/_geo_cleanup";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(202).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the PostGeoCleanupOptions model
    PostGeoCleanupOptions postGeoCleanupOptionsModel = new PostGeoCleanupOptions.Builder().db("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<Ok> response = cloudantService.postGeoCleanup(postGeoCleanupOptionsModel).execute();
    assertNotNull(response);
    Ok responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Check query
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, postGeoCleanupPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) PostGeoCleanupOptions(com.ibm.cloud.cloudant.v1.model.PostGeoCleanupOptions) Ok(com.ibm.cloud.cloudant.v1.model.Ok) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with PostGeoCleanupOptions

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

the class PostGeoCleanupOptionsTest method testPostGeoCleanupOptions.

@Test
public void testPostGeoCleanupOptions() throws Throwable {
    PostGeoCleanupOptions postGeoCleanupOptionsModel = new PostGeoCleanupOptions.Builder().db("testString").build();
    assertEquals(postGeoCleanupOptionsModel.db(), "testString");
}
Also used : PostGeoCleanupOptions(com.ibm.cloud.cloudant.v1.model.PostGeoCleanupOptions) Test(org.testng.annotations.Test)

Example 3 with PostGeoCleanupOptions

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

the class Cloudant method postGeoCleanup.

/**
 * Cleanup old geospatial indexes.
 *
 * Cleanup old geospatial indexes from disk that have been superseded by newer index builds.
 *
 * @param postGeoCleanupOptions the {@link PostGeoCleanupOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link Ok}
 */
public ServiceCall<Ok> postGeoCleanup(PostGeoCleanupOptions postGeoCleanupOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(postGeoCleanupOptions, "postGeoCleanupOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("db", postGeoCleanupOptions.db());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_geo_cleanup", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postGeoCleanup");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Ok(com.ibm.cloud.cloudant.v1.model.Ok)

Aggregations

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