use of org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata in project ddf by codice.
the class FeatureTransformationServiceTest method testApplyBadXML.
@Test
public void testApplyBadXML() {
InputStream inputStream = new BufferedInputStream(FeatureTransformationServiceTest.class.getResourceAsStream("/Broken.xml"));
WfsMetadata wfsMetadata = mock(WfsMetadata.class);
when(wfsMetadata.getFeatureMemberNodeNames()).thenReturn(Collections.singletonList("featureMember"));
WfsFeatureCollection wfsFeatureCollection = featureTransformationService.apply(inputStream, wfsMetadata);
ArgumentCaptor<InputStream> inputStreamArgumentCaptor = ArgumentCaptor.forClass(InputStream.class);
ArgumentCaptor<WfsMetadata> wfsMetadataArgumentCaptor = ArgumentCaptor.forClass(WfsMetadata.class);
verify(transformerList.get(0), times(0)).apply(inputStreamArgumentCaptor.capture(), wfsMetadataArgumentCaptor.capture());
assertThat(wfsFeatureCollection.getNumberOfFeatures(), is(10L));
assertThat(wfsFeatureCollection.getFeatureMembers(), hasSize(0));
}
use of org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata in project ddf by codice.
the class FeatureTransformationServiceTest method testFeatureMembersWithNoNumberOfFeaturesAttribute.
@Test
public void testFeatureMembersWithNoNumberOfFeaturesAttribute() throws Exception {
try (final InputStream inputStream = getClass().getResourceAsStream("/NeverlandNoNumberOfFeaturesAttribute.xml")) {
final WfsMetadata wfsMetadata = mock(WfsMetadata.class);
when(wfsMetadata.getFeatureMemberNodeNames()).thenReturn(Collections.singletonList("featureMember"));
final WfsFeatureCollection wfsFeatureCollection = featureTransformationService.apply(inputStream, wfsMetadata);
assertThat(wfsFeatureCollection.getNumberOfFeatures(), is(10L));
assertThat(wfsFeatureCollection.getFeatureMembers(), hasSize(10));
}
}
use of org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata in project ddf by codice.
the class FeatureTransformationServiceTest method testMultipleFeatureMemberNodeNames.
@Test
public void testMultipleFeatureMemberNodeNames() throws Exception {
try (final InputStream inputStream = getClass().getResourceAsStream("/Tasmania.xml")) {
final WfsMetadata wfsMetadata = mock(WfsMetadata.class);
when(wfsMetadata.getFeatureMemberNodeNames()).thenReturn(Arrays.asList("tasmania_water_bodies", "streams", "roads", "poi", "giant_polygon", "archsites", "bugsites", "tasmania_state_boundaries", "tiger_roads", "states", "tasmania_cities", "restricted", "poly_landmarks", "tasmania_roads"));
final WfsFeatureCollection wfsFeatureCollection = featureTransformationService.apply(inputStream, wfsMetadata);
assertThat(wfsFeatureCollection.getNumberOfFeatures(), is(2L));
assertThat(wfsFeatureCollection.getFeatureMembers(), hasSize(2));
}
}
use of org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata in project ddf by codice.
the class FeatureTransformationServiceTest method validateTenMetacards.
private void validateTenMetacards(String inputFileName, String featureNodeName) {
InputStream inputStream = new BufferedInputStream(FeatureTransformationServiceTest.class.getResourceAsStream(inputFileName));
WfsMetadata wfsMetadata = mock(WfsMetadata.class);
when(wfsMetadata.getFeatureMemberNodeNames()).thenReturn(Collections.singletonList(featureNodeName));
WfsFeatureCollection wfsFeatureCollection = featureTransformationService.apply(inputStream, wfsMetadata);
ArgumentCaptor<InputStream> inputStreamArgumentCaptor = ArgumentCaptor.forClass(InputStream.class);
ArgumentCaptor<WfsMetadata> wfsMetadataArgumentCaptor = ArgumentCaptor.forClass(WfsMetadata.class);
verify(transformerList.get(0), times(FEATURE_MEMBER_COUNT)).apply(inputStreamArgumentCaptor.capture(), wfsMetadataArgumentCaptor.capture());
for (int i = 0; i < FEATURE_MEMBER_COUNT; i++) {
assertThat(inputStreamArgumentCaptor.getAllValues().get(i), notNullValue());
assertThat(wfsMetadataArgumentCaptor.getAllValues().get(i), notNullValue());
}
assertThat(wfsFeatureCollection.getNumberOfFeatures(), is(10L));
assertThat(wfsFeatureCollection.getFeatureMembers(), hasSize(10));
}
Aggregations