Search in sources :

Example 1 with ShardsInformation

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetShardsInformationOptions(com.ibm.cloud.cloudant.v1.model.GetShardsInformationOptions) ShardsInformation(com.ibm.cloud.cloudant.v1.model.ShardsInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ShardsInformation

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());
}
Also used : ShardsInformation(com.ibm.cloud.cloudant.v1.model.ShardsInformation) Test(org.testng.annotations.Test)

Example 3 with ShardsInformation

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) ShardsInformation(com.ibm.cloud.cloudant.v1.model.ShardsInformation)

Aggregations

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