Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public static Feature fromGeometry(@Nullable Geometry geometry, @Nullable JsonOb
*/
public static Feature fromGeometry(@Nullable Geometry geometry, @NonNull JsonObject properties,
@Nullable String id, @Nullable BoundingBox bbox) {
return new AutoValue_Feature(TYPE, bbox, id, geometry, properties);
return new AutoValue_Feature(TYPE, bbox, id, geometry,
properties == null ? new JsonObject() : properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static MultiPoint fromLngLats(@NonNull double[][] coordinates) {
* @return a list of points
* @since 3.0.0
*/
@Nullable
@NonNull
@Override
public abstract List<Point> coordinates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public List<LineString> inner() {
* @return a list of points
* @since 3.0.0
*/
@Nullable
@NonNull
@Override
public abstract List<List<Point>> coordinates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ public void toJson() throws IOException {
LineString geo = LineString.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
LineString.fromJson("{\"type\":\"LineString\",\"coordinates\":null}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import static org.junit.Assert.assertNull;

import com.mapbox.core.TestUtils;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -16,6 +19,9 @@ public class MultiLineStringTest extends TestUtils {

private static final String SAMPLE_MULTILINESTRING = "sample-multilinestring.json";

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void sanity() throws Exception {
List<Point> points = new ArrayList<>();
Expand Down Expand Up @@ -133,4 +139,10 @@ public void toJson() throws IOException {
MultiLineString geo = MultiLineString.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
MultiLineString.fromJson("{\"type\":\"MultiLineString\",\"coordinates\":null}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import com.mapbox.core.TestUtils;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -17,6 +19,9 @@ public class MultiPointTest extends TestUtils {

private static final String SAMPLE_MULTIPOINT = "sample-multipoint.json";

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void sanity() throws Exception {
List<Point> points = new ArrayList<>();
Expand Down Expand Up @@ -106,4 +111,10 @@ public void toJson() throws IOException {
MultiPoint geo = MultiPoint.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
MultiPoint.fromJson("{\"type\":\"MultiPoint\",\"coordinates\":null}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import com.mapbox.core.TestUtils;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -16,6 +18,9 @@
public class MultiPolygonTest extends TestUtils {
private static final String SAMPLE_MULTIPOLYGON = "sample-multipolygon.json";

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void sanity() throws Exception {
List<Point> points = new ArrayList<>();
Expand Down Expand Up @@ -151,4 +156,10 @@ public void toJson() throws IOException {
MultiPolygon geo = MultiPolygon.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
MultiPolygon.fromJson("{\"type\":\"MultiPolygon\",\"coordinates\":null}");
}
}
14 changes: 13 additions & 1 deletion services-geojson/src/test/java/com/mapbox/geojson/PointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import static org.junit.Assert.assertNull;

import com.mapbox.core.TestUtils;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -17,6 +20,9 @@ public class PointTest extends TestUtils {

private static final String SAMPLE_POINT = "sample-point.json";

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void sanity() throws Exception {
Point point = Point.fromLngLat(1.0, 2.0);
Expand Down Expand Up @@ -60,7 +66,7 @@ public void bbox_nullWhenNotSet() throws Exception {
}

@Test
public void bbox_doesNotSerializeWhenNotPresent() throws Exception {
public void bbox_doesSerializeWhenNotPresent() throws Exception {
Point point = Point.fromLngLat(1.0, 2.0);
compareJson(point.toJson(),
"{\"type\":\"Point\",\"coordinates\":[1.0, 2.0]}");
Expand Down Expand Up @@ -126,4 +132,10 @@ public void toJson() throws IOException {
Point geo = Point.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
Point.fromJson("{\"type\":\"Point\",\"coordinates\":null}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,10 @@ public void toJsonHoles() throws IOException {
Polygon geo = Polygon.fromJson(json);
compareJson(json, geo.toJson());
}

@Test
public void fromJson_coordinatesPresent() throws Exception {
thrown.expect(NullPointerException.class);
Polygon.fromJson("{\"type\":\"Polygon\",\"coordinates\":null}");
}
}