Search in sources :

Example 1 with DocumentShardInfo

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

the class Cloudant method getDocumentShardsInfo.

/**
 * Retrieve shard information for a specific document.
 *
 * Retrieves information about a specific shard where a particular document is stored, along with information about
 * the nodes where that shard has a replica.
 *
 * @param getDocumentShardsInfoOptions the {@link GetDocumentShardsInfoOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link DocumentShardInfo}
 */
public ServiceCall<DocumentShardInfo> getDocumentShardsInfo(GetDocumentShardsInfoOptions getDocumentShardsInfoOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentShardsInfoOptions, "getDocumentShardsInfoOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("db", getDocumentShardsInfoOptions.db());
    pathParamsMap.put("doc_id", getDocumentShardsInfoOptions.docId());
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards/{doc_id}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocumentShardsInfo");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<DocumentShardInfo> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentShardInfo>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) DocumentShardInfo(com.ibm.cloud.cloudant.v1.model.DocumentShardInfo)

Example 2 with DocumentShardInfo

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

the class CloudantTest method testGetDocumentShardsInfoWOptions.

@Test
public void testGetDocumentShardsInfoWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"nodes\": [\"nodes\"], \"range\": \"range\"}";
    String getDocumentShardsInfoPath = "/testString/_shards/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetDocumentShardsInfoOptions model
    GetDocumentShardsInfoOptions getDocumentShardsInfoOptionsModel = new GetDocumentShardsInfoOptions.Builder().db("testString").docId("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<DocumentShardInfo> response = cloudantService.getDocumentShardsInfo(getDocumentShardsInfoOptionsModel).execute();
    assertNotNull(response);
    DocumentShardInfo 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, getDocumentShardsInfoPath);
}
Also used : GetDocumentShardsInfoOptions(com.ibm.cloud.cloudant.v1.model.GetDocumentShardsInfoOptions) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DocumentShardInfo(com.ibm.cloud.cloudant.v1.model.DocumentShardInfo) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with DocumentShardInfo

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

the class DocumentShardInfoTest method testDocumentShardInfo.

@Test
public void testDocumentShardInfo() throws Throwable {
    DocumentShardInfo documentShardInfoModel = new DocumentShardInfo();
    assertNull(documentShardInfoModel.getNodes());
    assertNull(documentShardInfoModel.getRange());
}
Also used : DocumentShardInfo(com.ibm.cloud.cloudant.v1.model.DocumentShardInfo) Test(org.testng.annotations.Test)

Aggregations

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