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);
}
}
Aggregations