Search in sources :

Example 36 with DeleteRequest

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

the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByID.

/**
     * Tests that the framework properly throws a catalog exception when the local provider is not
     * available for delete by id.
     *
     * @throws IngestException
     * @throws SourceUnavailableException
     */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByID() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    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 being unavailable
    try {
        framework.delete(request);
    } catch (IngestException e) {
        fail();
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) IngestException(ddf.catalog.source.IngestException) Matchers.anyString(org.mockito.Matchers.anyString) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 37 with DeleteRequest

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

the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnDeleteByIdentifier.

@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnDeleteByIdentifier() 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);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
    // List<MetacardType> identifiers = new ArrayList<MetacardType>();
    // identifiers.add( new MetacardTypeImpl( "id", "1234" ) );
    ArrayList<URI> uris = new ArrayList<URI>();
    DeleteRequest request = new DeleteRequestImpl((URI[]) uris.toArray(new URI[uris.size()]));
    // expected to throw exception due to catalog provider being unavailable
    try {
        framework.delete(request);
    } catch (SourceUnavailableException e) {
        fail();
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) ContentType(ddf.catalog.data.ContentType) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) URI(java.net.URI) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 38 with DeleteRequest

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

the class CatalogFrameworkImplTest method testProviderUnavailableDeleteByIdentifier.

/**
     * Tests that the framework properly throws a catalog exception when the local provider is not
     * available for delete by identifier.
     *
     * @throws IngestException
     * @throws SourceUnavailableException
     */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableDeleteByIdentifier() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    List<URI> uris = new ArrayList<URI>();
    try {
        uris.add(new URI("id://1234"));
        DeleteRequest request = new DeleteRequestImpl((URI[]) uris.toArray(new URI[uris.size()]));
        // expected to throw exception due to catalog provider being
        // unavailable
        framework.delete(request);
    } catch (URISyntaxException e) {
        fail();
    } catch (IngestException e) {
        fail();
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) IngestException(ddf.catalog.source.IngestException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 39 with DeleteRequest

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

the class FanoutCatalogFrameworkTest method testBlacklistedTagDeleteRequestFails.

@Test(expected = IngestException.class)
public void testBlacklistedTagDeleteRequestFails() throws Exception {
    Metacard metacard = new MetacardImpl();
    metacard.setAttribute(new AttributeImpl(Metacard.ID, "metacardId"));
    metacard.setAttribute(new AttributeImpl(Metacard.TAGS, "blacklisted"));
    CatalogProvider catalogProvider = mock(CatalogProvider.class);
    doReturn(true).when(catalogProvider).isAvailable();
    StorageProvider storageProvider = new MockMemoryStorageProvider();
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterAdapter filterAdapter = mock(FilterAdapter.class);
    ValidationQueryFactory validationQueryFactory = new ValidationQueryFactory(filterAdapter, filterBuilder);
    QueryRequestImpl queryRequest = new QueryRequestImpl(mock(Query.class));
    ResultImpl result = new ResultImpl(metacard);
    List<Result> results = new ArrayList<>();
    results.add(result);
    QueryResponseImpl queryResponse = new QueryResponseImpl(queryRequest, results, 1);
    FederationStrategy strategy = mock(FederationStrategy.class);
    when(strategy.federate(anyList(), any())).thenReturn(queryResponse);
    QueryResponsePostProcessor queryResponsePostProcessor = mock(QueryResponsePostProcessor.class);
    doNothing().when(queryResponsePostProcessor).processResponse(any());
    frameworkProperties.setCatalogProviders(Collections.singletonList(catalogProvider));
    frameworkProperties.setStorageProviders(Collections.singletonList(storageProvider));
    frameworkProperties.setFilterBuilder(filterBuilder);
    frameworkProperties.setValidationQueryFactory(validationQueryFactory);
    frameworkProperties.setFederationStrategy(strategy);
    frameworkProperties.setQueryResponsePostProcessor(queryResponsePostProcessor);
    OperationsSecuritySupport opsSecurity = new OperationsSecuritySupport();
    MetacardFactory metacardFactory = new MetacardFactory(frameworkProperties.getMimeTypeToTransformerMapper(), uuidGenerator);
    OperationsMetacardSupport opsMetacard = new OperationsMetacardSupport(frameworkProperties, metacardFactory);
    SourceOperations sourceOperations = new SourceOperations(frameworkProperties);
    sourceOperations.bind(catalogProvider);
    sourceOperations.bind(storageProvider);
    TransformOperations transformOperations = new TransformOperations(frameworkProperties);
    QueryOperations queryOperations = new QueryOperations(frameworkProperties, sourceOperations, opsSecurity, opsMetacard);
    OperationsCatalogStoreSupport opsCatStore = new OperationsCatalogStoreSupport(frameworkProperties, sourceOperations);
    ResourceOperations resourceOperations = new ResourceOperations(frameworkProperties, queryOperations, opsSecurity);
    DeleteOperations deleteOperations = new DeleteOperations(frameworkProperties, queryOperations, sourceOperations, opsSecurity, null);
    deleteOperations.setOpsCatStoreSupport(opsCatStore);
    framework = new CatalogFrameworkImpl(null, null, deleteOperations, queryOperations, resourceOperations, sourceOperations, transformOperations);
    framework.setId(NEW_SOURCE_ID);
    framework.setFanoutEnabled(true);
    framework.setFanoutTagBlacklist(Collections.singletonList("blacklisted"));
    DeleteRequest request = new DeleteRequestImpl(metacard.getId());
    framework.delete(request);
}
Also used : OperationsCatalogStoreSupport(ddf.catalog.impl.operations.OperationsCatalogStoreSupport) Query(ddf.catalog.operation.Query) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) MockMemoryStorageProvider(ddf.catalog.content.impl.MockMemoryStorageProvider) ArrayList(java.util.ArrayList) FilterAdapter(ddf.catalog.filter.FilterAdapter) ResultImpl(ddf.catalog.data.impl.ResultImpl) DeleteOperations(ddf.catalog.impl.operations.DeleteOperations) Result(ddf.catalog.data.Result) MetacardFactory(ddf.catalog.impl.operations.MetacardFactory) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) SourceOperations(ddf.catalog.impl.operations.SourceOperations) FederationStrategy(ddf.catalog.federation.FederationStrategy) ResourceOperations(ddf.catalog.impl.operations.ResourceOperations) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) ValidationQueryFactory(ddf.catalog.cache.solr.impl.ValidationQueryFactory) StorageProvider(ddf.catalog.content.StorageProvider) MockMemoryStorageProvider(ddf.catalog.content.impl.MockMemoryStorageProvider) TransformOperations(ddf.catalog.impl.operations.TransformOperations) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Metacard(ddf.catalog.data.Metacard) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) CatalogProvider(ddf.catalog.source.CatalogProvider) QueryOperations(ddf.catalog.impl.operations.QueryOperations) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) OperationsSecuritySupport(ddf.catalog.impl.operations.OperationsSecuritySupport) OperationsMetacardSupport(ddf.catalog.impl.operations.OperationsMetacardSupport) 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