Search in sources :

Example 1 with ActivityTrackerEvents

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

the class Cloudant method getActivityTrackerEvents.

/**
 * Retrieve Activity Tracker events information.
 *
 * Check event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance.
 *
 * @param getActivityTrackerEventsOptions the {@link GetActivityTrackerEventsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents}
 */
public ServiceCall<ActivityTrackerEvents> getActivityTrackerEvents(GetActivityTrackerEventsOptions getActivityTrackerEventsOptions) {
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActivityTrackerEvents");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    ResponseConverter<ActivityTrackerEvents> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ActivityTrackerEvents>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : ActivityTrackerEvents(com.ibm.cloud.cloudant.v1.model.ActivityTrackerEvents) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder)

Example 2 with ActivityTrackerEvents

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

the class CloudantTest method testGetActivityTrackerEventsWOptions.

@Test
public void testGetActivityTrackerEventsWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"types\": [\"management\"]}";
    String getActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetActivityTrackerEventsOptions model
    GetActivityTrackerEventsOptions getActivityTrackerEventsOptionsModel = new GetActivityTrackerEventsOptions();
    // Invoke operation with valid options model (positive test)
    Response<ActivityTrackerEvents> response = cloudantService.getActivityTrackerEvents(getActivityTrackerEventsOptionsModel).execute();
    assertNotNull(response);
    ActivityTrackerEvents 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, getActivityTrackerEventsPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ActivityTrackerEvents(com.ibm.cloud.cloudant.v1.model.ActivityTrackerEvents) GetActivityTrackerEventsOptions(com.ibm.cloud.cloudant.v1.model.GetActivityTrackerEventsOptions) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with ActivityTrackerEvents

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

the class ActivityTrackerEventsTest method testActivityTrackerEvents.

@Test
public void testActivityTrackerEvents() throws Throwable {
    ActivityTrackerEvents activityTrackerEventsModel = new ActivityTrackerEvents.Builder().types(new java.util.ArrayList<String>(java.util.Arrays.asList("management"))).build();
    assertEquals(activityTrackerEventsModel.types(), new java.util.ArrayList<String>(java.util.Arrays.asList("management")));
    String json = TestUtilities.serialize(activityTrackerEventsModel);
    ActivityTrackerEvents activityTrackerEventsModelNew = TestUtilities.deserialize(json, ActivityTrackerEvents.class);
    assertTrue(activityTrackerEventsModelNew instanceof ActivityTrackerEvents);
}
Also used : ActivityTrackerEvents(com.ibm.cloud.cloudant.v1.model.ActivityTrackerEvents) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

ActivityTrackerEvents (com.ibm.cloud.cloudant.v1.model.ActivityTrackerEvents)3 Test (org.testng.annotations.Test)2 GetActivityTrackerEventsOptions (com.ibm.cloud.cloudant.v1.model.GetActivityTrackerEventsOptions)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 ArrayList (java.util.ArrayList)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1