use of com.ibm.cloud.cloudant.v1.model.DeleteReplicationDocumentOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testDeleteReplicationDocumentWOptions.
@Test
public void testDeleteReplicationDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\"}";
String deleteReplicationDocumentPath = "/_replicator/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the DeleteReplicationDocumentOptions model
DeleteReplicationDocumentOptions deleteReplicationDocumentOptionsModel = new DeleteReplicationDocumentOptions.Builder().docId("testString").ifMatch("testString").batch("ok").rev("testString").build();
// Invoke operation with valid options model (positive test)
Response<DocumentResult> response = cloudantService.deleteReplicationDocument(deleteReplicationDocumentOptionsModel).execute();
assertNotNull(response);
DocumentResult responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "DELETE");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("batch"), "ok");
assertEquals(query.get("rev"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteReplicationDocumentPath);
}
use of com.ibm.cloud.cloudant.v1.model.DeleteReplicationDocumentOptions in project cloudant-java-sdk by IBM.
the class DeleteReplicationDocumentOptionsTest method testDeleteReplicationDocumentOptions.
@Test
public void testDeleteReplicationDocumentOptions() throws Throwable {
DeleteReplicationDocumentOptions deleteReplicationDocumentOptionsModel = new DeleteReplicationDocumentOptions.Builder().docId("testString").ifMatch("testString").batch("ok").rev("testString").build();
assertEquals(deleteReplicationDocumentOptionsModel.docId(), "testString");
assertEquals(deleteReplicationDocumentOptionsModel.ifMatch(), "testString");
assertEquals(deleteReplicationDocumentOptionsModel.batch(), "ok");
assertEquals(deleteReplicationDocumentOptionsModel.rev(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.DeleteReplicationDocumentOptions in project cloudant-java-sdk by IBM.
the class Cloudant method deleteReplicationDocument.
/**
* Cancel a replication.
*
* Cancels a replication by deleting the document that describes it from the `_replicator` database.
*
* @param deleteReplicationDocumentOptions the {@link DeleteReplicationDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> deleteReplicationDocument(DeleteReplicationDocumentOptions deleteReplicationDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteReplicationDocumentOptions, "deleteReplicationDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", deleteReplicationDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteReplicationDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteReplicationDocumentOptions.ifMatch() != null) {
builder.header("If-Match", deleteReplicationDocumentOptions.ifMatch());
}
if (deleteReplicationDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(deleteReplicationDocumentOptions.batch()));
}
if (deleteReplicationDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(deleteReplicationDocumentOptions.rev()));
}
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations