TurfAssertions { public static void geojsonType(GeoJson value, String type, String name) { if (type == null || type.length() == 0 || name == null || name.length() == 0) { throw new TurfException("Type and name required"); } if (value == null || !value.type().equals(type)) { throw new TurfException("Invalid input to " + name + ": must be a " + type + ", given " + (value != null ? value.type() : " null")); } } private  TurfAssertions(); @Deprecated static Point getCoord(Feature obj); static void geojsonType(GeoJson value, String type, String name); static void featureOf(Feature feature, String type, String name); static void collectionOf(FeatureCollection featureCollection, String type, String name);  }
@Test public void testInvariantGeojsonType1() throws TurfException { thrown.expect(TurfException.class); thrown.expectMessage(startsWith("Type and name required")); TurfAssertions.geojsonType(null, null, null); }
@Test public void testInvariantGeojsonType2() throws TurfException { thrown.expect(TurfException.class); thrown.expectMessage(startsWith("Type and name required")); TurfAssertions.geojsonType(null, null, "myfn"); }
@Test public void testInvariantGeojsonType3() throws TurfException { String json = "{ type: 'Point', coordinates: [0, 0] }"; thrown.expect(TurfException.class); thrown.expectMessage(startsWith("Invalid input to myfn: must be a Polygon, given Point")); TurfAssertions.geojsonType(Point.fromJson(json), "Polygon", "myfn"); }
@Test public void testInvariantGeojsonType4() { String json = "{ type: 'Point', coordinates: [0, 0] }"; TurfAssertions.geojsonType(Point.fromJson(json), "Point", "myfn"); }