use of ddf.catalog.content.operation.DeleteStorageRequest in project ddf by codice.
the class HistorianTest method testDeleteResponse.
@Test
public void testDeleteResponse() throws SourceUnavailableException, IngestException, StorageException {
Metacard metacard = getMetacardUpdatePair().get(0);
storeMetacard(metacard);
// Send a delete request
DeleteStorageRequest deleteStorageRequest = new DeleteStorageRequestImpl(Collections.singletonList(metacard), new HashMap<>());
storageProvider.delete(deleteStorageRequest);
// Version delete request
DeleteRequest deleteRequest = new DeleteRequestImpl("deleteRequest");
DeleteResponse deleteResponse = new DeleteResponseImpl(deleteRequest, new HashMap<>(), Collections.singletonList(metacard));
historian.version(deleteResponse);
// Only the version metacard is left
assertThat(storageProvider.storageMap.size(), equalTo(1));
}
use of ddf.catalog.content.operation.DeleteStorageRequest in project ddf by codice.
the class HistorianTest method testDeleteResponseSetSkipFlag.
@Test
public void testDeleteResponseSetSkipFlag() throws SourceUnavailableException, IngestException, StorageException {
Metacard metacard = getMetacardUpdatePair().get(0);
storeMetacard(metacard);
// Send a delete request
DeleteStorageRequest deleteStorageRequest = new DeleteStorageRequestImpl(Collections.singletonList(metacard), new HashMap<>());
storageProvider.delete(deleteStorageRequest);
// Version delete request
DeleteRequest deleteRequest = new DeleteRequestImpl("deleteRequest");
DeleteResponse deleteResponse = new DeleteResponseImpl(deleteRequest, new HashMap<>(), Collections.singletonList(metacard));
historian.version(deleteResponse);
assertThat(deleteResponse.getProperties(), hasEntry(MetacardVersion.SKIP_VERSIONING, true));
}
use of ddf.catalog.content.operation.DeleteStorageRequest 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.DeleteStorageRequest 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.DeleteStorageRequest 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());
}
}
Aggregations