Search in sources :

Example 1 with ActionRegistry

use of ddf.action.ActionRegistry in project ddf by codice.

the class CqlResultTest method distanceCheck.

private void distanceCheck(Double input, Double output) {
    MetacardImpl metacard = new MetacardImpl(BasicTypes.BASIC_METACARD);
    ResultImpl result = new ResultImpl(metacard);
    result.setDistanceInMeters(input);
    ActionRegistry actionRegistry = mock(ActionRegistry.class);
    when(actionRegistry.list(any())).thenReturn(Collections.emptyList());
    QueryRequest request = new QueryRequestImpl(new QueryImpl(filterBuilder.attribute("test").equalTo().text("value")));
    CqlResult cqlResult = new CqlResult(result, null, request, false, filterAdapter, actionRegistry);
    assertThat(cqlResult.getDistance(), is(output));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) ActionRegistry(ddf.action.ActionRegistry) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 2 with ActionRegistry

use of ddf.action.ActionRegistry in project ddf by codice.

the class SourceOperationsTest method testGettingSourceActions.

@Test
public void testGettingSourceActions() throws SourceUnavailableException {
    Action action = mock(Action.class);
    FrameworkProperties frameworkProperties = mock(FrameworkProperties.class);
    CatalogProvider catalogProvider = mock(CatalogProvider.class);
    when(frameworkProperties.getCatalogProviders()).thenReturn(Collections.singletonList(catalogProvider));
    ActionRegistry actionRegistry = mock(ActionRegistry.class);
    when(actionRegistry.list(any(Source.class))).thenReturn(Collections.singletonList(action));
    final SourcePoller<SourceStatus> mockStatusSourcePoller = mock(SourcePoller.class);
    when(mockStatusSourcePoller.getCachedValueForSource(isA(Source.class))).thenReturn(Optional.empty());
    SourceOperations sourceOperations = new SourceOperations(frameworkProperties, actionRegistry, mockStatusSourcePoller, mock(SourcePoller.class));
    sourceOperations.bind((CatalogProvider) null);
    SourceInfoRequest sourceInfoRequest = mock(SourceInfoRequest.class);
    SourceInfoResponse sourceInfoResponse = sourceOperations.getSourceInfo(sourceInfoRequest, true);
    assertThat(sourceInfoResponse.getSourceInfo(), hasSize(1));
    SourceDescriptor sourceDescriptor = sourceInfoResponse.getSourceInfo().toArray(new SourceDescriptor[0])[0];
    assertThat(sourceDescriptor.getActions(), is(Collections.singletonList(action)));
}
Also used : FrameworkProperties(ddf.catalog.impl.FrameworkProperties) Action(ddf.action.Action) SourceDescriptor(ddf.catalog.source.SourceDescriptor) CatalogProvider(ddf.catalog.source.CatalogProvider) SourceStatus(org.codice.ddf.catalog.sourcepoller.SourceStatus) SourceInfoRequest(ddf.catalog.operation.SourceInfoRequest) ActionRegistry(ddf.action.ActionRegistry) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) Source(ddf.catalog.source.Source) SourcePoller(org.codice.ddf.catalog.sourcepoller.SourcePoller) Test(org.junit.Test)

Example 3 with ActionRegistry

use of ddf.action.ActionRegistry in project ddf by codice.

the class CatalogFrameworkQueryTest method initFramework.

