use of com.ibm.cloud.cloudant.v1.model.Ok in project cloudant-java-sdk by IBM.
the class CloudantTest method testPutDocumentWOptions.
@Test
public void testPutDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\"}";
String putDocumentPath = "/testString/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the Attachment model
Attachment attachmentModel = new Attachment.Builder().contentType("testString").data(TestUtilities.createMockByteArray("This is a mock byte array value.")).digest("testString").encodedLength(Long.valueOf("0")).encoding("testString").follows(true).length(Long.valueOf("0")).revpos(Long.valueOf("1")).stub(true).build();
// Construct an instance of the Revisions model
Revisions revisionsModel = new Revisions.Builder().ids(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).start(Long.valueOf("1")).build();
// Construct an instance of the DocumentRevisionStatus model
DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder().rev("testString").status("available").build();
// Construct an instance of the Document model
Document documentModel = new Document.Builder().attachments(new java.util.HashMap<String, Attachment>() {
{
put("foo", attachmentModel);
}
}).conflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).deleted(true).deletedConflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).id("exampleid").localSeq("testString").rev("testString").revisions(revisionsModel).revsInfo(new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel))).add("brand", "Foo").add("colours", "[\"red\",\"green\",\"black\",\"blue\"]").add("description", "Slim Colourful Design Electronic Cooking Appliance for ...").add("image", "assets/img/0gmsnghhew.jpg").add("keywords", "[\"Foo\",\"Scales\",\"Weight\",\"Digital\",\"Kitchen\"]").add("name", "Digital Kitchen Scales").add("price", "14.99").add("productid", "1000042").add("taxonomy", "[\"Home\",\"Kitchen\",\"Small Appliances\"]").add("type", "product").build();
// Construct an instance of the PutDocumentOptions model
PutDocumentOptions putDocumentOptionsModel = new PutDocumentOptions.Builder().db("testString").docId("testString").document(documentModel).contentType("application/json").ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
// Invoke operation with valid options model (positive test)
Response<DocumentResult> response = cloudantService.putDocument(putDocumentOptionsModel).execute();
assertNotNull(response);
DocumentResult responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "PUT");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("batch"), "ok");
assertEquals(Boolean.valueOf(query.get("new_edits")), Boolean.valueOf(false));
assertEquals(query.get("rev"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, putDocumentPath);
}
use of com.ibm.cloud.cloudant.v1.model.Ok 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.Ok in project cloudant-java-sdk by IBM.
the class CloudantTest method testPutDesignDocumentWOptions.
@Test
public void testPutDesignDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\"}";
String putDesignDocumentPath = "/testString/_design/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the Attachment model
Attachment attachmentModel = new Attachment.Builder().contentType("testString").data(TestUtilities.createMockByteArray("This is a mock byte array value.")).digest("testString").encodedLength(Long.valueOf("0")).encoding("testString").follows(true).length(Long.valueOf("0")).revpos(Long.valueOf("1")).stub(true).build();
// Construct an instance of the Revisions model
Revisions revisionsModel = new Revisions.Builder().ids(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).start(Long.valueOf("1")).build();
// Construct an instance of the DocumentRevisionStatus model
DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder().rev("testString").status("available").build();
// Construct an instance of the Analyzer model
Analyzer analyzerModel = new Analyzer.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
// Construct an instance of the AnalyzerConfiguration model
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).fields(new java.util.HashMap<String, Analyzer>() {
{
put("foo", analyzerModel);
}
}).build();
// Construct an instance of the SearchIndexDefinition model
SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder().analyzer(analyzerConfigurationModel).index("testString").build();
// Construct an instance of the DesignDocumentOptions model
DesignDocumentOptions designDocumentOptionsModel = new DesignDocumentOptions.Builder().partitioned(true).build();
// Construct an instance of the DesignDocumentViewsMapReduce model
DesignDocumentViewsMapReduce designDocumentViewsMapReduceModel = new DesignDocumentViewsMapReduce.Builder().map("testString").reduce("testString").build();
// Construct an instance of the GeoIndexDefinition model
GeoIndexDefinition geoIndexDefinitionModel = new GeoIndexDefinition.Builder().index("testString").build();
// Construct an instance of the DesignDocument model
DesignDocument designDocumentModel = new DesignDocument.Builder().attachments(new java.util.HashMap<String, Attachment>() {
{
put("foo", attachmentModel);
}
}).conflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).deleted(true).deletedConflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).id("testString").localSeq("testString").rev("testString").revisions(revisionsModel).revsInfo(new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel))).autoupdate(true).filters(new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
}).indexes(new java.util.HashMap<String, SearchIndexDefinition>() {
{
put("foo", searchIndexDefinitionModel);
}
}).language("javascript").options(designDocumentOptionsModel).validateDocUpdate("testString").views(new java.util.HashMap<String, DesignDocumentViewsMapReduce>() {
{
put("foo", designDocumentViewsMapReduceModel);
}
}).stIndexes(new java.util.HashMap<String, GeoIndexDefinition>() {
{
put("foo", geoIndexDefinitionModel);
}
}).add("foo", "testString").build();
// Construct an instance of the PutDesignDocumentOptions model
PutDesignDocumentOptions putDesignDocumentOptionsModel = new PutDesignDocumentOptions.Builder().db("testString").ddoc("testString").designDocument(designDocumentModel).ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
// Invoke operation with valid options model (positive test)
Response<DocumentResult> response = cloudantService.putDesignDocument(putDesignDocumentOptionsModel).execute();
assertNotNull(response);
DocumentResult responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "PUT");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("batch"), "ok");
assertEquals(Boolean.valueOf(query.get("new_edits")), Boolean.valueOf(false));
assertEquals(query.get("rev"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, putDesignDocumentPath);
}
use of com.ibm.cloud.cloudant.v1.model.Ok in project cloudant-java-sdk by IBM.
the class DeleteDesignDocumentOptionsTest method testDeleteDesignDocumentOptions.
@Test
public void testDeleteDesignDocumentOptions() throws Throwable {
DeleteDesignDocumentOptions deleteDesignDocumentOptionsModel = new DeleteDesignDocumentOptions.Builder().db("testString").ddoc("testString").ifMatch("testString").batch("ok").rev("testString").build();
assertEquals(deleteDesignDocumentOptionsModel.db(), "testString");
assertEquals(deleteDesignDocumentOptionsModel.ddoc(), "testString");
assertEquals(deleteDesignDocumentOptionsModel.ifMatch(), "testString");
assertEquals(deleteDesignDocumentOptionsModel.batch(), "ok");
assertEquals(deleteDesignDocumentOptionsModel.rev(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.Ok in project cloudant-java-sdk by IBM.
the class PutReplicationDocumentOptionsTest method testPutReplicationDocumentOptions.
@Test
public void testPutReplicationDocumentOptions() throws Throwable {
Attachment attachmentModel = new Attachment.Builder().contentType("testString").data(TestUtilities.createMockByteArray("This is a mock byte array value.")).digest("testString").encodedLength(Long.valueOf("0")).encoding("testString").follows(true).length(Long.valueOf("0")).revpos(Long.valueOf("1")).stub(true).build();
assertEquals(attachmentModel.contentType(), "testString");
assertEquals(attachmentModel.data(), TestUtilities.createMockByteArray("This is a mock byte array value."));
assertEquals(attachmentModel.digest(), "testString");
assertEquals(attachmentModel.encodedLength(), Long.valueOf("0"));
assertEquals(attachmentModel.encoding(), "testString");
assertEquals(attachmentModel.follows(), Boolean.valueOf(true));
assertEquals(attachmentModel.length(), Long.valueOf("0"));
assertEquals(attachmentModel.revpos(), Long.valueOf("1"));
assertEquals(attachmentModel.stub(), Boolean.valueOf(true));
Revisions revisionsModel = new Revisions.Builder().ids(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).start(Long.valueOf("1")).build();
assertEquals(revisionsModel.ids(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(revisionsModel.start(), Long.valueOf("1"));
DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder().rev("testString").status("available").build();
assertEquals(documentRevisionStatusModel.rev(), "testString");
assertEquals(documentRevisionStatusModel.status(), "available");
ReplicationCreateTargetParameters replicationCreateTargetParametersModel = new ReplicationCreateTargetParameters.Builder().n(Long.valueOf("1")).partitioned(false).q(Long.valueOf("26")).build();
assertEquals(replicationCreateTargetParametersModel.n(), Long.valueOf("1"));
assertEquals(replicationCreateTargetParametersModel.partitioned(), Boolean.valueOf(false));
assertEquals(replicationCreateTargetParametersModel.q(), Long.valueOf("26"));
ReplicationDatabaseAuthBasic replicationDatabaseAuthBasicModel = new ReplicationDatabaseAuthBasic.Builder().password("testString").username("testString").build();
assertEquals(replicationDatabaseAuthBasicModel.password(), "testString");
assertEquals(replicationDatabaseAuthBasicModel.username(), "testString");
ReplicationDatabaseAuthIam replicationDatabaseAuthIamModel = new ReplicationDatabaseAuthIam.Builder().apiKey("testString").build();
assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString");
ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder().basic(replicationDatabaseAuthBasicModel).iam(replicationDatabaseAuthIamModel).build();
assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel);
assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel);
ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder().auth(replicationDatabaseAuthModel).headers(new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
}).url("testString").build();
assertEquals(replicationDatabaseModel.auth(), replicationDatabaseAuthModel);
assertEquals(replicationDatabaseModel.headers(), new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
});
assertEquals(replicationDatabaseModel.url(), "testString");
UserContext userContextModel = new UserContext.Builder().db("testString").name("testString").roles(new java.util.ArrayList<String>(java.util.Arrays.asList("_reader"))).build();
assertEquals(userContextModel.db(), "testString");
assertEquals(userContextModel.name(), "testString");
assertEquals(userContextModel.roles(), new java.util.ArrayList<String>(java.util.Arrays.asList("_reader")));
ReplicationDocument replicationDocumentModel = new ReplicationDocument.Builder().attachments(new java.util.HashMap<String, Attachment>() {
{
put("foo", attachmentModel);
}
}).conflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).deleted(true).deletedConflicts(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).id("testString").localSeq("testString").rev("testString").revisions(revisionsModel).revsInfo(new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel))).cancel(true).checkpointInterval(Long.valueOf("0")).connectionTimeout(Long.valueOf("0")).continuous(false).createTarget(false).createTargetParams(replicationCreateTargetParametersModel).docIds(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).filter("testString").httpConnections(Long.valueOf("1")).queryParams(new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
}).retriesPerRequest(Long.valueOf("0")).selector(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).sinceSeq("testString").socketOptions("testString").source(replicationDatabaseModel).sourceProxy("testString").target(replicationDatabaseModel).targetProxy("testString").useCheckpoints(true).userCtx(userContextModel).workerBatchSize(Long.valueOf("1")).workerProcesses(Long.valueOf("1")).add("foo", "testString").build();
assertEquals(replicationDocumentModel.getAttachments(), new java.util.HashMap<String, Attachment>() {
{
put("foo", attachmentModel);
}
});
assertEquals(replicationDocumentModel.getConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(replicationDocumentModel.isDeleted(), Boolean.valueOf(true));
assertEquals(replicationDocumentModel.getDeletedConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(replicationDocumentModel.getId(), "testString");
assertEquals(replicationDocumentModel.getLocalSeq(), "testString");
assertEquals(replicationDocumentModel.getRev(), "testString");
assertEquals(replicationDocumentModel.getRevisions(), revisionsModel);
assertEquals(replicationDocumentModel.getRevsInfo(), new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel)));
assertEquals(replicationDocumentModel.isCancel(), Boolean.valueOf(true));
assertEquals(replicationDocumentModel.getCheckpointInterval(), Long.valueOf("0"));
assertEquals(replicationDocumentModel.getConnectionTimeout(), Long.valueOf("0"));
assertEquals(replicationDocumentModel.isContinuous(), Boolean.valueOf(false));
assertEquals(replicationDocumentModel.isCreateTarget(), Boolean.valueOf(false));
assertEquals(replicationDocumentModel.getCreateTargetParams(), replicationCreateTargetParametersModel);
assertEquals(replicationDocumentModel.getDocIds(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(replicationDocumentModel.getFilter(), "testString");
assertEquals(replicationDocumentModel.getHttpConnections(), Long.valueOf("1"));
assertEquals(replicationDocumentModel.getQueryParams(), new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
});
assertEquals(replicationDocumentModel.getRetriesPerRequest(), Long.valueOf("0"));
assertEquals(replicationDocumentModel.getSelector(), new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
assertEquals(replicationDocumentModel.getSinceSeq(), "testString");
assertEquals(replicationDocumentModel.getSocketOptions(), "testString");
assertEquals(replicationDocumentModel.getSource(), replicationDatabaseModel);
assertEquals(replicationDocumentModel.getSourceProxy(), "testString");
assertEquals(replicationDocumentModel.getTarget(), replicationDatabaseModel);
assertEquals(replicationDocumentModel.getTargetProxy(), "testString");
assertEquals(replicationDocumentModel.isUseCheckpoints(), Boolean.valueOf(true));
assertEquals(replicationDocumentModel.getUserCtx(), userContextModel);
assertEquals(replicationDocumentModel.getWorkerBatchSize(), Long.valueOf("1"));
assertEquals(replicationDocumentModel.getWorkerProcesses(), Long.valueOf("1"));
assertEquals(replicationDocumentModel.get("foo"), "testString");
PutReplicationDocumentOptions putReplicationDocumentOptionsModel = new PutReplicationDocumentOptions.Builder().docId("testString").replicationDocument(replicationDocumentModel).ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
assertEquals(putReplicationDocumentOptionsModel.docId(), "testString");
assertEquals(putReplicationDocumentOptionsModel.replicationDocument(), replicationDocumentModel);
assertEquals(putReplicationDocumentOptionsModel.ifMatch(), "testString");
assertEquals(putReplicationDocumentOptionsModel.batch(), "ok");
assertEquals(putReplicationDocumentOptionsModel.newEdits(), Boolean.valueOf(false));
assertEquals(putReplicationDocumentOptionsModel.rev(), "testString");
}
Aggregations