use of com.google.api.expr.v1alpha1.Reference in project geotoolkit by Geomatys.
the class FeatureCollectionToReferenceConverterTest method testJSONConversion.
@Test
public void testJSONConversion() throws DataStoreException, MalformedURLException, IOException, URISyntaxException, FactoryException {
// Get the test resource
final Object testResource = ConvertersTestUtils.loadTestResource("/inputs/featurecollection.json");
final Reference reference = ConvertersTestUtils.initAndRunOutputConversion(FeatureCollection.class, Reference.class, testResource, WPSMimeType.APP_GEOJSON.val(), WPSEncoding.UTF8.getValue());
// Test reference
assertEquals(WPSMimeType.APP_GEOJSON.val(), reference.getMimeType());
assertEquals(WPSEncoding.UTF8.getValue(), reference.getEncoding());
assertNull(reference.getSchema());
assertNotNull(reference.getHref());
final FeatureSet featureCollection = WPSConvertersUtils.readFeatureCollectionFromJson(URI.create(reference.getHref()));
ConvertersTestUtils.assertFeatureCollectionIsValid((FeatureSet) testResource);
ConvertersTestUtils.assertFeatureCollectionIsValid(featureCollection);
}
use of com.google.api.expr.v1alpha1.Reference in project geotoolkit by Geomatys.
the class FeatureToReferenceConverterTest method testJSONConversion.
@Test
public void testJSONConversion() throws DataStoreException, IOException, URISyntaxException, FactoryException {
// Get the test resource
final Object testResource = ConvertersTestUtils.loadTestResource("/inputs/feature.json");
final Reference reference = ConvertersTestUtils.initAndRunOutputConversion(Feature.class, Reference.class, testResource, WPSMimeType.APP_GEOJSON.val(), WPSEncoding.UTF8.getValue());
// Test reference
assertEquals(WPSMimeType.APP_GEOJSON.val(), reference.getMimeType());
assertEquals(WPSEncoding.UTF8.getValue(), reference.getEncoding());
assertNull(reference.getSchema());
assertNotNull(reference.getHref());
Feature feature = WPSConvertersUtils.readFeatureFromJson(URI.create(reference.getHref()));
ConvertersTestUtils.assertFeatureIsValid((Feature) testResource);
ConvertersTestUtils.assertFeatureIsValid(feature);
}
use of com.google.api.expr.v1alpha1.Reference in project geotoolkit by Geomatys.
the class GeometryToReferenceConverterTest method testJSONConversion.
@Test
public void testJSONConversion() throws DataStoreException, IOException, URISyntaxException, FactoryException {
// Get test resource
final Object testResource = ConvertersTestUtils.loadTestResource("/inputs/geometry.json");
Reference reference = ConvertersTestUtils.initAndRunOutputConversion(Geometry.class, Reference.class, testResource, WPSMimeType.APP_GEOJSON.val(), WPSEncoding.UTF8.getValue());
// Test reference
assertEquals(WPSMimeType.APP_GEOJSON.val(), reference.getMimeType());
assertEquals(WPSEncoding.UTF8.getValue(), reference.getEncoding());
assertNull(reference.getSchema());
assertNotNull(reference.getHref());
Geometry geometry = ConvertersTestUtils.getGeometryFromGeoJsonContent(Paths.get(URI.create(reference.getHref())));
ConvertersTestUtils.assertGeometryIsValid((Geometry) testResource);
ConvertersTestUtils.assertGeometryIsValid(geometry);
}
use of com.google.api.expr.v1alpha1.Reference in project geotoolkit by Geomatys.
the class ReferenceToRenderedImageConverterTest method testConversion.
@Test
public void testConversion() throws UnconvertibleObjectException, IOException {
final WPSObjectConverter<Reference, RenderedImage> converter = WPSConverterRegistry.getInstance().getConverter(Reference.class, RenderedImage.class);
final URL image = ReferenceToRenderedImageConverterTest.class.getResource("/inputs/image.tiff");
assertNotNull(image);
final Map<String, Object> parameters = new HashMap<>();
parameters.put(AbstractReferenceInputConverter.IOTYPE, WPSIO.IOType.INPUT);
final Reference reference = new Reference();
reference.setHref(image.toString());
reference.setMimeType("image/tiff");
reference.setEncoding(null);
final RenderedImage convertedImage = converter.convert(reference, parameters);
assertNotNull(convertedImage);
final RenderedImage expectedImage = ConvertersTestUtils.makeRendredImage();
assertRasterEquals(expectedImage, convertedImage);
}
use of com.google.api.expr.v1alpha1.Reference in project geotoolkit by Geomatys.
the class ReferenceToUrlConnectionConverterTest method convert.
@Test
public void convert() throws Exception {
final WPSObjectConverter<Reference, URLConnection> converter = WPSConverterRegistry.getInstance().getConverter(Reference.class, URLConnection.class);
final Reference ref = new Reference();
ref.setHref("https://my.domain/context");
final Reference.Header header = new Reference.Header();
header.setKey("myKey");
header.setValue("myValue");
ref.getHeader().add(header);
final URLConnection con = converter.convert(ref, Collections.singletonMap(WPSObjectConverter.IOTYPE, (Object) WPSIO.IOType.INPUT.name()));
Assert.assertEquals("HRef differs !", ref.getHref(), con.getURL().toExternalForm());
Assert.assertEquals("No header has been copied !", header.getValue(), con.getRequestProperty(header.getKey()));
}
Aggregations