Search in sources :

Example 1 with GetDesignDocumentInformationOptions

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

the class GetDesignDocumentInformationOptionsTest method testGetDesignDocumentInformationOptions.

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

Example 2 with GetDesignDocumentInformationOptions

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

the class CloudantTest method testGetDesignDocumentInformationWOptions.

@Test
public void testGetDesignDocumentInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"name\": \"name\", \"view_index\": {\"compact_running\": true, \"language\": \"language\", \"signature\": \"signature\", \"sizes\": {\"active\": 6, \"external\": 8, \"file\": 4}, \"updater_running\": true, \"waiting_clients\": 0, \"waiting_commit\": false}}";
    String getDesignDocumentInformationPath = "/testString/_design/testString/_info";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetDesignDocumentInformationOptions model
    GetDesignDocumentInformationOptions getDesignDocumentInformationOptionsModel = new GetDesignDocumentInformationOptions.Builder().db("testString").ddoc("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<DesignDocumentInformation> response = cloudantService.getDesignDocumentInformation(getDesignDocumentInformationOptionsModel).execute();
    assertNotNull(response);
    DesignDocumentInformation 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, getDesignDocumentInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DesignDocumentInformation(com.ibm.cloud.cloudant.v1.model.DesignDocumentInformation) GetDesignDocumentInformationOptions(com.ibm.cloud.cloudant.v1.model.GetDesignDocumentInformationOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with GetDesignDocumentInformationOptions

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

the class Cloudant method getDesignDocumentInformation.

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

Aggregations

DesignDocumentInformation (com.ibm.cloud.cloudant.v1.model.DesignDocumentInformation)2 GetDesignDocumentInformationOptions (com.ibm.cloud.cloudant.v1.model.GetDesignDocumentInformationOptions)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