use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class CatalogFrameworkImplTest method testNullEntriesCreate.
@Test(expected = IngestException.class)
public void testNullEntriesCreate() throws IngestException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
// call framework with null request
try {
framework.create((CreateRequest) null);
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class CatalogFrameworkImplTest method testNullFederatedQuery.
/**
* Tests that the framework properly throws a catalog exception when the federated query being
* passed in is null.
*
* @throws UnsupportedQueryException
*/
@Test(expected = UnsupportedQueryException.class)
public void testNullFederatedQuery() throws UnsupportedQueryException {
boolean isAvailable = false;
CatalogProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), isAvailable, new Date());
createDefaultFederatedSourceList(isAvailable);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, null, true);
try {
framework.query(null, null);
} catch (FederationException e) {
fail();
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class CswEndpointTest method testDeleteTransaction.
@Test
public void testDeleteTransaction() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException, IngestException {
DeleteType deleteType = mock(DeleteType.class);
doReturn(CswConstants.CSW_RECORD).when(deleteType).getTypeName();
doReturn("").when(deleteType).getHandle();
QueryConstraintType queryConstraintType = new QueryConstraintType();
queryConstraintType.setCqlText("title = \"foo\"");
doReturn(queryConstraintType).when(deleteType).getConstraint();
when(catalogFramework.delete(any(DeleteRequest.class))).thenAnswer((Answer<DeleteResponse>) invocation -> {
DeleteRequest request = (DeleteRequest) invocation.getArguments()[0];
long numResults = request.getAttributeValues().size();
when(deleteResponse.getDeletedMetacards()).thenReturn(populateMetacardList((int) numResults));
return deleteResponse;
});
DeleteAction deleteAction = new DeleteActionImpl(deleteType, DefaultCswRecordMap.getPrefixToUriMapping());
CswTransactionRequest deleteRequest = new CswTransactionRequest();
deleteRequest.getDeleteActions().add(deleteAction);
deleteRequest.setVersion(CswConstants.VERSION_2_0_2);
deleteRequest.setService(CswConstants.CSW);
deleteRequest.setVerbose(false);
TransactionResponseType response = csw.transaction(deleteRequest);
assertThat(response, notNullValue());
TransactionSummaryType summary = response.getTransactionSummary();
assertThat(summary, notNullValue());
assertThat(summary.getTotalDeleted().intValue(), is(BATCH_TOTAL));
assertThat(summary.getTotalInserted().intValue(), is(0));
assertThat(summary.getTotalUpdated().intValue(), is(0));
verifyMarshalResponse(response, "net.opengis.cat.csw.v_2_0_2:net.opengis.filter.v_1_1_0:net.opengis.gml.v_3_1_1", cswQnameOutPutSchema);
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class GazetteerBuildSuggesterIndexCommandTest method unsuccessfulRunPrintsErrors.
@Test
public void unsuccessfulRunPrintsErrors() throws Exception {
final String exceptionMessage = "The source is unavailable.";
doThrow(new SourceUnavailableException(exceptionMessage)).when(catalogFramework).query(any());
command.executeWithSubject();
final String output = consoleInterceptor.getOutput();
assertThat(output, containsString("Error: " + exceptionMessage));
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class CatalogBundle method isCatalogProviderReady.
private boolean isCatalogProviderReady() {
CatalogProvider provider = getService(CatalogProvider.class);
CatalogFramework framework = getService(CatalogFramework.class);
if (framework != null && provider != null) {
SourceInfoRequestLocal sourceInfoRequestEnterprise = new SourceInfoRequestLocal(true);
try {
SourceInfoResponse sources = framework.getSourceInfo(sourceInfoRequestEnterprise);
return sources.getSourceInfo().stream().filter(descriptor -> descriptor.getSourceId().equals(provider.getId())).map(descriptor -> descriptor.isAvailable() && provider.isAvailable()).findFirst().orElse(false);
} catch (SourceUnavailableException ignored) {
}
}
return false;
}
Aggregations