use of com.ibm.cloud.cloudant.v1.model.SchedulerJobsResult in project cloudant-java-sdk by IBM.
the class Cloudant method getSchedulerJobs.
/**
* Retrieve replication scheduler jobs.
*
* Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created
* from replication documents. It doesn't include replications that completed or failed to start because replication
* documents were malformed. Each job description includes source and target information, replication ID, history of
* recent events, and other information.
*
* @param getSchedulerJobsOptions the {@link GetSchedulerJobsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult}
*/
public ServiceCall<SchedulerJobsResult> getSchedulerJobs(GetSchedulerJobsOptions getSchedulerJobsOptions) {
if (getSchedulerJobsOptions == null) {
getSchedulerJobsOptions = new GetSchedulerJobsOptions.Builder().build();
}
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJobs");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getSchedulerJobsOptions.limit() != null) {
builder.query("limit", String.valueOf(getSchedulerJobsOptions.limit()));
}
if (getSchedulerJobsOptions.skip() != null) {
builder.query("skip", String.valueOf(getSchedulerJobsOptions.skip()));
}
ResponseConverter<SchedulerJobsResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SchedulerJobsResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.SchedulerJobsResult in project cloudant-java-sdk by IBM.
the class SchedulerJobsResultTest method testSchedulerJobsResult.
@Test
public void testSchedulerJobsResult() throws Throwable {
SchedulerJobsResult schedulerJobsResultModel = new SchedulerJobsResult();
assertNull(schedulerJobsResultModel.getTotalRows());
assertNull(schedulerJobsResultModel.getJobs());
}
use of com.ibm.cloud.cloudant.v1.model.SchedulerJobsResult in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetSchedulerJobsWOptions.
@Test
public void testGetSchedulerJobsWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"total_rows\": 0, \"jobs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"history\": [{\"reason\": \"reason\", \"timestamp\": \"2019-01-01T12:00:00.000Z\", \"type\": \"type\"}], \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"node\": \"node\", \"pid\": \"pid\", \"source\": \"source\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"target\": \"target\", \"user\": \"user\"}]}";
String getSchedulerJobsPath = "/_scheduler/jobs";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetSchedulerJobsOptions model
GetSchedulerJobsOptions getSchedulerJobsOptionsModel = new GetSchedulerJobsOptions.Builder().limit(Long.valueOf("0")).skip(Long.valueOf("0")).build();
// Invoke operation with valid options model (positive test)
Response<SchedulerJobsResult> response = cloudantService.getSchedulerJobs(getSchedulerJobsOptionsModel).execute();
assertNotNull(response);
SchedulerJobsResult 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);
assertNotNull(query);
// Get query params
assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("0"));
assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0"));
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getSchedulerJobsPath);
}
Aggregations