Search in sources :

Example 16 with DeleteRequest

use of ddf.catalog.operation.DeleteRequest in project ddf by codice.

the class SecurityPluginTest method testNominalCaseDelete.

@Test
public void testNominalCaseDelete() throws Exception {
    Subject mockSubject = mock(Subject.class);
    ThreadContext.bind(mockSubject);
    DeleteRequest request = new MockDeleteRequest();
    SecurityPlugin plugin = new SecurityPlugin();
    request = plugin.processPreDelete(request);
    request = plugin.processPreDelete(request);
    assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
}
Also used : DeleteRequest(ddf.catalog.operation.DeleteRequest) Subject(ddf.security.Subject) Test(org.junit.Test)

Example 17 with DeleteRequest

use of ddf.catalog.operation.DeleteRequest in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnDeleteByID.

@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnDeleteByID() throws IngestException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    // use exception provider instead of memory
    MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
    MockMemoryStorageProvider storageProvider = new MockMemoryStorageProvider();
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
    List<String> ids = new ArrayList<String>();
    ids.add("1234");
    DeleteRequest request = new DeleteRequestImpl((String[]) ids.toArray(new String[ids.size()]));
    // expected to throw exception due to catalog provider
    try {
        framework.delete(request);
    } catch (SourceUnavailableException e) {
        fail();
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) ContentType(ddf.catalog.data.ContentType) MockMemoryStorageProvider(ddf.catalog.content.impl.MockMemoryStorageProvider) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 18 with DeleteRequest

use of ddf.catalog.operation.DeleteRequest in project ddf by codice.

the class HistorianTest method testDeleteResponseNoContentItems.

@Test
public void testDeleteResponseNoContentItems() throws SourceUnavailableException, IngestException, StorageException {
    Metacard metacard = getMetacardUpdatePair().get(0);
    DeleteRequest deleteRequest = new DeleteRequestImpl("deleteRequest");
    DeleteResponse deleteResponse = new DeleteResponseImpl(deleteRequest, new HashMap<>(), Collections.singletonList(metacard));
    historian.version(deleteResponse);
    assertThat(storageProvider.storageMap.size(), equalTo(0));
}
Also used : DeletedMetacard(ddf.catalog.core.versioning.DeletedMetacard) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 19 with DeleteRequest

use of ddf.catalog.operation.DeleteRequest 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));
}
Also used : DeleteStorageRequest(ddf.catalog.content.operation.DeleteStorageRequest) DeleteStorageRequestImpl(ddf.catalog.content.operation.impl.DeleteStorageRequestImpl) DeletedMetacard(ddf.catalog.core.versioning.DeletedMetacard) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 20 with DeleteRequest

use of ddf.catalog.operation.DeleteRequest in project ddf by codice.

the class SolrCacheTest method deleteWithId.

@Test
public void deleteWithId() throws Exception {
    DeleteRequest mockRequest = setupDeleteRequest("id");
    solrCache.delete(mockRequest);
    verify(mockCacheSolrMetacardClient).deleteByIds("original_id" + SchemaFields.TEXT_SUFFIX, null, false);
}
Also used : DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Aggregations

DeleteRequest (ddf.catalog.operation.DeleteRequest)39 Test (org.junit.Test)29 DeleteResponse (ddf.catalog.operation.DeleteResponse)22 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)22 Metacard (ddf.catalog.data.Metacard)18 ArrayList (java.util.ArrayList)18 HashMap (java.util.HashMap)11 Serializable (java.io.Serializable)10 DeleteResponseImpl (ddf.catalog.operation.impl.DeleteResponseImpl)9 List (java.util.List)9 CatalogFramework (ddf.catalog.CatalogFramework)7 QueryResponse (ddf.catalog.operation.QueryResponse)7 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)7 Result (ddf.catalog.data.Result)6 QueryRequest (ddf.catalog.operation.QueryRequest)6 ContentType (ddf.catalog.data.ContentType)5 ResourceRequest (ddf.catalog.operation.ResourceRequest)5 QueryImpl (ddf.catalog.operation.impl.QueryImpl)5 Filter (org.opengis.filter.Filter)5 ResultImpl (ddf.catalog.data.impl.ResultImpl)4