@Before
public void initFramework() {
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
    final SourcePoller<SourceStatus> mockStatusSourcePoller = mock(SourcePoller.class);
    when(mockStatusSourcePoller.getCachedValueForSource(isA(Source.class))).thenReturn(Optional.of(SourceStatus.AVAILABLE));
    ArrayList<PostIngestPlugin> postIngestPlugins = new ArrayList<>();
    FrameworkProperties props = new FrameworkProperties();
    props.setCatalogProviders(Collections.singletonList(provider));
    props.setPostIngest(postIngestPlugins);
    props.setFederationStrategy(new MockFederationStrategy());
    props.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
    props.setFilterBuilder(new GeotoolsFilterBuilder());
    props.setDefaultAttributeValueRegistry(new DefaultAttributeValueRegistryImpl());
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    ActionRegistry sourceActionRegistry = mock(ActionRegistry.class);
    when(sourceActionRegistry.list(any())).thenReturn(Collections.emptyList());
    OperationsSecuritySupport opsSecurity = new OperationsSecuritySupport();
    MetacardFactory metacardFactory = new MetacardFactory(props.getMimeTypeToTransformerMapper(), uuidGenerator);
    OperationsMetacardSupport opsMetacard = new OperationsMetacardSupport(props, metacardFactory);
    SourceOperations sourceOperations = new SourceOperations(props, sourceActionRegistry, mockStatusSourcePoller, mock(SourcePoller.class));
    QueryOperations queryOperations = new QueryOperations(props, sourceOperations, opsSecurity, opsMetacard);
    ResourceOperations resourceOperations = new ResourceOperations(props, queryOperations, opsSecurity);
    TransformOperations transformOperations = new TransformOperations(props);
    OperationsCatalogStoreSupport opsCatStore = new OperationsCatalogStoreSupport(props, sourceOperations);
    OperationsStorageSupport opsStorage = new OperationsStorageSupport(sourceOperations, queryOperations);
    CreateOperations createOperations = new CreateOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard, opsCatStore, opsStorage);
    UpdateOperations updateOperations = new UpdateOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard, opsCatStore, opsStorage);
    DeleteOperations deleteOperations = new DeleteOperations(props, queryOperations, sourceOperations, opsSecurity, opsMetacard);
    Historian historian = new Historian();
    historian.setHistoryEnabled(false);
    updateOperations.setHistorian(historian);
    deleteOperations.setHistorian(historian);
    framework = new CatalogFrameworkImpl(createOperations, updateOperations, deleteOperations, queryOperations, resourceOperations, sourceOperations, transformOperations);
    sourceOperations.bind(provider);
}
Also used : OperationsCatalogStoreSupport(ddf.catalog.impl.operations.OperationsCatalogStoreSupport) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) ContentType(ddf.catalog.data.ContentType) ArrayList(java.util.ArrayList) DeleteOperations(ddf.catalog.impl.operations.DeleteOperations) ActionRegistry(ddf.action.ActionRegistry) Source(ddf.catalog.source.Source) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) SourcePoller(org.codice.ddf.catalog.sourcepoller.SourcePoller) MetacardFactory(ddf.catalog.impl.operations.MetacardFactory) OperationsStorageSupport(ddf.catalog.impl.operations.OperationsStorageSupport) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Historian(ddf.catalog.history.Historian) DefaultAttributeValueRegistryImpl(ddf.catalog.data.defaultvalues.DefaultAttributeValueRegistryImpl) SourceOperations(ddf.catalog.impl.operations.SourceOperations) SourceStatus(org.codice.ddf.catalog.sourcepoller.SourceStatus) ResourceOperations(ddf.catalog.impl.operations.ResourceOperations) TransformOperations(ddf.catalog.impl.operations.TransformOperations) Date(java.util.Date) QueryOperations(ddf.catalog.impl.operations.QueryOperations) UpdateOperations(ddf.catalog.impl.operations.UpdateOperations) OperationsSecuritySupport(ddf.catalog.impl.operations.OperationsSecuritySupport) CreateOperations(ddf.catalog.impl.operations.CreateOperations) OperationsMetacardSupport(ddf.catalog.impl.operations.OperationsMetacardSupport) Before(org.junit.Before)

Aggregations

ActionRegistry (ddf.action.ActionRegistry)3 Source (ddf.catalog.source.Source)2 SourcePoller (org.codice.ddf.catalog.sourcepoller.SourcePoller)2 SourceStatus (org.codice.ddf.catalog.sourcepoller.SourceStatus)2 Action (ddf.action.Action)1 ContentType (ddf.catalog.data.ContentType)1 DefaultAttributeValueRegistryImpl (ddf.catalog.data.defaultvalues.DefaultAttributeValueRegistryImpl)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 Historian (ddf.catalog.history.Historian)1 FrameworkProperties (ddf.catalog.impl.FrameworkProperties)1 CreateOperations (ddf.catalog.impl.operations.CreateOperations)1 DeleteOperations (ddf.catalog.impl.operations.DeleteOperations)1 MetacardFactory (ddf.catalog.impl.operations.MetacardFactory)1 OperationsCatalogStoreSupport (ddf.catalog.impl.operations.OperationsCatalogStoreSupport)1 OperationsMetacardSupport (ddf.catalog.impl.operations.OperationsMetacardSupport)1 OperationsSecuritySupport (ddf.catalog.impl.operations.OperationsSecuritySupport)1 OperationsStorageSupport (ddf.catalog.impl.operations.OperationsStorageSupport)1 QueryOperations (ddf.catalog.impl.operations.QueryOperations)1