### Question:
RevisionHistoryHelper { public static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history) { return revisionHistoryToJson(history, null, false, 0); }  static List<String> getRevisionPath(DocumentRevs documentRevs); static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history); static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history,
                                                            Map<String, ? extends Attachment> attachments,
                                                            boolean shouldInline,
                                                            int minRevPos); static boolean shouldInline(Map<String, ? extends Attachment> attachments,
                                PushAttachmentsInline inlinePreference,
                                int minRevPos); static MultipartAttachmentWriter createMultipartWriter(Map<String,Object> revision,
                                                                  Map<String, ? extends Attachment> attachments,
                                                                  boolean shouldInline,
                                                                  int minRevPos);  }### Answer:
@Test public void revisionHistoryToJson_oneRevisionInHistory_success() { Map m = new HashMap<String, Object>(); m.put("name", "Tom"); List<InternalDocumentRevision> d = createDBObjects("Tom", "1-a"); String json = JSONUtils.toJson(RevisionHistoryHelper.revisionHistoryToJson(d)); DocumentRevs documentRevs = JSONUtils.fromJson(new StringReader(json), DocumentRevs.class); Assert.assertEquals("1", documentRevs.getId()); Assert.assertEquals("1-a", documentRevs.getRev()); Assert.assertThat(documentRevs.getOthers().entrySet(), equalTo(m.entrySet())); Assert.assertEquals(1, documentRevs.getRevisions().getStart()); Assert.assertThat(documentRevs.getRevisions().getIds(), equalTo(Arrays.asList("a"))); }
@Test public void revisionHistoryToJson_twoRevisionsInHistory_success() { Map m = new HashMap<String, Object>(); m.put("name", "Tom"); List<InternalDocumentRevision> d = createDBObjects("Tom", "2-b", "1-a"); String json = JSONUtils.toJson(RevisionHistoryHelper.revisionHistoryToJson(d)); DocumentRevs documentRevs = JSONUtils.fromJson(new StringReader(json), DocumentRevs.class); Assert.assertEquals("1", documentRevs.getId()); Assert.assertEquals("2-b", documentRevs.getRev()); Assert.assertThat(documentRevs.getOthers().entrySet(), equalTo(m.entrySet())); Assert.assertEquals(2, documentRevs.getRevisions().getStart()); Assert.assertThat(documentRevs.getRevisions().getIds(), equalTo(Arrays.asList("b", "a"))); }
@Test(expected = IllegalArgumentException.class) public void revisionHistoryToJson_historyIsInAscendingOrder_exception() { List<InternalDocumentRevision> d = createDBObjects("Tom", "1-a", "2-b"); RevisionHistoryHelper.revisionHistoryToJson(d); }
@Test(expected = IllegalArgumentException.class) public void revisionHistoryToJson_null_exception() { RevisionHistoryHelper.revisionHistoryToJson(null); }
@Test(expected = IllegalArgumentException.class) public void revisionHistoryToJson_zeroLengthHistory_exception() { RevisionHistoryHelper.revisionHistoryToJson(new ArrayList<InternalDocumentRevision>()); }