use of com.ibm.cloud.cloudant.v1.model.ReplicationDocument in project cloudant-java-sdk by IBM.
the class Cloudant method getReplicationDocument.
/**
* Retrieve a replication document.
*
* Retrieves a replication document from the `_replicator` database to view the configuration of the replication. The
* status of the replication is no longer recorded in the document but can be checked via the replication scheduler.
*
* @param getReplicationDocumentOptions the {@link GetReplicationDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ReplicationDocument}
*/
public ServiceCall<ReplicationDocument> getReplicationDocument(GetReplicationDocumentOptions getReplicationDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getReplicationDocumentOptions, "getReplicationDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", getReplicationDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getReplicationDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getReplicationDocumentOptions.ifNoneMatch() != null) {
builder.header("If-None-Match", getReplicationDocumentOptions.ifNoneMatch());
}
if (getReplicationDocumentOptions.attachments() != null) {
builder.query("attachments", String.valueOf(getReplicationDocumentOptions.attachments()));
}
if (getReplicationDocumentOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(getReplicationDocumentOptions.attEncodingInfo()));
}
if (getReplicationDocumentOptions.conflicts() != null) {
builder.query("conflicts", String.valueOf(getReplicationDocumentOptions.conflicts()));
}
if (getReplicationDocumentOptions.deletedConflicts() != null) {
builder.query("deleted_conflicts", String.valueOf(getReplicationDocumentOptions.deletedConflicts()));
}
if (getReplicationDocumentOptions.latest() != null) {
builder.query("latest", String.valueOf(getReplicationDocumentOptions.latest()));
}
if (getReplicationDocumentOptions.localSeq() != null) {
builder.query("local_seq", String.valueOf(getReplicationDocumentOptions.localSeq()));
}
if (getReplicationDocumentOptions.meta() != null) {
builder.query("meta", String.valueOf(getReplicationDocumentOptions.meta()));
}
if (getReplicationDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(getReplicationDocumentOptions.rev()));
}
if (getReplicationDocumentOptions.revs() != null) {
builder.query("revs", String.valueOf(getReplicationDocumentOptions.revs()));
}
if (getReplicationDocumentOptions.revsInfo() != null) {
builder.query("revs_info", String.valueOf(getReplicationDocumentOptions.revsInfo()));
}
ResponseConverter<ReplicationDocument> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ReplicationDocument>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.ReplicationDocument in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetReplicationDocumentWOptions.
@Test
public void testGetReplicationDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}], \"cancel\": true, \"checkpoint_interval\": 0, \"connection_timeout\": 0, \"continuous\": false, \"create_target\": false, \"create_target_params\": {\"n\": 1, \"partitioned\": false, \"q\": 1}, \"doc_ids\": [\"docIds\"], \"filter\": \"filter\", \"http_connections\": 1, \"query_params\": {\"mapKey\": \"inner\"}, \"retries_per_request\": 0, \"selector\": {\"mapKey\": \"anyValue\"}, \"since_seq\": \"sinceSeq\", \"socket_options\": \"socketOptions\", \"source\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"source_proxy\": \"sourceProxy\", \"target\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"target_proxy\": \"targetProxy\", \"use_checkpoints\": true, \"user_ctx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}, \"worker_batch_size\": 1, \"worker_processes\": 1}";
String getReplicationDocumentPath = "/_replicator/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetReplicationDocumentOptions model
GetReplicationDocumentOptions getReplicationDocumentOptionsModel = new GetReplicationDocumentOptions.Builder().docId("testString").ifNoneMatch("testString").attachments(false).attEncodingInfo(false).conflicts(false).deletedConflicts(false).latest(false).localSeq(false).meta(false).rev("testString").revs(false).revsInfo(false).build();
// Invoke operation with valid options model (positive test)
Response<ReplicationDocument> response = cloudantService.getReplicationDocument(getReplicationDocumentOptionsModel).execute();
assertNotNull(response);
ReplicationDocument 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(Boolean.valueOf(query.get("attachments")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("att_encoding_info")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("conflicts")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("deleted_conflicts")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("latest")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("local_seq")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("meta")), Boolean.valueOf(false));
assertEquals(query.get("rev"), "testString");
assertEquals(Boolean.valueOf(query.get("revs")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("revs_info")), Boolean.valueOf(false));
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getReplicationDocumentPath);
}
use of com.ibm.cloud.cloudant.v1.model.ReplicationDocument in project cloudant-java-sdk by IBM.
the class ReplicationDocumentTest method testReplicationDocument.
@Test
public void testReplicationDocument() 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");
String json = TestUtilities.serialize(replicationDocumentModel);
ReplicationDocument replicationDocumentModelNew = TestUtilities.deserialize(json, ReplicationDocument.class);
assertTrue(replicationDocumentModelNew instanceof ReplicationDocument);
assertEquals(replicationDocumentModelNew.isDeleted(), Boolean.valueOf(true));
assertEquals(replicationDocumentModelNew.getId(), "testString");
assertEquals(replicationDocumentModelNew.getLocalSeq(), "testString");
assertEquals(replicationDocumentModelNew.getRev(), "testString");
assertEquals(replicationDocumentModelNew.getRevisions().toString(), revisionsModel.toString());
assertEquals(replicationDocumentModelNew.isCancel(), Boolean.valueOf(true));
assertEquals(replicationDocumentModelNew.getCheckpointInterval(), Long.valueOf("0"));
assertEquals(replicationDocumentModelNew.getConnectionTimeout(), Long.valueOf("0"));
assertEquals(replicationDocumentModelNew.isContinuous(), Boolean.valueOf(false));
assertEquals(replicationDocumentModelNew.isCreateTarget(), Boolean.valueOf(false));
assertEquals(replicationDocumentModelNew.getCreateTargetParams().toString(), replicationCreateTargetParametersModel.toString());
assertEquals(replicationDocumentModelNew.getFilter(), "testString");
assertEquals(replicationDocumentModelNew.getHttpConnections(), Long.valueOf("1"));
assertEquals(replicationDocumentModelNew.getRetriesPerRequest(), Long.valueOf("0"));
assertEquals(replicationDocumentModelNew.getSinceSeq(), "testString");
assertEquals(replicationDocumentModelNew.getSocketOptions(), "testString");
assertEquals(replicationDocumentModelNew.getSource().toString(), replicationDatabaseModel.toString());
assertEquals(replicationDocumentModelNew.getSourceProxy(), "testString");
assertEquals(replicationDocumentModelNew.getTarget().toString(), replicationDatabaseModel.toString());
assertEquals(replicationDocumentModelNew.getTargetProxy(), "testString");
assertEquals(replicationDocumentModelNew.isUseCheckpoints(), Boolean.valueOf(true));
assertEquals(replicationDocumentModelNew.getUserCtx().toString(), userContextModel.toString());
assertEquals(replicationDocumentModelNew.getWorkerBatchSize(), Long.valueOf("1"));
assertEquals(replicationDocumentModelNew.getWorkerProcesses(), Long.valueOf("1"));
assertEquals(replicationDocumentModelNew.get("foo"), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.ReplicationDocument 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");
}
use of com.ibm.cloud.cloudant.v1.model.ReplicationDocument in project cloudant-java-sdk by IBM.
the class CloudantTest method testPutReplicationDocumentWOptions.
@Test
public void testPutReplicationDocumentWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\"}";
String putReplicationDocumentPath = "/_replicator/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 ReplicationCreateTargetParameters model
ReplicationCreateTargetParameters replicationCreateTargetParametersModel = new ReplicationCreateTargetParameters.Builder().n(Long.valueOf("1")).partitioned(false).q(Long.valueOf("26")).build();
// Construct an instance of the ReplicationDatabaseAuthBasic model
ReplicationDatabaseAuthBasic replicationDatabaseAuthBasicModel = new ReplicationDatabaseAuthBasic.Builder().password("testString").username("testString").build();
// Construct an instance of the ReplicationDatabaseAuthIam model
ReplicationDatabaseAuthIam replicationDatabaseAuthIamModel = new ReplicationDatabaseAuthIam.Builder().apiKey("testString").build();
// Construct an instance of the ReplicationDatabaseAuth model
ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder().basic(replicationDatabaseAuthBasicModel).iam(replicationDatabaseAuthIamModel).build();
// Construct an instance of the ReplicationDatabase model
ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder().auth(replicationDatabaseAuthModel).headers(new java.util.HashMap<String, String>() {
{
put("foo", "testString");
}
}).url("testString").build();
// Construct an instance of the UserContext model
UserContext userContextModel = new UserContext.Builder().db("testString").name("testString").roles(new java.util.ArrayList<String>(java.util.Arrays.asList("_reader"))).build();
// Construct an instance of the ReplicationDocument model
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();
// Construct an instance of the PutReplicationDocumentOptions model
PutReplicationDocumentOptions putReplicationDocumentOptionsModel = new PutReplicationDocumentOptions.Builder().docId("testString").replicationDocument(replicationDocumentModel).ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
// Invoke operation with valid options model (positive test)
Response<DocumentResult> response = cloudantService.putReplicationDocument(putReplicationDocumentOptionsModel).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, putReplicationDocumentPath);
}
Aggregations