### Question:
StreamedCouchDbConnector extends StdCouchDbConnector { @Override public void update(final Object o) { Assert.notNull(o, "Document cannot be null"); final String id = Documents.getId(o); assertDocIdHasValue(id); HttpEntity entity = createHttpEntity(o); restTemplate.put(dbURI.append(id).toString(), entity, new StdResponseHandler<Void>() { @Override public Void success(HttpResponse hr) throws Exception { JsonNode n = objectMapper.readValue(hr.getContent(), JsonNode.class); Documents.setRevision(o, n.get("rev").textValue()); return null; } @Override public Void error(HttpResponse hr) { if (hr.getCode() == HttpStatus.CONFLICT) { throw new UpdateConflictException(id, Documents .getRevision(o)); } return super.error(hr); } }); } StreamedCouchDbConnector(String databaseName, CouchDbInstance dbInstance);  StreamedCouchDbConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om); @Override void create(final Object o); @Override void create(String id, Object node); @Override PurgeResult purge(Map<String, List<String>> revisionsToPurge); @Override void update(final Object o);  }### Answer:
@Test public void update() throws IOException { td.setId("some_id"); td.setRevision("123D123"); final ByteArrayOutputStream output = new ByteArrayOutputStream(); doAnswer(new MarshallEntityAndReturnAnswer(output, HttpResponseStub.valueOf(201, OK_RESPONSE_WITH_ID_AND_REV))).when(httpClient).put(anyString(), any(HttpEntity.class)); dbCon.update(td); ArgumentCaptor<HttpEntity> ac = ArgumentCaptor.forClass(HttpEntity.class); verify(httpClient).put(eq("/test_db/some_id"), ac.capture()); assertEquals("some_id", td.getId()); assertEquals("123D123", td.getRevision()); assertEqualJson("update.json", Charset.forName("UTF-8"), output.toByteArray()); }
@Test(expected = UpdateConflictException.class) public void throw_exception_when_in_conflict() { td.setId("some_id"); td.setRevision("123D123"); final ByteArrayOutputStream output = new ByteArrayOutputStream(); doAnswer(new MarshallEntityAndReturnAnswer(output, ResponseOnFileStub.newInstance(409, "update_conflict.json"))).when(httpClient).put(anyString(), any(HttpEntity.class)); dbCon.update(td); }