Skip to content

Commit

Permalink
test for PR added
Browse files Browse the repository at this point in the history
  • Loading branch information
grundid committed Jun 26, 2015
1 parent 0e44f43 commit a192f70
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/test/java/org/geojson/jackson/GeometryCollectionTest.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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);
}
}

0 comments on commit a192f70

Please sign in to comment.