CosmosDBDocumentStoreWriter implements DocumentStoreWriter<TimelineDoc> { @VisibleForTesting @SuppressWarnings("unchecked") TimelineDoc applyUpdatesOnPrevDoc(CollectionType collectionType, TimelineDoc timelineDoc, StringBuilder eTagStrBuilder) { TimelineDoc prevDocument = fetchLatestDoc(collectionType, timelineDoc.getId(), eTagStrBuilder); if (prevDocument != null) { prevDocument.merge(timelineDoc); timelineDoc = prevDocument; } return timelineDoc; } CosmosDBDocumentStoreWriter(Configuration conf); @Override void createDatabase(); @Override void createCollection(final String collectionName); @Override void writeDocument(final TimelineDoc timelineDoc,
      final CollectionType collectionType); @Override synchronized void close();  }
@SuppressWarnings("unchecked") @Test public void applyingUpdatesOnPrevDocTest() throws IOException { MockedCosmosDBDocumentStoreWriter documentStoreWriter = new MockedCosmosDBDocumentStoreWriter(null); TimelineEntityDocument actualEntityDoc = new TimelineEntityDocument(); TimelineEntityDocument expectedEntityDoc = DocumentStoreTestUtils.bakeTimelineEntityDoc(); Assert.assertEquals(1, actualEntityDoc.getInfo().size()); Assert.assertEquals(0, actualEntityDoc.getMetrics().size()); Assert.assertEquals(0, actualEntityDoc.getEvents().size()); Assert.assertEquals(0, actualEntityDoc.getConfigs().size()); Assert.assertEquals(0, actualEntityDoc.getIsRelatedToEntities().size()); Assert.assertEquals(0, actualEntityDoc. getRelatesToEntities().size()); actualEntityDoc = (TimelineEntityDocument) documentStoreWriter .applyUpdatesOnPrevDoc(CollectionType.ENTITY, actualEntityDoc, null); Assert.assertEquals(expectedEntityDoc.getInfo().size(), actualEntityDoc.getInfo().size()); Assert.assertEquals(expectedEntityDoc.getMetrics().size(), actualEntityDoc.getMetrics().size()); Assert.assertEquals(expectedEntityDoc.getEvents().size(), actualEntityDoc.getEvents().size()); Assert.assertEquals(expectedEntityDoc.getConfigs().size(), actualEntityDoc.getConfigs().size()); Assert.assertEquals(expectedEntityDoc.getRelatesToEntities().size(), actualEntityDoc.getIsRelatedToEntities().size()); Assert.assertEquals(expectedEntityDoc.getRelatesToEntities().size(), actualEntityDoc.getRelatesToEntities().size()); }