diff --git a/src/test/java/org/geojson/jackson/GeometryCollectionTest.java b/src/test/java/org/geojson/jackson/GeometryCollectionTest.java index a7d0382..02c743d 100644 --- a/src/test/java/org/geojson/jackson/GeometryCollectionTest.java +++ b/src/test/java/org/geojson/jackson/GeometryCollectionTest.java @@ -1,13 +1,10 @@ package org.geojson.jackson; import com.fasterxml.jackson.databind.ObjectMapper; -import org.geojson.GeometryCollection; -import org.geojson.LineString; -import org.geojson.LngLatAlt; -import org.geojson.Point; +import org.geojson.*; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; public class GeometryCollectionTest { @@ -23,4 +20,38 @@ public void itShouldSerialize() throws Exception { + "{\"type\":\"LineString\",\"coordinates\":[[101.0,0.0],[102.0,1.0]]}]}", mapper.writeValueAsString(gc)); } + + @Test + public void itShouldDeserialize() throws Exception { + GeometryCollection geometryCollection = mapper + .readValue("{\"type\":\"GeometryCollection\"," + + "\"geometries\":[{\"type\":\"Point\",\"coordinates\":[100.0,0.0]}," + + "{\"type\":\"LineString\",\"coordinates\":[[101.0,0.0],[102.0,1.0]]}]}", + GeometryCollection.class); + assertNotNull(geometryCollection); + } + + @Test + public void itShouldDeserializeSubtype() throws Exception { + FeatureCollection collection = mapper + .readValue("{\"type\": \"FeatureCollection\"," + + " \"features\": [" + + " {" + + " \"type\": \"Feature\"," + + " \"geometry\": {" + + " \"type\": \"GeometryCollection\"," + + " \"geometries\": [" + + " {" + + " \"type\": \"Point\"," + + " \"coordinates\": [100.0, 0.0]" + + " }" + + " ]" + + " }" + + " }" + + " ]" + + "}", + FeatureCollection.class); + assertNotNull(collection); + assertTrue(collection.getFeatures().get(0).getGeometry() instanceof GeometryCollection); + } }