use of com.ibm.cloud.cloudant.v1.model.DeleteDatabaseOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testDeleteDatabaseWOptions.
@Test
public void testDeleteDatabaseWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"ok\": true}";
String deleteDatabasePath = "/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the DeleteDatabaseOptions model
DeleteDatabaseOptions deleteDatabaseOptionsModel = new DeleteDatabaseOptions.Builder().db("testString").build();
// Invoke operation with valid options model (positive test)
Response<Ok> response = cloudantService.deleteDatabase(deleteDatabaseOptionsModel).execute();
assertNotNull(response);
Ok 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);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteDatabasePath);
}
use of com.ibm.cloud.cloudant.v1.model.DeleteDatabaseOptions in project cloudant-java-sdk by IBM.
the class Cloudant method deleteDatabase.
/**
* Delete a database.
*
* Deletes the specified database and all documents and attachments contained within it. To avoid deleting a database,
* the server responds with a 400 HTTP status code when the request URL includes a `?rev=` parameter. This response
* suggests that a user wanted to delete a document but forgot to add the document ID to the URL.
*
* @param deleteDatabaseOptions the {@link DeleteDatabaseOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> deleteDatabase(DeleteDatabaseOptions deleteDatabaseOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDatabaseOptions, "deleteDatabaseOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", deleteDatabaseOptions.db());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteDatabase");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.DeleteDatabaseOptions in project cloudant-java-sdk by IBM.
the class DeleteDatabaseOptionsTest method testDeleteDatabaseOptions.
@Test
public void testDeleteDatabaseOptions() throws Throwable {
DeleteDatabaseOptions deleteDatabaseOptionsModel = new DeleteDatabaseOptions.Builder().db("testString").build();
assertEquals(deleteDatabaseOptionsModel.db(), "testString");
}
Aggregations