/**
  * The document this row was mapped from. This will be nil if a grouping was enabled in the query,
  * because then the result rows don't correspond to individual documents.
  */
 @InterfaceAudience.Public
 public Document getDocument() {
   if (getDocumentId() == null) {
     return null;
   }
   assert (database != null);
   Document document = database.getDocument(getDocumentId());
   document.loadCurrentRevisionFrom(this);
   return document;
 }
 /**
  * Returns all conflicting revisions of the document, or nil if the document is not in conflict.
  *
  * <p>The first object in the array will be the default "winning" revision that shadows the
  * others. This is only valid in an allDocuments query whose allDocsMode is set to
  * Query.AllDocsMode.SHOW_CONFLICTS or Query.AllDocsMode.ONLY_CONFLICTS; otherwise it returns an
  * empty list.
  */
 @InterfaceAudience.Public
 public List<SavedRevision> getConflictingRevisions() {
   Document doc = database.getDocument(sourceDocID);
   Map<String, Object> valueTmp = (Map<String, Object>) value;
   List<String> conflicts = (List<String>) valueTmp.get("_conflicts");
   if (conflicts == null) {
     conflicts = new ArrayList<String>();
   }
   List<SavedRevision> conflictingRevisions = new ArrayList<SavedRevision>();
   for (String conflictRevisionId : conflicts) {
     SavedRevision revision = doc.getRevision(conflictRevisionId);
     conflictingRevisions.add(revision);
   }
   return conflictingRevisions;
 }
  // depends on testRunPushReplication
  private void testRunPullReplication() throws Throwable {
    URL remoteDbURL = new URL(syncGatewayUrl + pushThenPullDBName);
    Database db = startDatabase();

    Log.i(TAG, "Pulling...");
    Replication repl = db.getPullReplication(remoteDbURL);
    runReplication(repl);
    assertNull(repl.getLastError());

    Log.i(TAG, "Verifying documents...");
    for (int i = 1; i <= kNDocuments; i++) {
      Document doc = db.getDocument("doc-" + i);
      assertEquals(i, doc.getProperty("index"));
      assertEquals(false, doc.getProperty("bar"));
    }
  }