Search in sources :

Example 1 with WfsMetadata

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));
}
Also used : WfsMetadata(org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.WfsFeatureCollection) Test(org.junit.Test)

Example 2 with WfsMetadata

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));
    }
}
Also used : WfsMetadata(org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.WfsFeatureCollection) Test(org.junit.Test)

Example 3 with WfsMetadata

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));
    }
}
Also used : WfsMetadata(org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.WfsFeatureCollection) Test(org.junit.Test)

Example 4 with WfsMetadata

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));
}
Also used : WfsMetadata(org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.WfsFeatureCollection) Endpoint(org.apache.camel.Endpoint)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)4 InputStream (java.io.InputStream)4 WfsFeatureCollection (org.codice.ddf.spatial.ogc.wfs.catalog.WfsFeatureCollection)4 WfsMetadata (org.codice.ddf.spatial.ogc.wfs.featuretransformer.WfsMetadata)4 Test (org.junit.Test)3 Endpoint (org.apache.camel.Endpoint)1