Package com.couchace.core.api.response

Examples of com.couchace.core.api.response.TextDocument


                        // We have what we needed, stop parsing.
                        break;
                    }
                }

                return new TextDocument(documentId, revision, null, json);
            }
        } catch (IOException e) {
            throw new CouchJsonException(e);
        }
    }
View Full Code Here


                                }
                                revision = (revNode != null) ? revNode.asText() : null;
                            }

                            // Create the document
                            documentList.add(new TextDocument(
                                    id,
                                    revision,
                                    jsonKey,
                                    content
                            ));
View Full Code Here

public class ReadDocumentTest {

    private JacksonCouchJsonStrategy strategy = JacksonTestSetup.strategy;

    public void petTextDocumentTest() {
        TextDocument couchDocument = strategy.readTextDocument(JacksonTestSetup.petDocJson);
        assertEquals(couchDocument.getDocumentId(), "7889");
        assertEquals(couchDocument.getDocumentRevision(), "1-8765");
        String content = couchDocument.getContent();
        assertNotNull(content);
        assertTrue(content.contains("\"_id\":\"7889\","), content);
        assertTrue(content.contains("\"type\":\"DOG\","), content);
        assertEquals(couchDocument.getContent(), JacksonTestSetup.petDocJson);
    }
View Full Code Here

        // Get updated doc one
        GetDocumentResponse getResponse = couchDatabase.get().document(docOneId).execute();
        assertEquals(getResponse.getHttpStatus(), CouchHttpStatus.OK);
        assertEquals(getResponse.getDocumentCount(), 1);
        TextDocument document = getResponse.getFirstDocument();
        assertEquals(document.getDocumentId(), docOneId);
        assertEquals(document.getDocumentRevision(), docOneVersion);
        assertTrue(document.getContent().contains("\"direction\":\"NORTH EAST\",\"city\":\"Toronto\""), document.getContent());

        // Put update to document one, back to original
        putResponse = couchDatabase.put().document(docOneId, docOneJson, docOneVersion).execute();
        assertEquals(putResponse.getHttpStatus(), CouchHttpStatus.CREATED);
        assertTrue(putResponse.isCreated());
View Full Code Here

    public void petViewWithDocsTest() {

        List<TextDocument> couchDocuments = strategy.readTextDocuments(JacksonTestSetup.petViewWithDocs);
        assertEquals(couchDocuments.size(), 2);

        TextDocument couchDocument = couchDocuments.get(0);
        assertEquals(couchDocument.getDocumentId(), "7889");
        assertEquals(couchDocument.getDocumentRevision(), "1-8765");
        String content = couchDocument.getContent();
        assertNotNull(content);
        assertTrue(content.contains("\"_id\":\"7889\","), content);
        assertTrue(content.contains("\"type\":\"DOG\","), content);
        assertEquals(couchDocument.getContent(), JacksonTestSetup.petDocJson);

        couchDocument = couchDocuments.get(1);
        assertEquals(couchDocument.getDocumentRevision(), "1-99222");
        assertEquals(couchDocument.getDocumentId(), "9999");
        content = couchDocument.getContent();
        assertNotNull(content);
        assertTrue(content.contains("\"_id\":\"9999\","), content);
        assertTrue(content.contains("\"type\":\"DOG\","), content);
        assertTrue(content.contains("\"name\":\"Rocky\","), content);
    }
View Full Code Here

        GetDocumentResponse docResponse = couchDatabase.get().document(docThreeId).execute();
        assertEquals(docResponse.getHttpStatus(), CouchHttpStatus.OK);
        assertTrue(docResponse.isOk());
        assertEquals(docResponse.getContentType(), CouchMediaType.APPLICATION_JSON);
        assertEquals(docResponse.getDocumentCount(), 1);
        TextDocument document = docResponse.getFirstDocument();
        assertNotNull(document.getDocumentRevision());
        assertEquals(document.getDocumentRevision(), docThreeVersion);
        assertEquals(document.getContent(), buildFresnoGetResponseContent());

    }
View Full Code Here

        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK);
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.APPLICATION_JSON);
        assertEquals(response.getDocumentCount(), 1);
        TextDocument document = response.getFirstDocument();
        assertNotNull(document.getDocumentRevision());
        assertEquals(document.getContent(), buildTorontoGetResponseContent());

    }
View Full Code Here

        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK);
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.APPLICATION_JSON);
        assertEquals(response.getDocumentCount(), 1);
        TextDocument document = response.getFirstDocument();
        assertNotNull(document.getDocumentRevision());
        assertEquals(document.getContent(), buildTorontoGetResponseContent());

    }
View Full Code Here

        // Retrieve the raw document and ensure the id is not part of the entity body.
        GetDocumentResponse response = couchDatabase
                .get()
                .document(firebirdId)
                .execute();
        TextDocument textDocument = response.getFirstDocument();
        String content = textDocument.getContent();
        ObjectMapper objectMapper = new ObjectMapper();
        Map map = objectMapper.readValue(content, Map.class);
        Map entity = (Map) map.get("entity");
        assertFalse(entity.containsKey("id"), "The entity body stored in couch contains the id.");
View Full Code Here

                        // We have what we needed, stop parsing.
                        break;
                    }
                }

                return new TextDocument(documentId, revision, null, json);
            }
        } catch (IOException e) {
            throw new CouchJsonException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.couchace.core.api.response.TextDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.