use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocumentOptions in project cloudant-java-sdk by IBM.
the class Cloudant method getSchedulerDocument.
/**
* Retrieve a replication scheduler document.
*
* Retrieves information about a replication document from the replicator database. The endpoint returns the document
* ID, database, replication ID, source and target, and other information.
*
* @param getSchedulerDocumentOptions the {@link GetSchedulerDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SchedulerDocument}
*/
public ServiceCall<SchedulerDocument> getSchedulerDocument(GetSchedulerDocumentOptions getSchedulerDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerDocumentOptions, "getSchedulerDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", getSchedulerDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SchedulerDocument> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SchedulerDocument>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocumentOptions in project cloudant-java-sdk by IBM.
the class GetSchedulerDocumentOptionsTest method testGetSchedulerDocumentOptions.
@Test
public void testGetSchedulerDocumentOptions() throws Throwable {
GetSchedulerDocumentOptions getSchedulerDocumentOptionsModel = new GetSchedulerDocumentOptions.Builder().docId("testString").build();
assertEquals(getSchedulerDocumentOptionsModel.docId(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.GetSchedulerDocumentOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetSchedulerDocumentWOptions.
@Test
public void testGetSchedulerDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"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 getSchedulerDocumentPath = "/_scheduler/docs/_replicator/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetSchedulerDocumentOptions model
GetSchedulerDocumentOptions getSchedulerDocumentOptionsModel = new GetSchedulerDocumentOptions.Builder().docId("testString").build();
// Invoke operation with valid options model (positive test)
Response<SchedulerDocument> response = cloudantService.getSchedulerDocument(getSchedulerDocumentOptionsModel).execute();
assertNotNull(response);
SchedulerDocument 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, getSchedulerDocumentPath);
}
Aggregations