@Test public void dates_should_be_serialized_in_ISO_8601_format() throws IOException { setupNegativeContains("some_id"); 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)); DateTime dt = new DateTime(2010, 4, 25, 20, 11, 24, 555, DateTimeZone.forID("+00:00")); Date d = dt.toDate(); System.out.println(d); DateDoc dd = new DateDoc(); dd.setId("some_id"); dd.setDateTime(dt); dd.setDate(dt.toDate()); dbCon.create(dd); ArgumentCaptor<JacksonableEntity> ac = ArgumentCaptor.forClass(JacksonableEntity.class); verify(httpClient).put(eq("/test_db/some_id"), ac.capture()); byte[] json = output.toByteArray(); assertEqualJson("dates.json", Charset.forName("UTF-8"), json); doReturn(HttpResponseStub.valueOf(201, output.toString("UTF-8"))).when(httpClient).get("/test_db/some_id"); DateDoc deserialized = dbCon.get(DateDoc.class, dd.getId()); assertEquals(dt, deserialized.getDateTime()); assertEquals(d, deserialized.getDate()); }
@Override public void create(final Object o) { Assert.notNull(o, "Document may not be null"); Assert.isTrue(Documents.isNew(o), "Object must be new"); HttpEntity entity = createHttpEntity(o); String id = Documents.getId(o); DocumentOperationResult result; if (id != null && id.length() != 0) { result = restTemplate.put(URIWithDocId(id), entity, revisionHandler); } else { result = restTemplate.post(dbURI.toString(), entity, revisionHandler); Documents.setId(o, result.getId()); } Documents.setRevision(o, result.getRevision()); }
StreamedCouchDbConnector extends StdCouchDbConnector { @Override public void create(final Object o) { Assert.notNull(o, "Document may not be null"); Assert.isTrue(Documents.isNew(o), "Object must be new"); HttpEntity entity = createHttpEntity(o); String id = Documents.getId(o); DocumentOperationResult result; if (id != null && id.length() != 0) { result = restTemplate.put(URIWithDocId(id), entity, revisionHandler); } else { result = restTemplate.post(dbURI.toString(), entity, revisionHandler); Documents.setId(o, result.getId()); } Documents.setRevision(o, result.getRevision()); } }
StreamedCouchDbConnector extends StdCouchDbConnector { @Override public void create(final Object o) { Assert.notNull(o, "Document may not be null"); Assert.isTrue(Documents.isNew(o), "Object must be new"); HttpEntity entity = createHttpEntity(o); String id = Documents.getId(o); DocumentOperationResult result; if (id != null && id.length() != 0) { result = restTemplate.put(URIWithDocId(id), entity, revisionHandler); } else { result = restTemplate.post(dbURI.toString(), entity, revisionHandler); Documents.setId(o, result.getId()); } Documents.setRevision(o, result.getRevision()); } StreamedCouchDbConnector(String databaseName, CouchDbInstance dbInstance);  StreamedCouchDbConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om); }
StreamedCouchDbConnector extends StdCouchDbConnector { @Override public void create(final Object o) { Assert.notNull(o, "Document may not be null"); Assert.isTrue(Documents.isNew(o), "Object must be new"); HttpEntity entity = createHttpEntity(o); String id = Documents.getId(o); DocumentOperationResult result; if (id != null && id.length() != 0) { result = restTemplate.put(URIWithDocId(id), entity, revisionHandler); } else { result = restTemplate.post(dbURI.toString(), entity, revisionHandler); Documents.setId(o, result.getId()); } Documents.setRevision(o, result.getRevision()); } 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); }
StreamedCouchDbConnector extends StdCouchDbConnector { @Override public void create(final Object o) { Assert.notNull(o, "Document may not be null"); Assert.isTrue(Documents.isNew(o), "Object must be new"); HttpEntity entity = createHttpEntity(o); String id = Documents.getId(o); DocumentOperationResult result; if (id != null && id.length() != 0) { result = restTemplate.put(URIWithDocId(id), entity, revisionHandler); } else { result = restTemplate.post(dbURI.toString(), entity, revisionHandler); Documents.setId(o, result.getId()); } Documents.setRevision(o, result.getRevision()); } 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);  }