Source:
<code>public void testReplicationDocWithEmptyId() throws Exception { CouchDB mockRemoteDb = mock(CouchDB.class); when(mockRemoteDb.changes(null, null, 1000)).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { JSONHelper jsonHelper = new JSONHelper(); FileReader fr = new FileReader(TestUtils.loadFixture("fixture/empty_docid.json")); return jsonHelper.fromJson(fr, ChangesResult.class); } }); when(mockRemoteDb.exists()).thenReturn(true); Collection<String> revs = new ArrayList<String>(); revs.add("1-bd42b942b8b672f0289cf3cd1f67044c"); when(mockRemoteDb.getRevisions("", revs, new HashSet<String>(), false)).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { JSONHelper helper = new JSONHelper(); FileReader fileReader = new FileReader(TestUtils.loadFixture ("fixture/empty_docid_open_revs.json")); List<OpenRevision> openRevs = helper.fromJson(fileReader, new TypeReference<List<OpenRevision>>() { }); List<DocumentRevs> documentRevs = new ArrayList<DocumentRevs>(); for (OpenRevision openRev : openRevs) { if (openRev instanceof OkOpenRevision) { documentRevs.add(((OkOpenRevision) openRev).getDocumentRevs()); } } return documentRevs; } }); StrategyListener mockListener = mock(StrategyListener.class); final BasicPullStrategy pullStrategy = new BasicPullStrategy(createPullReplication()); pullStrategy.sourceDb = mockRemoteDb; pullStrategy.getEventBus().register(mockListener); pullStrategy.run(); Assert.assertEquals(this.datastore.getDocumentCount(),0); verify(mockListener).complete(any(ReplicationStrategyCompleted.class)); verify(mockListener,never()).error(any(ReplicationStrategyErrored.class)); <START> } <END></code><technical_language>good if do that, catch more future regressions</technical_language>

Target:
public void testReplicationDocWithEmptyId() throws Exception { CouchDB mockRemoteDb = mock(CouchDB.class); when(mockRemoteDb.changes(null, null, 1000)).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { JSONHelper jsonHelper = new JSONHelper(); FileReader fr = new FileReader(TestUtils.loadFixture("fixture/testReplicationDocWithEmptyId_changes.json")); return jsonHelper.fromJson(fr, ChangesResult.class); } }); when(mockRemoteDb.exists()).thenReturn(true); Collection<String> revs = new ArrayList<String>(); revs.add("1-bd42b942b8b672f0289cf3cd1f67044c"); when(mockRemoteDb.getRevisions("", revs, new HashSet<String>(), false)).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return loadOpenRevsResponseFromFixture("testReplicationDocWithEmptyId_open_revs_1.json"); } }); revs = new ArrayList<String>(); revs.add("1-13d33701a0954729ad029adf8fdc5a04"); when(mockRemoteDb.getRevisions("4d3b3f01362649d79b31d9092799a7e0", revs, new HashSet<String>(),false)).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return loadOpenRevsResponseFromFixture("fixture/testReplicationDocWithEmptyId_open_revs_2.json"); } }); StrategyListener mockListener = mock(StrategyListener.class); final BasicPullStrategy pullStrategy = new BasicPullStrategy(createPullReplication()); pullStrategy.sourceDb = mockRemoteDb; pullStrategy.getEventBus().register(mockListener); pullStrategy.run(); Assert.assertEquals(this.datastore.getDocumentCount(), 1); verify(mockListener).complete(any(ReplicationStrategyCompleted.class)); verify(mockListener,never()).error(any(ReplicationStrategyErrored.class)); }