use of ddf.catalog.data.ContentType in project ddf by codice.
the class TestWfsSource method testConfigureFeatureTypes.
@Test
public void testConfigureFeatureTypes() throws WfsException, SecurityServiceException {
ArgumentCaptor<DescribeFeatureTypeRequest> captor = ArgumentCaptor.forClass(DescribeFeatureTypeRequest.class);
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 1);
final String SAMPLE_FEATURE_NAME0 = SAMPLE_FEATURE_NAME + "0";
verify(mockWfs).describeFeatureType(captor.capture());
DescribeFeatureTypeRequest describeFeatureType = captor.getValue();
// sample feature 0 does not have a prefix
assertThat(SAMPLE_FEATURE_NAME0, equalTo(describeFeatureType.getTypeName()));
assertTrue(source.isAvailable());
assertThat(source.featureTypeFilters.size(), is(1));
WfsFilterDelegate delegate = source.featureTypeFilters.get(new QName(SAMPLE_FEATURE_NAME0));
assertThat(delegate, notNullValue());
assertThat(source.getContentTypes().size(), is(1));
List<ContentType> types = new ArrayList<ContentType>();
types.addAll(source.getContentTypes());
assertTrue(SAMPLE_FEATURE_NAME0.equals(types.get(0).getName()));
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class CatalogFrameworkImplTest method testPreQueryStopExecution.
@Test(expected = FederationException.class)
public void testPreQueryStopExecution() throws UnsupportedQueryException, FederationException, SourceUnavailableException {
SourcePoller poller = mock(SourcePoller.class);
when(poller.getCachedSource(isA(Source.class))).thenReturn(null);
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
FederationStrategy federationStrategy = mock(FederationStrategy.class);
QueryRequest request = mock(QueryRequest.class);
when(request.getQuery()).thenReturn(mock(Query.class));
PreQueryPlugin stopQueryPlugin = new PreQueryPlugin() {
@Override
public QueryRequest process(QueryRequest input) throws PluginExecutionException, StopProcessingException {
throw new StopProcessingException("Testing that the framework will stop the query.");
}
};
FrameworkProperties frameworkProperties = new FrameworkProperties();
frameworkProperties.setSourcePoller(poller);
frameworkProperties.setPreQuery(Arrays.asList(stopQueryPlugin));
frameworkProperties.setFederationStrategy(federationStrategy);
frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
CatalogFrameworkImpl framework = createFramework(frameworkProperties);
framework.query(request);
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderUnavailableCreate.
// End testing CatalogFramework
// Test negative use-cases (expected errors)
/**
* Tests that the framework properly throws a catalog exception when the local provider is not
* available for create.
*
* @throws SourceUnavailableException
*/
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableCreate() throws SourceUnavailableException {
MockEventProcessor eventAdmin = new MockEventProcessor();
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
CatalogFramework framework = createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
List<Metacard> metacards = new ArrayList<Metacard>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
CreateRequest create = new CreateRequestImpl(metacards);
// expected to throw exception due to catalog provider being unavailable
try {
framework.create(create);
} catch (IngestException e) {
fail();
}
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnCreate.
@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnCreate() throws IngestException {
MockEventProcessor eventAdmin = new MockEventProcessor();
// use exception provider instead of memory
MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
List<Metacard> metacards = new ArrayList<Metacard>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
CreateRequest create = new CreateRequestImpl((Metacard) null);
try {
framework.create(create);
} catch (SourceUnavailableException e) {
fail();
}
}
use of ddf.catalog.data.ContentType in project ddf by codice.
the class WfsSource method getContentTypes.
@Override
public Set<ContentType> getContentTypes() {
Set<QName> typeNames = featureTypeFilters.keySet();
Set<ContentType> contentTypes = new HashSet<ContentType>();
for (QName featureName : typeNames) {
contentTypes.add(new ContentTypeImpl(featureName.getLocalPart(), getVersion()));
}
return contentTypes;
}
Aggregations