use of com.ibm.cloud.cloudant.v1.model.Ok 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.Ok in project cloudant-java-sdk by IBM.
the class CloudantTest method testPostGeoCleanupWOptions.
@Test
public void testPostGeoCleanupWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"ok\": true}";
String postGeoCleanupPath = "/testString/_geo_cleanup";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(202).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the PostGeoCleanupOptions model
PostGeoCleanupOptions postGeoCleanupOptionsModel = new PostGeoCleanupOptions.Builder().db("testString").build();
// Invoke operation with valid options model (positive test)
Response<Ok> response = cloudantService.postGeoCleanup(postGeoCleanupOptionsModel).execute();
assertNotNull(response);
Ok responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, postGeoCleanupPath);
}
use of com.ibm.cloud.cloudant.v1.model.Ok in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetGeoAsStreamWOptions.
@Test
public void testGetGeoAsStreamWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}";
String getGeoAsStreamPath = "/testString/_design/testString/_geo/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetGeoOptions model
GetGeoOptions getGeoOptionsModel = new GetGeoOptions.Builder().db("testString").ddoc("testString").index("testString").bbox("testString").bookmark("testString").format("view").g("testString").includeDocs(false).lat(Double.valueOf("-90")).limit(Long.valueOf("0")).lon(Double.valueOf("-180")).nearest(false).radius(Double.valueOf("0")).rangex(Double.valueOf("0")).rangey(Double.valueOf("0")).relation("intersects").skip(Long.valueOf("0")).stale("ok").build();
// Invoke operation with valid options model (positive test)
Response<InputStream> response = cloudantService.getGeoAsStream(getGeoOptionsModel).execute();
assertNotNull(response);
InputStream 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(query.get("bbox"), "testString");
assertEquals(query.get("bookmark"), "testString");
assertEquals(query.get("format"), "view");
assertEquals(query.get("g"), "testString");
assertEquals(Boolean.valueOf(query.get("include_docs")), Boolean.valueOf(false));
assertEquals(Double.valueOf(query.get("lat")), Double.valueOf("-90"));
assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("0"));
assertEquals(Double.valueOf(query.get("lon")), Double.valueOf("-180"));
assertEquals(Boolean.valueOf(query.get("nearest")), Boolean.valueOf(false));
assertEquals(Double.valueOf(query.get("radius")), Double.valueOf("0"));
assertEquals(Double.valueOf(query.get("rangex")), Double.valueOf("0"));
assertEquals(Double.valueOf(query.get("rangey")), Double.valueOf("0"));
assertEquals(query.get("relation"), "intersects");
assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0"));
assertEquals(query.get("stale"), "ok");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getGeoAsStreamPath);
// Verify streamed JSON response
java.util.Scanner s = new java.util.Scanner(responseObj).useDelimiter("\\A");
String streamedResponseBody = s.hasNext() ? s.next() : "";
assertEquals(streamedResponseBody, mockResponseBody);
}
use of com.ibm.cloud.cloudant.v1.model.Ok in project cloudant-java-sdk by IBM.
the class DeleteDocumentOptionsTest method testDeleteDocumentOptions.
@Test
public void testDeleteDocumentOptions() throws Throwable {
DeleteDocumentOptions deleteDocumentOptionsModel = new DeleteDocumentOptions.Builder().db("testString").docId("testString").ifMatch("testString").batch("ok").rev("testString").build();
assertEquals(deleteDocumentOptionsModel.db(), "testString");
assertEquals(deleteDocumentOptionsModel.docId(), "testString");
assertEquals(deleteDocumentOptionsModel.ifMatch(), "testString");
assertEquals(deleteDocumentOptionsModel.batch(), "ok");
assertEquals(deleteDocumentOptionsModel.rev(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.Ok 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");
}
Aggregations