Search in sources :

Example 1 with GetServerInformationOptions

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

the class GetServerInformationOptionsTest method testGetServerInformationOptions.

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

Example 2 with GetServerInformationOptions

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

the class CloudantTest method testGetServerInformationWOptions.

@Test
public void testGetServerInformationWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"couchdb\": \"couchdb\", \"features\": [\"features\"], \"vendor\": {\"name\": \"name\", \"variant\": \"variant\", \"version\": \"version\"}, \"version\": \"version\", \"features_flags\": [\"featuresFlags\"]}";
    String getServerInformationPath = "/";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetServerInformationOptions model
    GetServerInformationOptions getServerInformationOptionsModel = new GetServerInformationOptions();
    // Invoke operation with valid options model (positive test)
    Response<ServerInformation> response = cloudantService.getServerInformation(getServerInformationOptionsModel).execute();
    assertNotNull(response);
    ServerInformation 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, getServerInformationPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetServerInformationOptions(com.ibm.cloud.cloudant.v1.model.GetServerInformationOptions) ServerInformation(com.ibm.cloud.cloudant.v1.model.ServerInformation) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with GetServerInformationOptions

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

the class Cloudant method getServerInformation.

/**
 * Retrieve server instance information.
 *
 * When you access the root of an instance, IBM Cloudant returns meta-information about the instance. The response
 * includes a JSON structure that contains information about the server, including a welcome message and the server's
 * version.
 *
 * @param getServerInformationOptions the {@link GetServerInformationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link ServerInformation}
 */
public ServiceCall<ServerInformation> getServerInformation(GetServerInformationOptions getServerInformationOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getServerInformation");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<ServerInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ServerInformation>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) ServerInformation(com.ibm.cloud.cloudant.v1.model.ServerInformation)

Aggregations

GetServerInformationOptions (com.ibm.cloud.cloudant.v1.model.GetServerInformationOptions)2 ServerInformation (com.ibm.cloud.cloudant.v1.model.ServerInformation)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