use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class RefreshRegistryEntriesTest method testSubscriptionEntityRemovalFailedQuery.
@Test
public void testSubscriptionEntityRemovalFailedQuery() throws Exception {
Metacard localMetacard = getPopulatedTestRegistryMetacard("mcardId", "testRegId", 0, true);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMetacard));
when(registryStore.query(any(QueryRequest.class))).thenThrow(new UnsupportedQueryException("query error"));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.getId()).thenReturn(TEST_ID);
when(registryStore.getRegistryId()).thenReturn("remoteRegId");
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService, never()).deleteRegistryEntriesByMetacardIds(Collections.singletonList(localMetacard.getId()));
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class RefreshRegistryEntriesTest method testMultipleStores.
@Test
public void testMultipleStores() throws Exception {
Metacard mcard = getPopulatedTestRegistryMetacard();
RegistryStore registryStore2 = mock(RegistryStore.class);
when(registryStore2.getId()).thenReturn("id2");
when(registryStore2.getRegistryId()).thenReturn("regId2");
when(registryStore2.isAvailable()).thenReturn(true);
when(registryStore2.isPullAllowed()).thenReturn(true);
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(mcard)));
when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
when(registryStore.query(any(QueryRequest.class))).thenThrow(new UnsupportedQueryException());
when(registryStore.isAvailable()).thenReturn(true);
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
List<RegistryStore> stores = new ArrayList<>();
stores.add(registryStore);
stores.add(registryStore2);
refreshRegistryEntries.setRegistryStores(stores);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).addRegistryEntries(Collections.singletonList(mcard), null);
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class RegistryIdPostIngestPluginTest method testInitCatalogNotAvailable.
@Test
public void testInitCatalogNotAvailable() throws Exception {
when(security.runAsAdminWithException(any(PrivilegedExceptionAction.class))).thenThrow(new PrivilegedActionException(new UnsupportedQueryException("exception")));
registryIdPostIngestPlugin.init();
assertThat(registryIdPostIngestPlugin.getRegistryIds().size(), equalTo(0));
verify(executorService).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class SourceQueryRunnable method normalize.
private void normalize(Query query, List<Result> responseResults) {
if (shouldNormalizeRelevance) {
FilteringSolrIndex index = null;
try {
index = solrIndexFuture.get(FUTURE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
index.add(responseResults);
List<Result> indexResults = index.query(new QueryRequestImpl(query)).getResults();
normalizeRelevance(indexResults, results);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.debug("Failed to get index for relevance normalization", e);
} catch (UnsupportedQueryException e) {
LOGGER.debug("Failed to parse query for relevance normalization", e);
} catch (IngestException e) {
LOGGER.debug("Failed to ingest results for relevance normalization", e);
}
} else if (shouldNormalizeDistance) {
normalizeDistances(query, results);
}
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class FilterAdapterTest method assertFilterFails.
private void assertFilterFails(Filter filter) {
FilterDelegate<String> delegate = new FilterToTextDelegate();
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
try {
fa.adapt(filter, delegate);
fail("Expected UnsupportedQueryException");
} catch (UnsupportedQueryException e) {
// pass
}
}
Aggregations