package com.couchbase.cblite;

import com.couchbase.cblite.testapp.tests.CBLiteTestCase;

import junit.framework.Assert;

import java.util.HashMap;
import java.util.Map;

public class DocumentTest extends CBLiteTestCase {

    public void testNewDocumentHasCurrentRevision() throws CBLiteException {

        CBLDocument document = database.createDocument();
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("foo", "foo");
        properties.put("bar", Boolean.FALSE);
        document.putProperties(properties);
        Assert.assertNotNull(document.getCurrentRevision());

    }

    public void testDeleteDocument() throws CBLiteException {

        CBLDocument document = database.createDocument();
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("foo", "foo");
        properties.put("bar", Boolean.FALSE);
        document.putProperties(properties);
        Assert.assertNotNull(document.getCurrentRevision());
        String docId = document.getId();
        document.delete();
        CBLDocument fetchedDoc = database.getExistingDocument(docId);
        Assert.assertNull(fetchedDoc);

    }

}
@@ -141,16 +141,43 @@
 ashMap;%0A
+import java.util.Iterator;%0A
 import j
@@ -1094,24 +1094,73 @@
 t.delete();%0A
+        Assert.assertTrue(document.isDeleted());%0A
         CBLD
@@ -1253,20 +1253,469 @@
 tchedDoc);%0A%0A
+        // query all docs and make sure we don't see that document%0A        database.getAllDocs(new CBLQueryOptions());%0A        CBLQuery queryAllDocs = database.queryAllDocuments();%0A        CBLQueryEnumerator queryEnumerator = queryAllDocs.getRows();%0A        for (Iterator%3CCBLQueryRow%3E it = queryEnumerator; it.hasNext();) %7B%0A            CBLQueryRow row = it.next();%0A            Assert.assertFalse(row.getDocument().getId().equals(docId));%0A        %7D%0A%0A
     %7D%0A%0A%7D

enhance testDeleteDocument()