Search in sources :

Example 1 with PartitionInformation

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

the class PartitionInformationTest method testPartitionInformation.

@Test
public void testPartitionInformation() throws Throwable {
    PartitionInformation partitionInformationModel = new PartitionInformation();
    assertNull(partitionInformationModel.getDbName());
    assertNull(partitionInformationModel.getDocCount());
    assertNull(partitionInformationModel.getDocDelCount());
    assertNull(partitionInformationModel.getPartition());
    assertNull(partitionInformationModel.getPartitionedIndexes());
    assertNull(partitionInformationModel.getSizes());
}
Also used : PartitionInformation(com.ibm.cloud.cloudant.v1.model.PartitionInformation) Test(org.testng.annotations.Test)

Example 2 with PartitionInformation

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

the class CloudantTest method testGetPartitionInformationWOptions.

@Test
public void testGetPartitionInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"db_name\": \"dbName\", \"doc_count\": 0, \"doc_del_count\": 0, \"partition\": \"partition\", \"partitioned_indexes\": {\"count\": 0, \"indexes\": {\"search\": 0, \"view\": 0}, \"limit\": 0}, \"sizes\": {\"active\": 0, \"external\": 0}}";
    String getPartitionInformationPath = "/testString/_partition/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetPartitionInformationOptions model
    GetPartitionInformationOptions getPartitionInformationOptionsModel = new GetPartitionInformationOptions.Builder().db("testString").partitionKey("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<PartitionInformation> response = cloudantService.getPartitionInformation(getPartitionInformationOptionsModel).execute();
    assertNotNull(response);
    PartitionInformation 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, getPartitionInformationPath);
}
Also used : GetPartitionInformationOptions(com.ibm.cloud.cloudant.v1.model.GetPartitionInformationOptions) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) PartitionInformation(com.ibm.cloud.cloudant.v1.model.PartitionInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with PartitionInformation

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

the class Cloudant method getPartitionInformation.

/**
 * Retrieve information about a database partition.
 *
 * Given a partition key, return the database name, sizes, partition, doc count, and doc delete count.
 *
 * @param getPartitionInformationOptions the {@link GetPartitionInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link PartitionInformation}
 */
public ServiceCall<PartitionInformation> getPartitionInformation(GetPartitionInformationOptions getPartitionInformationOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(getPartitionInformationOptions, "getPartitionInformationOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("db", getPartitionInformationOptions.db());
    pathParamsMap.put("partition_key", getPartitionInformationOptions.partitionKey());
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getPartitionInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<PartitionInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<PartitionInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) PartitionInformation(com.ibm.cloud.cloudant.v1.model.PartitionInformation)

Aggregations

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