use of com.ibm.cloud.cloudant.v1.model.DeleteLocalDocumentOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testDeleteLocalDocumentWOptions.
@Test
public void testDeleteLocalDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\"}";
String deleteLocalDocumentPath = "/testString/_local/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the DeleteLocalDocumentOptions model
DeleteLocalDocumentOptions deleteLocalDocumentOptionsModel = new DeleteLocalDocumentOptions.Builder().db("testString").docId("testString").batch("ok").build();
// Invoke operation with valid options model (positive test)
Response<DocumentResult> response = cloudantService.deleteLocalDocument(deleteLocalDocumentOptionsModel).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");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteLocalDocumentPath);
}
use of com.ibm.cloud.cloudant.v1.model.DeleteLocalDocumentOptions in project cloudant-java-sdk by IBM.
the class Cloudant method deleteLocalDocument.
/**
* Delete a local document.
*
* Deletes the specified local document. The semantics are identical to deleting a standard document in the specified
* database, except that the document is not replicated.
*
* @param deleteLocalDocumentOptions the {@link DeleteLocalDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> deleteLocalDocument(DeleteLocalDocumentOptions deleteLocalDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteLocalDocumentOptions, "deleteLocalDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", deleteLocalDocumentOptions.db());
pathParamsMap.put("doc_id", deleteLocalDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteLocalDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteLocalDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(deleteLocalDocumentOptions.batch()));
}
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.DeleteLocalDocumentOptions in project cloudant-java-sdk by IBM.
the class DeleteLocalDocumentOptionsTest method testDeleteLocalDocumentOptions.
@Test
public void testDeleteLocalDocumentOptions() throws Throwable {
DeleteLocalDocumentOptions deleteLocalDocumentOptionsModel = new DeleteLocalDocumentOptions.Builder().db("testString").docId("testString").batch("ok").build();
assertEquals(deleteLocalDocumentOptionsModel.db(), "testString");
assertEquals(deleteLocalDocumentOptionsModel.docId(), "testString");
assertEquals(deleteLocalDocumentOptionsModel.batch(), "ok");
}
Aggregations