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());
}
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);
}
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);
}
Aggregations