use of ddf.catalog.content.operation.impl.DeleteStorageRequestImpl 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.impl.DeleteStorageRequestImpl 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.impl.DeleteStorageRequestImpl in project ddf by codice.
the class FileSystemStorageProviderTest method testDeleteIdWithMultpleContent.
@Test
public void testDeleteIdWithMultpleContent() throws Exception {
CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
createResponse = assertContentItemWithQualifier(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, createResponse.getCreatedContentItems().get(0).getId(), 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();
assertThat(items, hasSize(2));
for (ContentItem item : items) {
LOGGER.debug("Item retrieved: {}", item);
assertThat(item.getId(), is(id));
assertThat(item.getFilename(), isEmptyString());
}
}
use of ddf.catalog.content.operation.impl.DeleteStorageRequestImpl in project ddf by codice.
the class FileSystemStorageProviderTest method testInvalidDelete.
@Test
public void testInvalidDelete() throws Exception {
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
Metacard metacard = mock(Metacard.class);
when(metacard.getId()).thenReturn(uuid);
ContentItem contentItem = new ContentItemImpl(uuid, null, null, "application/text", "datadatadata", 0, metacard);
DeleteStorageRequest deleteRequest = new DeleteStorageRequestImpl(Lists.newArrayList(metacard), null);
DeleteStorageResponse deleteResponse = provider.delete(deleteRequest);
assertThat(deleteResponse.getDeletedContentItems().size(), is(0));
}
use of ddf.catalog.content.operation.impl.DeleteStorageRequestImpl in project ddf by codice.
the class FileSystemStorageProviderTest method testDeleteReference.
@Test
public void testDeleteReference() throws Exception {
String path = baseTmpDir + File.separator + TEST_INPUT_FILENAME;
File tempFile = new File(path);
FileUtils.writeStringToFile(tempFile, TEST_INPUT_CONTENTS);
Map<String, Serializable> properties = new HashMap<>();
properties.put(Constants.STORE_REFERENCE_KEY, tempFile.toURI().toASCIIString());
CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, properties);
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());
assertTrue(tempFile.exists());
}
Aggregations