use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.
the class FileSystemStorageProviderTest method testDeleteWithQualifier.
@Test
public void testDeleteWithQualifier() throws Exception {
CreateStorageResponse createResponse = assertContentItemWithQualifier(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, "", QUALIFIER);
String id = createResponse.getCreatedContentItems().get(0).getId();
DeleteStorageRequest deleteRequest = new DeleteStorageRequestImpl(createResponse.getCreatedContentItems().stream().map(ContentItem::getMetacard).collect(Collectors.toList()), null);
when(deleteRequest.getMetacards().get(0).getId()).thenReturn(id);
DeleteStorageResponse deleteResponse = provider.delete(deleteRequest);
provider.commit(deleteRequest);
List<ContentItem> items = deleteResponse.getDeletedContentItems();
ContentItem item = items.get(0);
LOGGER.debug("Item retrieved: {}", item);
assertEquals(id, item.getId());
assertThat(item.getFilename(), is(""));
}
use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.
the class FileSystemStorageProviderTest method testUpdateWithMultipleItems.
@Test
public void testUpdateWithMultipleItems() throws Exception {
CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
URI unqualifiedUri = new URI(createResponse.getCreatedContentItems().get(0).getUri());
createResponse = assertContentItemWithQualifier(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, createResponse.getCreatedContentItems().get(0).getId(), QUALIFIER);
URI qualifiedUri = new URI(createResponse.getCreatedContentItems().get(0).getUri());
String id = createResponse.getCreatedContentItems().get(0).getId();
ByteSource byteSource = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return IOUtils.toInputStream("Updated NITF");
}
};
ContentItem updateItem = new ContentItemImpl(id, byteSource, NITF_MIME_TYPE, mock(Metacard.class));
submitAndVerifySuccessfulUpdateStorageRequest(updateItem);
updateItem = new ContentItemImpl(id, qualifiedUri.getFragment(), byteSource, NITF_MIME_TYPE, mock(Metacard.class));
submitAndVerifySuccessfulUpdateStorageRequest(updateItem);
}
use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.
the class FileSystemStorageProviderTest method testReadDeletedReference.
@Test(expected = StorageException.class)
public void testReadDeletedReference() throws Exception {
Path tempFile = Files.createTempFile("test", "nitf");
Files.write(tempFile, TEST_INPUT_CONTENTS.getBytes());
CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, Collections.singletonMap(Constants.STORE_REFERENCE_KEY, tempFile.toFile().getAbsolutePath()));
URI uri = new URI(createResponse.getCreatedContentItems().get(0).getUri());
ReadStorageResponse read = provider.read(new ReadStorageRequestImpl(new URI(createResponse.getCreatedContentItems().get(0).getUri()), Collections.emptyMap()));
assertThat(read.getContentItem(), notNullValue());
Files.delete(tempFile);
provider.read(new ReadStorageRequestImpl(new URI(createResponse.getCreatedContentItems().get(0).getUri()), Collections.emptyMap()));
}
use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.
the class FileSystemStorageProviderTest method testDelete.
@Test
public void testDelete() throws Exception {
CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
String id = createResponse.getCreatedContentItems().get(0).getId();
DeleteStorageRequest deleteRequest = new DeleteStorageRequestImpl(createResponse.getCreatedContentItems().stream().map(ContentItem::getMetacard).collect(Collectors.toList()), null);
when(deleteRequest.getMetacards().get(0).getId()).thenReturn(id);
DeleteStorageResponse deleteResponse = provider.delete(deleteRequest);
List<ContentItem> items = deleteResponse.getDeletedContentItems();
ContentItem item = items.get(0);
LOGGER.debug("Item retrieved: {}", item);
assertEquals(id, item.getId());
assertThat(item.getFilename(), isEmptyString());
}
use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.
the class FileSystemStorageProviderTest method testReadWithQualifier.
@Test
public void testReadWithQualifier() throws Exception {
CreateStorageResponse createResponse = assertContentItemWithQualifier(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, "", QUALIFIER);
String uriString = createResponse.getCreatedContentItems().get(0).getUri();
assertReadRequest(uriString, NITF_MIME_TYPE);
}
Aggregations