### Question:
LocationSerializer implements JsonSerializer<JSON.Location> { @Override public JsonElement serialize(JSON.Location src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = (JsonObject) new GsonBuilder().create().toJsonTree(src); if (src.heading < 0 || src.heading >= 360) { jsonObject.remove("heading"); } return jsonObject; }  @Override JsonElement serialize(JSON.Location src, Type typeOfSrc,
      JsonSerializationContext context);  }### Answer:
@Test public void shouldIncludeHeading() throws Exception { assertThat(locationSerializer.serialize(location, JSON.Location.class, null).toString()) .contains("\"heading\":0"); }
@Test public void shouldExcludeHeadingLessThanZero() throws Exception { location.heading = -1; assertThat(locationSerializer.serialize(location, JSON.Location.class, null).toString()) .doesNotContain("\"heading\":-1"); }
@Test public void shouldExcludeHeadingEqualTo360() throws Exception { location.heading = 360; assertThat(locationSerializer.serialize(location, JSON.Location.class, null).toString()) .doesNotContain("\"heading\":360"); }
@Test public void shouldExcludeHeadingGreaterThan360() throws Exception { location.heading = 361; assertThat(locationSerializer.serialize(location, JSON.Location.class, null).toString()) .doesNotContain("\"heading\":361"); }