Search in sources :

Example 6 with Revisions

use of com.ibm.cloud.cloudant.v1.model.Revisions 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");
}
Also used : ArrayList(java.util.ArrayList) Attachment(com.ibm.cloud.cloudant.v1.model.Attachment) Revisions(com.ibm.cloud.cloudant.v1.model.Revisions) DocumentRevisionStatus(com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus) ReplicationDocument(com.ibm.cloud.cloudant.v1.model.ReplicationDocument) ReplicationDatabaseAuthBasic(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic) ReplicationDatabaseAuthIam(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam) UserContext(com.ibm.cloud.cloudant.v1.model.UserContext) ReplicationCreateTargetParameters(com.ibm.cloud.cloudant.v1.model.ReplicationCreateTargetParameters) ReplicationDatabase(com.ibm.cloud.cloudant.v1.model.ReplicationDatabase) ReplicationDatabaseAuth(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth) Test(org.testng.annotations.Test)

Example 7 with Revisions

use of com.ibm.cloud.cloudant.v1.model.Revisions in project cloudant-java-sdk by IBM.

the class RevisionsTest method testRevisions.

@Test
public void testRevisions() throws Throwable {
    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"));
    String json = TestUtilities.serialize(revisionsModel);
    Revisions revisionsModelNew = TestUtilities.deserialize(json, Revisions.class);
    assertTrue(revisionsModelNew instanceof Revisions);
    assertEquals(revisionsModelNew.start(), Long.valueOf("1"));
}
Also used : Revisions(com.ibm.cloud.cloudant.v1.model.Revisions) Test(org.testng.annotations.Test)

Example 8 with Revisions

use of com.ibm.cloud.cloudant.v1.model.Revisions 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");
}
Also used : ArrayList(java.util.ArrayList) Attachment(com.ibm.cloud.cloudant.v1.model.Attachment) Revisions(com.ibm.cloud.cloudant.v1.model.Revisions) DocumentRevisionStatus(com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus) ReplicationDocument(com.ibm.cloud.cloudant.v1.model.ReplicationDocument) ReplicationDatabaseAuthBasic(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic) ReplicationDatabaseAuthIam(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam) UserContext(com.ibm.cloud.cloudant.v1.model.UserContext) PutReplicationDocumentOptions(com.ibm.cloud.cloudant.v1.model.PutReplicationDocumentOptions) ReplicationCreateTargetParameters(com.ibm.cloud.cloudant.v1.model.ReplicationCreateTargetParameters) ReplicationDatabase(com.ibm.cloud.cloudant.v1.model.ReplicationDatabase) ReplicationDatabaseAuth(com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth) Test(org.testng.annotations.Test)

Example 9 with Revisions

use of com.ibm.cloud.cloudant.v1.model.Revisions in project cloudant-java-sdk by IBM.

the class PutDesignDocumentOptionsTest method testPutDesignDocumentOptions.

