Search in sources :

Example 1 with GetUpInformationOptions

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

the class GetUpInformationOptionsTest method testGetUpInformationOptions.

@Test
public void testGetUpInformationOptions() throws Throwable {
    GetUpInformationOptions getUpInformationOptionsModel = new GetUpInformationOptions();
    assertNotNull(getUpInformationOptionsModel);
}
Also used : GetUpInformationOptions(com.ibm.cloud.cloudant.v1.model.GetUpInformationOptions) Test(org.testng.annotations.Test)

Example 2 with GetUpInformationOptions

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

the class CloudantTest method testGetUpInformationWOptions.

@Test
public void testGetUpInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"seeds\": {\"mapKey\": \"anyValue\"}, \"status\": \"maintenance_mode\"}";
    String getUpInformationPath = "/_up";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetUpInformationOptions model
    GetUpInformationOptions getUpInformationOptionsModel = new GetUpInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<UpInformation> response = cloudantService.getUpInformation(getUpInformationOptionsModel).execute();
    assertNotNull(response);
    UpInformation 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, getUpInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) UpInformation(com.ibm.cloud.cloudant.v1.model.UpInformation) GetUpInformationOptions(com.ibm.cloud.cloudant.v1.model.GetUpInformationOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with GetUpInformationOptions

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

the class Cloudant method getUpInformation.

/**
 * Retrieve information about whether the server is up.
 *
 * Confirms that the server is up, running, and ready to respond to requests. If `maintenance_mode` is `true` or
 * `nolb`, the endpoint returns a 404 response.
 *
 * @param getUpInformationOptions the {@link GetUpInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link UpInformation}
 */
public ServiceCall<UpInformation> getUpInformation(GetUpInformationOptions getUpInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getUpInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<UpInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<UpInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) UpInformation(com.ibm.cloud.cloudant.v1.model.UpInformation)

Aggregations

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