@Test
 public void testGeoPointAsDoubleArray() {
   final double lat = rand.nextDouble() * 90 - 90;
   final double lon = rand.nextDouble() * 180 - 180;
   final Geometry geometry = parserUtil.createGeometry(Arrays.asList(new Double[] {lon, lat}));
   assertTrue(geometry.equals(geometryFactory.createPoint(new Coordinate(lon, lat))));
 }
 @Test
 public void testReadStringField() {
   properties.put("attr", "value");
   List<Object> values = parserUtil.readField(properties, "attr");
   assertTrue(values.size() == 1);
   assertTrue(values.get(0).equals("value"));
 }
 @Test
 public void testGeoShapeGeometryCollection()
     throws JsonParseException, JsonMappingException, IOException {
   rgb.setNumGeometries(5);
   GeometryCollection geom = rgb.createRandomGeometryCollection();
   assertTrue(parserUtil.createGeometry(rgb.toMap(geom)).equalsExact(geom, 1e-9));
 }
 @Test
 public void testReadNumericField() {
   properties.put("attr", 2.3);
   List<Object> values = parserUtil.readField(properties, "attr");
   assertTrue(values.size() == 1);
   assertTrue(values.get(0).equals(2.3));
 }
 @Test
 public void testReadInnerString() {
   properties.put("parent", new LinkedHashMap<String, Object>());
   ((Map) properties.get("parent")).put("attr", "value");
   List<Object> values = parserUtil.readField(properties, "parent.attr");
   assertTrue(values.size() == 1);
   assertTrue(values.get(0).equals("value"));
 }
 @Test
 public void testParseGeoPointPatternForNegatives() {
   final double lat = rand.nextDouble() * 90 - 90;
   final double lon = rand.nextDouble() * 180 - 180;
   final String value = lat + "," + lon;
   final Geometry geom = parserUtil.createGeometry(value);
   assertTrue(geom.equals(geometryFactory.createPoint(new Coordinate(lon, lat))));
 }
 @Test
 public void testGeoPointPatternForFractions() {
   final double lat = rand.nextDouble() * 2 - 1;
   final double lon = rand.nextDouble() * 2 - 1;
   final String value = (lat + "," + lon).replace("0.", ".");
   final Geometry geom = parserUtil.createGeometry(value);
   assertTrue(geom.equals(geometryFactory.createPoint(new Coordinate(lon, lat))));
 }
 @Test
 public void testGeoHash() {
   final double lat = rand.nextDouble() * 90 - 90;
   final double lon = rand.nextDouble() * 180 - 180;
   String geohash = GeoHashUtils.encode(lat, lon, 64);
   final Geometry expected = geometryFactory.createPoint(new Coordinate(lon, lat));
   assertTrue(parserUtil.createGeometry(geohash).equals(expected));
 }
 @Test
 public void testGeoPointAsUnrecognizedProperties() {
   final double lat = rand.nextDouble() * 90 - 90;
   final double lon = rand.nextDouble() * 180 - 180;
   properties.put("latD", lat);
   properties.put("lonD", lon);
   final Geometry geometry = parserUtil.createGeometry(properties);
   assertTrue(geometry == null);
 }
 @Test
 public void testReadInnerStringArray() {
   properties.put("parent", new LinkedHashMap<String, Object>());
   ((Map) properties.get("parent")).put("attr", Arrays.asList(new String[] {"value1", "value2"}));
   List<Object> values = parserUtil.readField(properties, "parent.attr");
   assertTrue(values.size() == 2);
   assertTrue(values.get(0).equals("value1"));
   assertTrue(values.get(1).equals("value2"));
 }
 @Test
 public void testGeoPointAsProperties() {
   final double lat = rand.nextDouble() * 90 - 90;
   final double lon = rand.nextDouble() * 180 - 180;
   properties.put("lat", lat);
   properties.put("lon", lon);
   final Geometry geometry = parserUtil.createGeometry(properties);
   assertTrue(geometry.equals(geometryFactory.createPoint(new Coordinate(lon, lat))));
 }
 @Test
 public void testReadMapField() {
   final Map<String, Object> map = new LinkedHashMap<String, Object>();
   properties.put("attr", map);
   map.put("attr2", "value2");
   map.put("attr3", "value3");
   List<Object> values = parserUtil.readField(properties, "attr");
   assertTrue(values.size() == 1);
   assertTrue(values.get(0).equals(map));
 }
 @Test
 public void testReadStringFieldWithConfuser() {
   properties.put("parent1", new LinkedHashMap<String, Object>());
   ((Map) properties.get("parent1")).put("attr", "value2");
   properties.put("attr", "value");
   properties.put("parent2", new LinkedHashMap<String, Object>());
   ((Map) properties.get("parent2")).put("attr", "value3");
   List<Object> values = parserUtil.readField(properties, "attr");
   assertTrue(values.size() == 1);
   assertTrue(values.get(0).equals("value"));
 }
 @Test
 public void testGeoShapePointString()
     throws JsonParseException, JsonMappingException, IOException {
   Point geom = rgb.createRandomPoint();
   final Map<String, Object> map = new HashMap<>();
   final List<String> coords = new ArrayList<>();
   coords.add(String.valueOf(geom.getX()));
   coords.add(String.valueOf(geom.getY()));
   map.put("coordinates", coords);
   map.put("type", "Point");
   assertTrue(parserUtil.createGeometry(map).equalsExact(geom, 1e-9));
 }
 @Test
 public void testReadStringFromObjectArray() {
   properties.put("parent", new ArrayList<Map<String, Object>>());
   ((List) properties.get("parent")).add(new LinkedHashMap<String, Object>());
   ((Map) ((List) properties.get("parent")).get(0)).put("attr", "value1");
   ((List) properties.get("parent")).add(new LinkedHashMap<String, Object>());
   ((Map) ((List) properties.get("parent")).get(1)).put("attr", "value2");
   List<Object> values = parserUtil.readField(properties, "parent.attr");
   assertTrue(values.size() == 2);
   assertTrue(values.get(0).equals("value1"));
   assertTrue(values.get(1).equals("value2"));
 }
 @Test
 public void testGeoPointAsInvalidArray() {
   final Geometry geometry = parserUtil.createGeometry(Arrays.asList(new Boolean[] {true, true}));
   assertTrue(geometry == null);
 }
 @Test
 public void testGeoPointPatternForWholeValues() {
   final Geometry geom = parserUtil.createGeometry("45,90");
   assertTrue(geom.equals(geometryFactory.createPoint(new Coordinate(90, 45))));
 }
 @Test
 public void testGeoShapeLineString()
     throws JsonParseException, JsonMappingException, IOException {
   LineString geom = rgb.createRandomLineString();
   assertTrue(parserUtil.createGeometry(rgb.toMap(geom)).equalsExact(geom, 1e-9));
 }
 @Test
 public void testGeoShapeMultiPolygon()
     throws JsonParseException, JsonMappingException, IOException {
   MultiPolygon geom = rgb.createRandomMultiPolygon();
   assertTrue(parserUtil.createGeometry(rgb.toMap(geom)).equalsExact(geom, 1e-9));
 }
 @Test
 public void testGeoShapeEnvelope() throws JsonParseException, JsonMappingException, IOException {
   Envelope envelope = rgb.createRandomEnvelope();
   Geometry expected = geometryFactory.toGeometry(envelope);
   assertTrue(parserUtil.createGeometry(rgb.toMap(envelope)).equalsExact(expected, 1e-9));
 }
 @Test
 public void testUnrecognizedGeometry() {
   final Geometry geom = parserUtil.createGeometry(3.0);
   assertTrue(geom == null);
 }