Search in sources :

Example 16 with DocumentRevisionStatus

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

the class DocumentRevisionStatusTest method testDocumentRevisionStatus.

@Test
public void testDocumentRevisionStatus() throws Throwable {
    DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder().rev("testString").status("available").build();
    assertEquals(documentRevisionStatusModel.rev(), "testString");
    assertEquals(documentRevisionStatusModel.status(), "available");
    String json = TestUtilities.serialize(documentRevisionStatusModel);
    DocumentRevisionStatus documentRevisionStatusModelNew = TestUtilities.deserialize(json, DocumentRevisionStatus.class);
    assertTrue(documentRevisionStatusModelNew instanceof DocumentRevisionStatus);
    assertEquals(documentRevisionStatusModelNew.rev(), "testString");
    assertEquals(documentRevisionStatusModelNew.status(), "available");
}
Also used : DocumentRevisionStatus(com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus) Test(org.testng.annotations.Test)

Example 17 with DocumentRevisionStatus

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

the class BulkDocsTest method testBulkDocs.

@Test
public void testBulkDocs() 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");
    BulkDocs bulkDocsModel = new BulkDocs.Builder().docs(new java.util.ArrayList<Document>(java.util.Arrays.asList(documentModel))).newEdits(true).build();
    assertEquals(bulkDocsModel.docs(), new java.util.ArrayList<Document>(java.util.Arrays.asList(documentModel)));
    assertEquals(bulkDocsModel.newEdits(), Boolean.valueOf(true));
    String json = TestUtilities.serialize(bulkDocsModel);
    BulkDocs bulkDocsModelNew = TestUtilities.deserialize(json, BulkDocs.class);
    assertTrue(bulkDocsModelNew instanceof BulkDocs);
    assertEquals(bulkDocsModelNew.newEdits(), Boolean.valueOf(true));
}
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) BulkDocs(com.ibm.cloud.cloudant.v1.model.BulkDocs) Test(org.testng.annotations.Test)

Aggregations

DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)17 Test (org.testng.annotations.Test)17 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)16 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)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 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 HashMap (java.util.HashMap)5 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