@Test
public void testPutDesignDocumentOptions() 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");
    Analyzer analyzerModel = new Analyzer.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
    assertEquals(analyzerModel.name(), "classic");
    assertEquals(analyzerModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    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();
    assertEquals(analyzerConfigurationModel.name(), "classic");
    assertEquals(analyzerConfigurationModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    assertEquals(analyzerConfigurationModel.fields(), new java.util.HashMap<String, Analyzer>() {

        {
            put("foo", analyzerModel);
        }
    });
    SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder().analyzer(analyzerConfigurationModel).index("testString").build();
    assertEquals(searchIndexDefinitionModel.analyzer(), analyzerConfigurationModel);
    assertEquals(searchIndexDefinitionModel.index(), "testString");
    DesignDocumentOptions designDocumentOptionsModel = new DesignDocumentOptions.Builder().partitioned(true).build();
    assertEquals(designDocumentOptionsModel.partitioned(), Boolean.valueOf(true));
    DesignDocumentViewsMapReduce designDocumentViewsMapReduceModel = new DesignDocumentViewsMapReduce.Builder().map("testString").reduce("testString").build();
    assertEquals(designDocumentViewsMapReduceModel.map(), "testString");
    assertEquals(designDocumentViewsMapReduceModel.reduce(), "testString");
    GeoIndexDefinition geoIndexDefinitionModel = new GeoIndexDefinition.Builder().index("testString").build();
    assertEquals(geoIndexDefinitionModel.index(), "testString");
    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();
    assertEquals(designDocumentModel.getAttachments(), new java.util.HashMap<String, Attachment>() {

        {
            put("foo", attachmentModel);
        }
    });
    assertEquals(designDocumentModel.getConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    assertEquals(designDocumentModel.isDeleted(), Boolean.valueOf(true));
    assertEquals(designDocumentModel.getDeletedConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    assertEquals(designDocumentModel.getId(), "testString");
    assertEquals(designDocumentModel.getLocalSeq(), "testString");
    assertEquals(designDocumentModel.getRev(), "testString");
    assertEquals(designDocumentModel.getRevisions(), revisionsModel);
    assertEquals(designDocumentModel.getRevsInfo(), new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel)));
    assertEquals(designDocumentModel.isAutoupdate(), Boolean.valueOf(true));
    assertEquals(designDocumentModel.getFilters(), new java.util.HashMap<String, String>() {

        {
            put("foo", "testString");
        }
    });
    assertEquals(designDocumentModel.getIndexes(), new java.util.HashMap<String, SearchIndexDefinition>() {

        {
            put("foo", searchIndexDefinitionModel);
        }
    });
    assertEquals(designDocumentModel.getLanguage(), "javascript");
    assertEquals(designDocumentModel.getOptions(), designDocumentOptionsModel);
    assertEquals(designDocumentModel.getValidateDocUpdate(), "testString");
    assertEquals(designDocumentModel.getViews(), new java.util.HashMap<String, DesignDocumentViewsMapReduce>() {

        {
            put("foo", designDocumentViewsMapReduceModel);
        }
    });
    assertEquals(designDocumentModel.getStIndexes(), new java.util.HashMap<String, GeoIndexDefinition>() {

        {
            put("foo", geoIndexDefinitionModel);
        }
    });
    assertEquals(designDocumentModel.get("foo"), "testString");
    PutDesignDocumentOptions putDesignDocumentOptionsModel = new PutDesignDocumentOptions.Builder().db("testString").ddoc("testString").designDocument(designDocumentModel).ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
    assertEquals(putDesignDocumentOptionsModel.db(), "testString");
    assertEquals(putDesignDocumentOptionsModel.ddoc(), "testString");
    assertEquals(putDesignDocumentOptionsModel.designDocument(), designDocumentModel);
    assertEquals(putDesignDocumentOptionsModel.ifMatch(), "testString");
    assertEquals(putDesignDocumentOptionsModel.batch(), "ok");
    assertEquals(putDesignDocumentOptionsModel.newEdits(), Boolean.valueOf(false));
    assertEquals(putDesignDocumentOptionsModel.rev(), "testString");
}
Also used : PutDesignDocumentOptions(com.ibm.cloud.cloudant.v1.model.PutDesignDocumentOptions) HashMap(java.util.HashMap) SearchIndexDefinition(com.ibm.cloud.cloudant.v1.model.SearchIndexDefinition) ArrayList(java.util.ArrayList) Attachment(com.ibm.cloud.cloudant.v1.model.Attachment) Revisions(com.ibm.cloud.cloudant.v1.model.Revisions) Analyzer(com.ibm.cloud.cloudant.v1.model.Analyzer) DocumentRevisionStatus(com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus) DesignDocumentViewsMapReduce(com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce) DesignDocumentOptions(com.ibm.cloud.cloudant.v1.model.DesignDocumentOptions) PutDesignDocumentOptions(com.ibm.cloud.cloudant.v1.model.PutDesignDocumentOptions) DesignDocument(com.ibm.cloud.cloudant.v1.model.DesignDocument) AnalyzerConfiguration(com.ibm.cloud.cloudant.v1.model.AnalyzerConfiguration) GeoIndexDefinition(com.ibm.cloud.cloudant.v1.model.GeoIndexDefinition) Test(org.testng.annotations.Test)

Example 10 with Revisions

use of com.ibm.cloud.cloudant.v1.model.Revisions in project cloudant-java-sdk by IBM.

the class PutDocumentOptionsTest method testPutDocumentOptions.

@Test
public void testPutDocumentOptions() 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");
    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("testString").localSeq("testString").rev("testString").revisions(revisionsModel).revsInfo(new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel))).add("foo", "testString").build();
    assertEquals(documentModel.getAttachments(), new java.util.HashMap<String, Attachment>() {

        {
            put("foo", attachmentModel);
        }
    });
    assertEquals(documentModel.getConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    assertEquals(documentModel.isDeleted(), Boolean.valueOf(true));
    assertEquals(documentModel.getDeletedConflicts(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
    assertEquals(documentModel.getId(), "testString");
    assertEquals(documentModel.getLocalSeq(), "testString");
    assertEquals(documentModel.getRev(), "testString");
    assertEquals(documentModel.getRevisions(), revisionsModel);
    assertEquals(documentModel.getRevsInfo(), new java.util.ArrayList<DocumentRevisionStatus>(java.util.Arrays.asList(documentRevisionStatusModel)));
    assertEquals(documentModel.get("foo"), "testString");
    PutDocumentOptions putDocumentOptionsModel = new PutDocumentOptions.Builder().db("testString").docId("testString").document(documentModel).body(TestUtilities.createMockStream("This is a mock file.")).contentType("application/json").ifMatch("testString").batch("ok").newEdits(false).rev("testString").build();
    assertEquals(putDocumentOptionsModel.db(), "testString");
    assertEquals(putDocumentOptionsModel.docId(), "testString");
    assertEquals(putDocumentOptionsModel.document(), documentModel);
    assertEquals(IOUtils.toString(putDocumentOptionsModel.body()), IOUtils.toString(TestUtilities.createMockStream("This is a mock file.")));
    assertEquals(putDocumentOptionsModel.contentType(), "application/json");
    assertEquals(putDocumentOptionsModel.ifMatch(), "testString");
    assertEquals(putDocumentOptionsModel.batch(), "ok");
    assertEquals(putDocumentOptionsModel.newEdits(), Boolean.valueOf(false));
    assertEquals(putDocumentOptionsModel.rev(), "testString");
}
Also used : ArrayList(java.util.ArrayList) Attachment(com.ibm.cloud.cloudant.v1.model.Attachment) Revisions(com.ibm.cloud.cloudant.v1.model.Revisions) Document(com.ibm.cloud.cloudant.v1.model.Document) DocumentRevisionStatus(com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus) PutDocumentOptions(com.ibm.cloud.cloudant.v1.model.PutDocumentOptions) Test(org.testng.annotations.Test)

Aggregations

Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)17 Test (org.testng.annotations.Test)17 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)16 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)16 ArrayList (java.util.ArrayList)16 Document (com.ibm.cloud.cloudant.v1.model.Document)10 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)7 ReplicationDocument (com.ibm.cloud.cloudant.v1.model.ReplicationDocument)7 HashMap (java.util.HashMap)7 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)6 MockResponse (okhttp3.mockwebserver.MockResponse)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BulkGetQueryDocument (com.ibm.cloud.cloudant.v1.model.BulkGetQueryDocument)4 BulkGetResultDocument (com.ibm.cloud.cloudant.v1.model.BulkGetResultDocument)4 SchedulerDocument (com.ibm.cloud.cloudant.v1.model.SchedulerDocument)4 Analyzer (com.ibm.cloud.cloudant.v1.model.Analyzer)3 AnalyzerConfiguration (com.ibm.cloud.cloudant.v1.model.AnalyzerConfiguration)3 BulkDocs (com.ibm.cloud.cloudant.v1.model.BulkDocs)3 DesignDocumentOptions (com.ibm.cloud.cloudant.v1.model.DesignDocumentOptions)3