@Test
public void testClientEntityJSONWithNull() throws ODataSerializerException {

  String expectedJson = "{\"@odata.type\":\"#test.testClientEntity\","
      + "\"testInt32@odata.type\":\"Int32\","
      + "\"testInt32\":12,"
      + "\"testInt32Null@odata.type\":\"Int32\""
      + ",\"testInt32Null\":null,"
      + "\"testString@odata.type\":\"String\","
      + "\"testString\":\"testString\","
      + "\"testStringNull@odata.type\":\"String\","
      + "\"testStringNull\":null}";
  ODataClient odataClient = ODataClientFactory.getClient();
  ClientObjectFactory objFactory = odataClient.getObjectFactory();
  ClientEntity clientEntity = objFactory.newEntity(new FullQualifiedName("test", "testClientEntity"));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testInt32",
          objFactory.newPrimitiveValueBuilder().buildInt32(12)));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testInt32Null",
          objFactory.newPrimitiveValueBuilder().buildInt32(null)));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testString",
          objFactory.newPrimitiveValueBuilder().buildString("testString")));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testStringNull",
          objFactory.newPrimitiveValueBuilder().buildString(null)));
  JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON_FULL_METADATA);
  StringWriter writer = new StringWriter();
  jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity));
  assertThat(writer.toString(), is(expectedJson));
}