use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocsOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetSchedulerDocsWOptions.
@Test
public void testGetSchedulerDocsWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"total_rows\": 0, \"docs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"error_count\": 0, \"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\"}, \"last_updated\": \"2019-01-01T12:00:00.000Z\", \"node\": \"node\", \"source\": \"source\", \"source_proxy\": \"sourceProxy\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"state\": \"initializing\", \"target\": \"target\", \"target_proxy\": \"targetProxy\"}]}";
String getSchedulerDocsPath = "/_scheduler/docs";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetSchedulerDocsOptions model
GetSchedulerDocsOptions getSchedulerDocsOptionsModel = new GetSchedulerDocsOptions.Builder().limit(Long.valueOf("0")).skip(Long.valueOf("0")).states(new java.util.ArrayList<String>(java.util.Arrays.asList("initializing"))).build();
// Invoke operation with valid options model (positive test)
Response<SchedulerDocsResult> response = cloudantService.getSchedulerDocs(getSchedulerDocsOptionsModel).execute();
assertNotNull(response);
SchedulerDocsResult 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"));
assertEquals(query.get("states"), RequestUtils.join(new java.util.ArrayList<String>(java.util.Arrays.asList("initializing")), ","));
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getSchedulerDocsPath);
}
use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocsOptions in project cloudant-java-sdk by IBM.
the class GetSchedulerDocsOptionsTest method testGetSchedulerDocsOptions.
@Test
public void testGetSchedulerDocsOptions() throws Throwable {
GetSchedulerDocsOptions getSchedulerDocsOptionsModel = new GetSchedulerDocsOptions.Builder().limit(Long.valueOf("0")).skip(Long.valueOf("0")).states(new java.util.ArrayList<String>(java.util.Arrays.asList("initializing"))).build();
assertEquals(getSchedulerDocsOptionsModel.limit(), Long.valueOf("0"));
assertEquals(getSchedulerDocsOptionsModel.skip(), Long.valueOf("0"));
assertEquals(getSchedulerDocsOptionsModel.states(), new java.util.ArrayList<String>(java.util.Arrays.asList("initializing")));
}
use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocsOptions in project cloudant-java-sdk by IBM.
the class Cloudant method getSchedulerDocs.
/**
* Retrieve replication scheduler documents.
*
* Lists replication documents, including information about all documents, even the ones in a completed or failed
* state. For each document, the endpoint returns the document ID, database, replication ID, source and target, and
* other information.
*
* @param getSchedulerDocsOptions the {@link GetSchedulerDocsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SchedulerDocsResult}
*/
public ServiceCall<SchedulerDocsResult> getSchedulerDocs(GetSchedulerDocsOptions getSchedulerDocsOptions) {
if (getSchedulerDocsOptions == null) {
getSchedulerDocsOptions = new GetSchedulerDocsOptions.Builder().build();
}
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocs");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getSchedulerDocsOptions.limit() != null) {
builder.query("limit", String.valueOf(getSchedulerDocsOptions.limit()));
}
if (getSchedulerDocsOptions.skip() != null) {
builder.query("skip", String.valueOf(getSchedulerDocsOptions.skip()));
}
if (getSchedulerDocsOptions.states() != null) {
builder.query("states", RequestUtils.join(getSchedulerDocsOptions.states(), ","));
}
ResponseConverter<SchedulerDocsResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SchedulerDocsResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations