Search in sources :

Example 6 with ReadStorageResponse

use of ddf.catalog.content.operation.ReadStorageResponse in project ddf by codice.

the class FileSystemStorageProviderTest method testRollback.

@Test(expected = StorageException.class)
public void testRollback() throws Exception {
    String id = UUID.randomUUID().toString().replaceAll("-", "");
    ByteSource byteSource = new ByteSource() {

        @Override
        public InputStream openStream() throws IOException {
            return IOUtils.toInputStream(TEST_INPUT_CONTENTS);
        }
    };
    Metacard metacard = mock(Metacard.class);
    when(metacard.getId()).thenReturn(id);
    ContentItem contentItem = new ContentItemImpl(id, byteSource, NITF_MIME_TYPE, TEST_INPUT_FILENAME, TEST_INPUT_CONTENTS.getBytes().length, metacard);
    CreateStorageRequest createRequest = new CreateStorageRequestImpl(Collections.singletonList(contentItem), null);
    CreateStorageResponse createStorageResponse = provider.create(createRequest);
    provider.rollback(createRequest);
    ReadStorageRequest readStorageRequest = new ReadStorageRequestImpl(new URI("content:" + id), null);
    ReadStorageResponse read = provider.read(readStorageRequest);
}
Also used : CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) Metacard(ddf.catalog.data.Metacard) ReadStorageRequest(ddf.catalog.content.operation.ReadStorageRequest) CreateStorageRequestImpl(ddf.catalog.content.operation.impl.CreateStorageRequestImpl) ByteSource(com.google.common.io.ByteSource) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) ReadStorageRequestImpl(ddf.catalog.content.operation.impl.ReadStorageRequestImpl) ReadStorageResponse(ddf.catalog.content.operation.ReadStorageResponse) URI(java.net.URI) ContentItem(ddf.catalog.content.data.ContentItem) ContentItemImpl(ddf.catalog.content.data.impl.ContentItemImpl) CreateStorageRequest(ddf.catalog.content.operation.CreateStorageRequest) Test(org.junit.Test)

Aggregations

ReadStorageResponse (ddf.catalog.content.operation.ReadStorageResponse)6 ContentItem (ddf.catalog.content.data.ContentItem)5 ReadStorageRequest (ddf.catalog.content.operation.ReadStorageRequest)5 CreateStorageResponse (ddf.catalog.content.operation.CreateStorageResponse)4 ReadStorageRequestImpl (ddf.catalog.content.operation.impl.ReadStorageRequestImpl)4 URI (java.net.URI)4 Test (org.junit.Test)4 Metacard (ddf.catalog.data.Metacard)3 StorageProvider (ddf.catalog.content.StorageProvider)2 DeleteStorageRequest (ddf.catalog.content.operation.DeleteStorageRequest)2 StorageRequest (ddf.catalog.content.operation.StorageRequest)2 UpdateStorageRequest (ddf.catalog.content.operation.UpdateStorageRequest)2 UpdateStorageResponse (ddf.catalog.content.operation.UpdateStorageResponse)2 DeletedMetacard (ddf.catalog.core.versioning.DeletedMetacard)2 UpdateResponse (ddf.catalog.operation.UpdateResponse)2 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)2 ByteSource (com.google.common.io.ByteSource)1 StorageException (ddf.catalog.content.StorageException)1 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)1 CreateStorageRequest (ddf.catalog.content.operation.CreateStorageRequest)1