use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class TestRegistryStore method testNonRegistryQuery.
@Test
public void testNonRegistryQuery() throws Exception {
Filter filter = filterBuilder.attribute(RegistryObjectMetacardType.REGISTRY_ID).is().like().text("registryId");
QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
queryResults.add(new ResultImpl(getDefaultMetacard()));
SourceResponse answer = registryStore.query(testRequest);
List<Result> testResults = answer.getResults();
assertThat(testResults.size(), is(0));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class TestRegistryStore method testInit.
@Test
public void testInit() throws Exception {
RegistryStoreImpl registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {
@Override
protected void validateOperation() {
}
@Override
public boolean isAvailable() {
return availability;
}
@Override
protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
if (queryResults == null) {
throw new UnsupportedQueryException("Test - Bad Query");
}
return new SourceResponseImpl(queryRequest, queryResults);
}
@Override
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
return new SourceResponseImpl(request, Collections.singletonList(new Result() {
@Override
public Metacard getMetacard() {
MetacardImpl metacard = new MetacardImpl();
metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "registryId");
metacard.setAttribute(Metacard.TITLE, "title");
return metacard;
}
@Override
public Double getRelevanceScore() {
return null;
}
@Override
public Double getDistanceInMeters() {
return null;
}
}));
}
@Override
protected CapabilitiesType getCapabilities() {
return mock(CapabilitiesType.class);
}
@Override
public void configureCswSource() {
}
;
@Override
protected Subject getSystemSubject() {
return subject;
}
@Override
BundleContext getBundleContext() {
return context;
}
});
registryStore.setFilterBuilder(filterBuilder);
registryStore.setFilterAdapter(filterAdapter);
registryStore.setConfigAdmin(configAdmin);
registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
registryStore.setSchemaTransformerManager(transformer);
registryStore.setAutoPush(true);
registryStore.setRegistryUrl("http://test.url:0101/example");
properties = new Hashtable<>();
properties.put(RegistryStoreImpl.ID, "registryId");
registryStore.setMetacardMarshaller(marshaller);
Csw csw = mock(Csw.class);
when(factory.getClientForSubject(any())).thenReturn(csw);
cswSourceConfiguration.setCswUrl("https://localhost");
cswSourceConfiguration.setPollIntervalMinutes(1);
queryResults.add(new ResultImpl(getDefaultMetacard()));
registryStore.init();
assertThat(registryStore.getRegistryId(), is("registryId"));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class RegistryStoreImpl method query.
@Override
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
//This is a registry store so only allow registry requests through
if (!filterAdapter.adapt(request.getQuery(), new TagsFilterDelegate(ImmutableSet.of(RegistryConstants.REGISTRY_TAG, RegistryConstants.REGISTRY_TAG_INTERNAL), true))) {
return new SourceResponseImpl(request, Collections.emptyList());
}
SourceResponse registryQueryResponse = super.query(request);
for (Result singleResult : registryQueryResponse.getResults()) {
if (registryId.equals(RegistryUtility.getRegistryId(singleResult.getMetacard()))) {
String metacardTitle = singleResult.getMetacard().getTitle();
if (metacardTitle != null && getId() != null && !getId().equals(getFullRegistryName(metacardTitle))) {
setId(metacardTitle);
updateConfiguration(metacardTitle);
}
break;
}
}
return registryQueryResponse;
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class TestRegistryStore method testRegistryQuery.
@Test
public void testRegistryQuery() throws Exception {
Filter filter = filterBuilder.attribute(Metacard.TAGS).is().like().text(RegistryConstants.REGISTRY_TAG);
queryResults.add(new ResultImpl(getDefaultMetacard()));
QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
SourceResponse answer = registryStore.query(testRequest);
List<Result> testResults = answer.getResults();
assertThat(testResults.size(), is(1));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class SolrCacheTest method query.
@Test
public void query() throws UnsupportedQueryException {
QueryRequest mockQuery = mock(QueryRequest.class);
SourceResponse expectedResponse = new QueryResponseImpl(mockQuery);
when(mockCacheSolrMetacardClient.query(mockQuery)).thenReturn(expectedResponse);
SourceResponse actualResponse = solrCache.query(mockQuery);
assertThat(actualResponse, is(expectedResponse));
verify(mockSolrClientAdaptor).getSolrMetacardClient();
verify(mockCacheSolrMetacardClient).query(mockQuery);
}
Aggregations