Search in sources :

Example 1 with ConnectedSource

use of ddf.catalog.source.ConnectedSource in project ddf by codice.

the class FanoutCatalogFrameworkTest method testQueryReplacesSourceId.

@Test
public void testQueryReplacesSourceId() throws Exception {
    ConnectedSource source1 = mock(ConnectedSource.class);
    ConnectedSource source2 = mock(ConnectedSource.class);
    when(source1.getId()).thenReturn("source1");
    when(source2.getId()).thenReturn("source2");
    frameworkProperties.setConnectedSources(ImmutableList.of(source1, source2));
    frameworkProperties.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
    QueryRequestImpl queryRequest = new QueryRequestImpl(mock(Query.class));
    MetacardImpl meta1 = new MetacardImpl();
    MetacardImpl meta2 = new MetacardImpl();
    meta1.setSourceId("source1");
    meta2.setSourceId("source2");
    ResultImpl result1 = new ResultImpl(meta1);
    ResultImpl result2 = new ResultImpl(meta2);
    List<Result> results = new ArrayList<>();
    results.add(result1);
    results.add(result2);
    QueryResponseImpl queryResponse = new QueryResponseImpl(queryRequest, results, 2);
    FederationStrategy strategy = mock(FederationStrategy.class);
    when(strategy.federate(anyList(), any())).thenReturn(queryResponse);
    QueryResponse response = framework.query(queryRequest, strategy);
    for (Result result : response.getResults()) {
        assertEquals(result.getMetacard().getSourceId(), NEW_SOURCE_ID);
    }
}
Also used : QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) ConnectedSource(ddf.catalog.source.ConnectedSource) Query(ddf.catalog.operation.Query) FederationStrategy(ddf.catalog.federation.FederationStrategy) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryResponse(ddf.catalog.operation.QueryResponse) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Aggregations

Result (ddf.catalog.data.Result)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 FederationStrategy (ddf.catalog.federation.FederationStrategy)1 Query (ddf.catalog.operation.Query)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)1 ConnectedSource (ddf.catalog.source.ConnectedSource)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1