Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jackson improvements

  • Loading branch information...
commit 8f10b36b8cfd585909e9261e4353abad3cb35b11 1 parent cfb7c0a
@rnewson rnewson authored
View
11 src/main/java/com/github/rnewson/couchdb/lucene/pojo/Document.java
@@ -33,10 +33,16 @@ public static Document deletedDocument(final String id) {
private String id;
+ private String revision;
+
public String getId() {
return id;
}
+ public String getRevision() {
+ return revision;
+ }
+
public boolean isDeleted() {
return deleted;
}
@@ -51,4 +57,9 @@ public void setId(final String id) {
this.id = id;
}
+ @JsonProperty("_rev")
+ public void setRevision(final String revision) {
+ this.revision = revision;
+ }
+
}
View
9 src/main/java/com/github/rnewson/couchdb/lucene/pojo/ViewRow.java
@@ -5,10 +5,15 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class ViewRow {
+ private Document doc;
private String id;
private String key;
private Object value;
+ public Document getDoc() {
+ return doc;
+ }
+
public String getId() {
return id;
}
@@ -21,6 +26,10 @@ public Object getValue() {
return value;
}
+ public void setDoc(final Document doc) {
+ this.doc = doc;
+ }
+
public void setId(final String id) {
this.id = id;
}
View
5 src/test/java/com/github/rnewson/couchdb/lucene/pojo/DocumentTest.java
@@ -30,7 +30,10 @@
@Test
public void testDocument() throws JsonProcessingException, IOException {
- final String str = "{\"_id\":\"foo\",\"_rev\":\"2-7051cbe5c8faecd085a3fa619e6e6337\"}";
+ final String str = "{\"_id\":\"foo\",\"_rev\":\"1-cd533285df9f7bf140d77b6bfb9eb2a3\","
+ + "\"text\":\"hello\",\"number\":1176,"
+ + "\"_attachments\":{\"foo\":{\"content_type\":\"text/plain\",\"revpos\":1,"
+ + "\"length\":229,\"stub\":true}}}";
final Document doc = mapper.readValue(str, Document.class);
assertThat(doc.getId(), is("foo"));
assertThat(doc.isDeleted(), is(false));
View
7 src/test/java/com/github/rnewson/couchdb/lucene/pojo/ViewResultTest.java
@@ -10,14 +10,17 @@
@Test
public void testViewResult() throws Exception {
final String str = "{\"total_rows\":1192,\"offset\":1,\"rows\":[\n"
- + "{\"id\":\"1f5195d6bc0a5973315e4a2710000d39\",\"key\":\"1f5195d6bc0a5973315e4a2710000d39\",\"value\":{\"rev\":\"2-7051cbe5c8faecd085a3fa619e6e6337\"}},\n"
- + "{\"id\":\"78596fc515b05ce7651b6d9c0800068a\",\"key\":\"78596fc515b05ce7651b6d9c0800068a\",\"value\":{\"rev\":\"1-4ce1e301f5d615c8f06891016d23365a\"}}\n"
+ + "{\"id\":\"1f5195d6bc0a5973315e4a2710000d39\",\"key\":\"1f5195d6bc0a5973315e4a2710000d39\","
+ + "\"value\":{\"rev\":\"2-7051cbe5c8faecd085a3fa619e6e6337\"},\"doc\":{\"_id\":\"foo\"}},\n"
+ + "{\"id\":\"78596fc515b05ce7651b6d9c0800068a\",\"key\":\"78596fc515b05ce7651b6d9c0800068a\","
+ + "\"value\":{\"rev\":\"1-4ce1e301f5d615c8f06891016d23365a\"}}\n"
+ "]}";
final ViewResult results = mapper.readValue(str, ViewResult.class);
assertThat(results.getTotalRows(), is(1192L));
assertThat(results.getOffset(), is(1L));
assertThat(results.getRow(0).getId(),
is("1f5195d6bc0a5973315e4a2710000d39"));
+ assertThat(results.getRow(0).getDoc().getId(), is("foo"));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.