use of com.ibm.cloud.cloudant.v1.model.GetActiveTasksOptions in project cloudant-java-sdk by IBM.
the class Cloudant method getActiveTasks.
/**
* Retrieve list of running tasks.
*
* Lists running tasks, including the task type, name, status, and process ID. The result includes a JSON array of the
* currently running tasks, with each task described as a single object. Depending on the operation type, the set of
* response object fields might be different.
*
* @param getActiveTasksOptions the {@link GetActiveTasksOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link List}
*/
public ServiceCall<List<ActiveTask>> getActiveTasks(GetActiveTasksOptions getActiveTasksOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_active_tasks"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActiveTasks");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<List<ActiveTask>> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<List<ActiveTask>>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.GetActiveTasksOptions in project cloudant-java-sdk by IBM.
the class GetActiveTasksOptionsTest method testGetActiveTasksOptions.
@Test
public void testGetActiveTasksOptions() throws Throwable {
GetActiveTasksOptions getActiveTasksOptionsModel = new GetActiveTasksOptions();
assertNotNull(getActiveTasksOptionsModel);
}
use of com.ibm.cloud.cloudant.v1.model.GetActiveTasksOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetActiveTasksWOptions.
@Test
public void testGetActiveTasksWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "[{\"changes_done\": 0, \"database\": \"database\", \"node\": \"node\", \"pid\": \"pid\", \"progress\": 0, \"started_on\": 0, \"status\": \"status\", \"task\": \"task\", \"total_changes\": 0, \"type\": \"type\", \"updated_on\": 0}]";
String getActiveTasksPath = "/_active_tasks";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetActiveTasksOptions model
GetActiveTasksOptions getActiveTasksOptionsModel = new GetActiveTasksOptions();
// Invoke operation with valid options model (positive test)
Response<List<ActiveTask>> response = cloudantService.getActiveTasks(getActiveTasksOptionsModel).execute();
assertNotNull(response);
List<ActiveTask> 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, getActiveTasksPath);
}
Aggregations