use of com.ibm.cloud.cloudant.v1.model.ShardsInformation in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetShardsInformationWOptions.
@Test
public void testGetShardsInformationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"shards\": {\"mapKey\": [\"inner\"]}}";
String getShardsInformationPath = "/testString/_shards";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetShardsInformationOptions model
GetShardsInformationOptions getShardsInformationOptionsModel = new GetShardsInformationOptions.Builder().db("testString").build();
// Invoke operation with valid options model (positive test)
Response<ShardsInformation> response = cloudantService.getShardsInformation(getShardsInformationOptionsModel).execute();
assertNotNull(response);
ShardsInformation 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, getShardsInformationPath);
}
use of com.ibm.cloud.cloudant.v1.model.ShardsInformation in project cloudant-java-sdk by IBM.
the class ShardsInformationTest method testShardsInformation.
@Test
public void testShardsInformation() throws Throwable {
ShardsInformation shardsInformationModel = new ShardsInformation();
assertNull(shardsInformationModel.getShards());
}
use of com.ibm.cloud.cloudant.v1.model.ShardsInformation in project cloudant-java-sdk by IBM.
the class Cloudant method getShardsInformation.
/**
* Retrieve shard information.
*
* List each shard range and the corresponding replicas for a specified database.
*
* @param getShardsInformationOptions the {@link GetShardsInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ShardsInformation}
*/
public ServiceCall<ShardsInformation> getShardsInformation(GetShardsInformationOptions getShardsInformationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getShardsInformationOptions, "getShardsInformationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getShardsInformationOptions.db());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getShardsInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<ShardsInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ShardsInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations