Search in sources :

Example 1 with MembershipInformation

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

the class Cloudant method getMembershipInformation.

/**
 * Retrieve cluster membership information.
 *
 * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this
 * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a
 * cluster.
 *
 * @param getMembershipInformationOptions the {@link GetMembershipInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link MembershipInformation}
 */
public ServiceCall<MembershipInformation> getMembershipInformation(GetMembershipInformationOptions getMembershipInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_membership"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getMembershipInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<MembershipInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<MembershipInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) MembershipInformation(com.ibm.cloud.cloudant.v1.model.MembershipInformation)

Example 2 with MembershipInformation

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

the class MembershipInformationTest method testMembershipInformation.

@Test
public void testMembershipInformation() throws Throwable {
    MembershipInformation membershipInformationModel = new MembershipInformation();
    assertNull(membershipInformationModel.getAllNodes());
    assertNull(membershipInformationModel.getClusterNodes());
}
Also used : MembershipInformation(com.ibm.cloud.cloudant.v1.model.MembershipInformation) Test(org.testng.annotations.Test)

Example 3 with MembershipInformation

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

the class CloudantTest method testGetMembershipInformationWOptions.

@Test
public void testGetMembershipInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"all_nodes\": [\"allNodes\"], \"cluster_nodes\": [\"clusterNodes\"]}";
    String getMembershipInformationPath = "/_membership";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetMembershipInformationOptions model
    GetMembershipInformationOptions getMembershipInformationOptionsModel = new GetMembershipInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<MembershipInformation> response = cloudantService.getMembershipInformation(getMembershipInformationOptionsModel).execute();
    assertNotNull(response);
    MembershipInformation 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, getMembershipInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetMembershipInformationOptions(com.ibm.cloud.cloudant.v1.model.GetMembershipInformationOptions) MembershipInformation(com.ibm.cloud.cloudant.v1.model.MembershipInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

MembershipInformation (com.ibm.cloud.cloudant.v1.model.MembershipInformation)3 Test (org.testng.annotations.Test)2 GetMembershipInformationOptions (com.ibm.cloud.cloudant.v1.model.GetMembershipInformationOptions)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1