Package com.couchace.core.api.response

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


        }

        // Add any attachments
        if (entityMeta.hasAttachments()) {
            for (AttachmentMeta attachmentDef : entityMeta.getAttachmentMetaList()) {
                GetAttachmentResponse response = getRequestFactory.attachment(documentId, revision, attachmentDef.getAttachmentName()).execute();
                inject.addValue(attachmentDef.getAttachmentName(), response.getContent());
            }
        }
        return inject;
    }
View Full Code Here


    @BeforeClass
    public void beforeClass() throws Exception {

      // All of this tom-foolerly is simply because @CouchAttachment was added to LocationEntity for the
      // sake of the write test. Here we just want to fake it out so that this part of the test doesn't fail.
      final GetAttachmentResponse response = new GetAttachmentResponse(URI.create("http://whatever.com"), CouchHttpStatus.OK, "x", "x", CouchMediaType.TEXT_PLAIN, "stuff", null);
      getRequestFactory = new GetRequestFactory(null) {
        @Override public GetAttachmentRequest attachment(String documentId, String documentRevision, String attachmentName) {
          return new GetAttachmentRequest(null, documentId, documentRevision, attachmentName) {
            @Override public GetAttachmentResponse execute() {
              return response;
View Full Code Here

    @Test(dependsOnMethods = {"putTest"})
    public void getLatestTest() {

        // Get html
        GetAttachmentResponse response = couchDatabase.get()
                .attachment(attachDocId, "html")
                .execute();
        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK, response.getStringContent());
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.TEXT_HTML);
        assertNotNull(response.getDocumentRevision());
        assertEquals(response.getStringContent(), htmlContent);

        // Get image
        response = couchDatabase.get()
                .attachment(attachDocId, "image")
                .execute();
        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK, response.getStringContent());
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.IMAGE_JPEG);
        assertNotNull(response.getDocumentRevision());
        byte[] responseImageBytes = (byte[]) response.getContent();

        assertEquals(responseImageBytes.length, aceOfSpacesBytes.length);
        assertTrue(Arrays.equals(responseImageBytes, aceOfSpacesBytes));
    }
View Full Code Here

    }

    @Test(dependsOnMethods = {"getLatestTest"})
    public void getVersionTest() {

        GetAttachmentResponse response = couchDatabase.get()
                .attachment(attachDocId, latestRevision, "html")
                .execute();

        // Get html
        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK, response.getStringContent());
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.TEXT_HTML);
        assertNotNull(response.getDocumentRevision());
        assertEquals(response.getStringContent(), htmlContent);

        // Get image
        response = couchDatabase.get().attachment(attachDocId, latestRevision, "image").execute();
        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK, response.getStringContent());
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.IMAGE_JPEG);
        assertNotNull(response.getDocumentRevision());
        byte[] responseImageBytes = (byte[]) response.getContent();

        assertEquals(responseImageBytes.length, aceOfSpacesBytes.length);
        assertTrue(Arrays.equals(responseImageBytes, aceOfSpacesBytes));
    }
View Full Code Here

        assertEquals(deleteResponse.getHttpStatus(), CouchHttpStatus.OK);
        String previousVersion = latestRevision;
        latestRevision = deleteResponse.getDocumentRevision();

        // Get attachment should now return not found
        GetAttachmentResponse response = couchDatabase
                .get()
                .attachment(attachDocId, latestRevision, "html")
                .execute();
        assertEquals(response.getHttpStatus(), CouchHttpStatus.NOT_FOUND);

        // Get previous version should be found
        response = couchDatabase
                .get()
                .attachment(attachDocId, previousVersion, "html")
                .execute();
        assertEquals(response.getHttpStatus(), CouchHttpStatus.OK, response.getStringContent());
        assertTrue(response.isOk());
        assertEquals(response.getContentType(), CouchMediaType.TEXT_HTML);
        assertNotNull(response.getDocumentRevision());
        assertEquals(response.getStringContent(), htmlContent);

    }
View Full Code Here

        }

        // Add any attachments
        if (entityMeta.hasAttachments()) {
            for (AttachmentMeta attachmentDef : entityMeta.getAttachmentMetaList()) {
                GetAttachmentResponse response = getRequestFactory.attachment(documentId, revision, attachmentDef.getAttachmentName()).execute();
                inject.addValue(attachmentDef.getAttachmentName(), response.getContent());
            }
        }
        return inject;
    }
View Full Code Here

        }

        // Add any attachments
        if (entityMeta.hasAttachments()) {
            for (AttachmentMeta attachmentDef : entityMeta.getAttachmentMetaList()) {
                GetAttachmentResponse response = getRequestFactory.attachment(documentId, revision, attachmentDef.getAttachmentName()).execute();
                inject.addValue(attachmentDef.getAttachmentName(), response.getContent());
            }
        }
        return inject;
    }
View Full Code Here

TOP

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

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.