You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/01/23 15:12:00 UTC

olingo-odata4 git commit: [OLINGO-530] Changed default value for Nullable attribute

Repository: olingo-odata4
Updated Branches:
  refs/heads/master d013c7043 -> e827ce122


[OLINGO-530] Changed default value for Nullable attribute


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/e827ce12
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/e827ce12
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/e827ce12

Branch: refs/heads/master
Commit: e827ce1226e73c1ef8799d88ef8a325abdbe73d7
Parents: d013c70
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jan 23 15:08:27 2015 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jan 23 15:08:27 2015 +0100

----------------------------------------------------------------------
 .../json/ODataJsonDeserializer.java             |  97 ++++---
 .../json/ODataJsonDeserializerEntityTest.java   | 281 ++++++++++++-------
 2 files changed, 225 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e827ce12/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index 1867cd7..2fa54a0 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -217,8 +217,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       JsonNode jsonNode = node.get(propertyName);
       if (jsonNode != null) {
         EdmProperty edmProperty = (EdmProperty) edmEntityType.getProperty(propertyName);
-        boolean isNullable = edmProperty.isNullable() == null ? false : edmProperty.isNullable();
-        if (jsonNode.isNull() && !isNullable) {
+        if (jsonNode.isNull() && !isNullable(edmProperty)) {
           throw new DeserializerException("Property: " + propertyName + " must not be null.",
               DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName);
         }
@@ -237,7 +236,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       JsonNode jsonNode = node.get(navigationPropertyName);
       if (jsonNode != null) {
         EdmNavigationProperty edmNavigationProperty = edmEntityType.getNavigationProperty(navigationPropertyName);
-        boolean isNullable = edmNavigationProperty.isNullable() == null ? false : edmNavigationProperty.isNullable();
+        boolean isNullable = edmNavigationProperty.isNullable() == null ? true : edmNavigationProperty.isNullable();
         if (jsonNode.isNull() && !isNullable) {
           throw new DeserializerException("Property: " + navigationPropertyName + " must not be null.",
               DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, navigationPropertyName);
@@ -315,7 +314,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private Property consumePropertyNode(EdmProperty edmProperty, JsonNode jsonNode) throws DeserializerException {
+  private Property consumePropertyNode(final EdmProperty edmProperty, final JsonNode jsonNode)
+          throws DeserializerException {
     Property property = new PropertyImpl();
     property.setName(edmProperty.getName());
     property.setType(edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
@@ -344,27 +344,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       property.setValue(ValueType.PRIMITIVE, value);
       break;
     case COMPLEX:
-      // read and add all complex properties
-      value = readComplexValue(edmProperty, jsonNode);
+      value = readComplexNode(edmProperty, jsonNode);
       property.setValue(ValueType.COMPLEX, value);
 
-      final List<String> toRemove = new ArrayList<String>();
-      Iterator<Entry<String, JsonNode>> fieldsIterator = jsonNode.fields();
-      while (fieldsIterator.hasNext()) {
-        Entry<String, JsonNode> field = fieldsIterator.next();
-
-        if (field.getKey().contains(ODATA_CONTROL_INFORMATION_PREFIX)) {
-          // Control Information is ignored for requests as per specification chapter "4.5 Control Information"
-          toRemove.add(field.getKey());
-        } else if (field.getKey().contains(ODATA_ANNOTATION_MARKER)) {
-          throw new DeserializerException("Custom annotation with field name: " + field.getKey() + " not supported",
-              DeserializerException.MessageKeys.NOT_IMPLEMENTED);
-        }
-      }
-      // remove here to avoid iterator issues.
-      ((ObjectNode) jsonNode).remove(toRemove);
-      // Afterwards the node must be empty
-      assertJsonNodeIsEmpty(jsonNode);
       break;
     default:
       throw new DeserializerException("Invalid Type Kind for a property found: " + edmProperty.getType().getKind(),
@@ -372,6 +354,34 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
+  private Object readComplexNode(final EdmProperty edmProperty, final JsonNode jsonNode)
+          throws DeserializerException {
+    // read and add all complex properties
+    Object value = readComplexValue(edmProperty, jsonNode);
+
+    final List<String> toRemove = new ArrayList<String>();
+    Iterator<Entry<String, JsonNode>> fieldsIterator = jsonNode.fields();
+    while (fieldsIterator.hasNext()) {
+      Entry<String, JsonNode> field = fieldsIterator.next();
+
+      if (field.getKey().contains(ODATA_CONTROL_INFORMATION_PREFIX)) {
+        // Control Information is ignored for requests as per specification chapter "4.5 Control Information"
+        toRemove.add(field.getKey());
+      } else if (field.getKey().contains(ODATA_ANNOTATION_MARKER)) {
+        throw new DeserializerException("Custom annotation with field name: " + field.getKey() + " not supported",
+            DeserializerException.MessageKeys.NOT_IMPLEMENTED);
+      }
+    }
+    // remove here to avoid iterator issues.
+    if(!jsonNode.isNull()) {
+      ((ObjectNode) jsonNode).remove(toRemove);
+    }
+    // Afterwards the node must be empty
+    assertJsonNodeIsEmpty(jsonNode);
+
+    return value;
+  }
+
   private void consumePropertyCollectionNode(final EdmProperty edmProperty, final JsonNode jsonNode,
       final Property property) throws DeserializerException {
     if (!jsonNode.isArray()) {
@@ -408,29 +418,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       break;
     case COMPLEX:
       while (iterator.hasNext()) {
-        JsonNode arrayElement = iterator.next();
         // read and add all complex properties
-        Object value = readComplexValue(edmProperty, arrayElement);
+        Object value = readComplexNode(edmProperty, iterator.next());
         valueArray.add(value);
-
-        final List<String> toRemove = new ArrayList<String>();
-        Iterator<Entry<String, JsonNode>> fieldsIterator = arrayElement.fields();
-        while (fieldsIterator.hasNext()) {
-          Entry<String, JsonNode> field = fieldsIterator.next();
-
-          if (field.getKey().contains(ODATA_CONTROL_INFORMATION_PREFIX)) {
-            // Control Information is ignored for requests as per specification chapter "4.5 Control Information"
-            toRemove.add(field.getKey());
-          } else if (field.getKey().contains(ODATA_ANNOTATION_MARKER)) {
-            throw new DeserializerException(
-                "Custom annotation with field name: " + field.getKey() + " not supported",
-                DeserializerException.MessageKeys.NOT_IMPLEMENTED);
-          }
-        }
-        // remove here to avoid iterator issues.
-        ((ObjectNode) arrayElement).remove(toRemove);
-        // Afterwards the node must be empty
-        assertJsonNodeIsEmpty(arrayElement);
       }
       property.setValue(ValueType.COLLECTION_COMPLEX, valueArray);
       break;
@@ -441,6 +431,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   private Object readComplexValue(EdmProperty edmComplexProperty, JsonNode jsonNode) throws DeserializerException {
+    if(isNullable(edmComplexProperty) && jsonNode.isNull()) {
+      return null;
+    }
     if (jsonNode.isArray() || !jsonNode.isContainerNode()) {
       throw new DeserializerException(
           "Invalid value for property: " + edmComplexProperty.getName() + " must not be an array or primitive value.",
@@ -454,8 +447,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       JsonNode subNode = jsonNode.get(propertyName);
       if (subNode != null) {
         EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);
-        boolean isNullable = edmProperty.isNullable() == null ? false : edmProperty.isNullable();
-        if (subNode.isNull() && !isNullable) {
+        if (subNode.isNull() && !isNullable(edmProperty)) {
           throw new DeserializerException("Property: " + propertyName + " must not be null.",
               DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName);
         }
@@ -467,8 +459,15 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     return propertyList;
   }
 
+  private boolean isNullable(EdmProperty edmProperty) {
+    return edmProperty.isNullable() == null ? true : edmProperty.isNullable();
+  }
+
   private Object readTypeDefinitionValue(EdmProperty edmProperty, JsonNode jsonNode) throws DeserializerException {
     checkForValueNode(edmProperty, jsonNode);
+    if(isNullable(edmProperty) && jsonNode.isNull()) {
+      return null;
+    }
     try {
       EdmTypeDefinition edmTypeDefinition = (EdmTypeDefinition) edmProperty.getType();
       checkJsonTypeBasedOnPrimitiveType(edmProperty.getName(), edmTypeDefinition.getUnderlyingType().getName(),
@@ -486,6 +485,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   private Object readEnumValue(EdmProperty edmProperty, JsonNode jsonNode) throws DeserializerException {
     checkForValueNode(edmProperty, jsonNode);
+    if(isNullable(edmProperty) && jsonNode.isNull()) {
+      return null;
+    }
     try {
       EdmEnumType edmEnumType = (EdmEnumType) edmProperty.getType();
       checkJsonTypeBasedOnPrimitiveType(edmProperty.getName(), edmEnumType.getUnderlyingType().getName(), jsonNode);
@@ -501,6 +503,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   private Object readPrimitiveValue(EdmProperty edmProperty, JsonNode jsonNode) throws DeserializerException {
     checkForValueNode(edmProperty, jsonNode);
+    if(isNullable(edmProperty) && jsonNode.isNull()) {
+      return null;
+    }
     try {
       EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmProperty.getType();
       checkJsonTypeBasedOnPrimitiveType(edmProperty.getName(), edmPrimitiveType.getName(), jsonNode);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e827ce12/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index e0d05e1..c467f2e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.server.core.deserializer.json;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -103,6 +104,39 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   }
 
   @Test
+  public void simpleEntityETAllPrimWithDefaultNullValue() throws Exception {
+    String entityString =
+            "{\"PropertyInt16\":32767," +
+                    "\"PropertyString\":\"First Resource - positive values\"," +
+                    "\"PropertyBoolean\":null," +
+                    "\"PropertyByte\":255," +
+                    "\"PropertySByte\":127," +
+                    "\"PropertyInt32\":2147483647," +
+                    "\"PropertyInt64\":9223372036854775807," +
+                    "\"PropertySingle\":1.79E20," +
+                    "\"PropertyDouble\":-1.79E19," +
+                    "\"PropertyDecimal\":34," +
+                    "\"PropertyBinary\":\"ASNFZ4mrze8=\"," +
+                    "\"PropertyDate\":null," +
+                    "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"," +
+                    "\"PropertyDuration\":\"PT6S\"," +
+                    "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
+                    "\"PropertyTimeOfDay\":\"03:26:05\"}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity entity =
+            deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+    assertNotNull(entity);
+    List<Property> properties = entity.getProperties();
+    assertNotNull(properties);
+    assertEquals(16, properties.size());
+
+    assertEquals("First Resource - positive values", entity.getProperty("PropertyString").getValue());
+    assertNull(entity.getProperty("PropertyBoolean").getValue());
+    assertNull(entity.getProperty("PropertyDate").getValue());
+  }
+
+  @Test
   public void simpleEntityETAllPrimNoTAllPropertiesPresent() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767," +
@@ -119,6 +153,39 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   }
 
   @Test
+  public void simpleEntityETNoneNullable() throws Exception {
+    String entityString =
+            "{\"PropertyInt16\":32767," +
+                    "\"PropertyString\":\"First Resource - positive values\"," +
+                    "\"PropertyBoolean\":null," +
+                    "\"PropertyByte\":255," +
+                    "\"PropertySByte\":127," +
+                    "\"PropertyInt32\":2147483647," +
+                    "\"PropertyInt64\":9223372036854775807," +
+                    "\"PropertySingle\":1.79E20," +
+                    "\"PropertyDouble\":-1.79E19," +
+                    "\"PropertyDecimal\":34," +
+                    "\"PropertyBinary\":\"ASNFZ4mrze8=\"," +
+                    "\"PropertyDate\":null," +
+                    "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"," +
+                    "\"PropertyDuration\":\"PT6S\"," +
+                    "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
+                    "\"PropertyTimeOfDay\":\"03:26:05\"}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity entity =
+            deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+    assertNotNull(entity);
+    List<Property> properties = entity.getProperties();
+    assertNotNull(properties);
+    assertEquals(16, properties.size());
+
+    assertEquals("First Resource - positive values", entity.getProperty("PropertyString").getValue());
+    assertNull(entity.getProperty("PropertyBoolean").getValue());
+    assertNull(entity.getProperty("PropertyDate").getValue());
+  }
+
+  @Test
   public void simpleEntityETCompAllPrim() throws Exception {
     String entityString = "{\"PropertyInt16\":32767," +
         "\"PropertyComp\":{" +
@@ -422,7 +489,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
         deserializer.entity(stream, edm
-            .getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
+                .getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
 
     assertEquals(6, entity.getProperties().size());
 
@@ -439,15 +506,113 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals((short) 2, value.get(0).getValue());
   }
 
+  @Test
+  public void eTCollAllPrimWithNullValue() throws Exception {
+    final String entityString = "{"
+            + "\"PropertyInt16\":1,"
+            + "\"CollPropertyString\":"
+            + "[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"],"
+            + "\"CollPropertyBoolean\":[true,null,false],"
+            + "\"CollPropertyByte\":[50,200,249],"
+            + "\"CollPropertySByte\":[-120,120,126],"
+            + "\"CollPropertyInt16\":[1000,2000,30112],"
+            + "\"CollPropertyInt32\":[23232323,11223355,10000001],"
+            + "\"CollPropertyInt64\":[929292929292,333333333333,444444444444],"
+            + "\"CollPropertySingle\":[1790.0,26600.0,3210.0],"
+            + "\"CollPropertyDouble\":[-17900.0,-2.78E7,3210.0],"
+            + "\"CollPropertyDecimal\":[12,-2,1234],"
+            + "\"CollPropertyBinary\":[\"q83v\",\"ASNF\",\"VGeJ\"],"
+            + "\"CollPropertyDate\":[\"1958-12-03\",\"1999-08-05\",\"2013-06-25\"],"
+            + "\"CollPropertyDateTimeOffset\":[\"2015-08-12T03:08:34Z\",\"1970-03-28T12:11:10Z\","
+            + "\"1948-02-17T09:09:09Z\"],"
+            + "\"CollPropertyDuration\":[\"PT13S\",\"PT5H28M0S\",\"PT1H0S\"],"
+            + "\"CollPropertyGuid\":[\"ffffff67-89ab-cdef-0123-456789aaaaaa\",\"eeeeee67-89ab-cdef-0123-456789bbbbbb\","
+            + "\"cccccc67-89ab-cdef-0123-456789cccccc\"],"
+            + "\"CollPropertyTimeOfDay\":[\"04:14:13\",\"23:59:59\",\"01:12:33\"]"
+            + "}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity e = deserializer.entity(stream, edm.getEntityType(
+            new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
+
+    assertTrue((Boolean) e.getProperty("CollPropertyBoolean").asCollection().get(0));
+    assertNull(e.getProperty("CollPropertyBoolean").asCollection().get(1));
+    assertFalse((Boolean) e.getProperty("CollPropertyBoolean").asCollection().get(2));
+  }
+
+  @Test
+  public void validJsonValueForComplexTypeNull() throws Exception {
+    final String entityString = "{"
+            + "\"PropertyComp\":null"
+            + "}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity entity = deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias",
+            "ETMixPrimCollComp")));
+
+    assertNull(entity.getProperty("PropertyComp").getValue());
+  }
+
+  @Test
+  public void validJsonValueForComplexCollectionNullValue() throws Exception {
+    final String entityString = "{"
+            + "\"CollPropertyComp\":["
+            + "null,"
+            + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+
+    Entity entity = deserializer.entity(stream, edm.getEntityType(
+            new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+    List<?> collPropertyComp = entity.getProperty("CollPropertyComp").asCollection();
+    assertNull(collPropertyComp.get(0));
+    List<Property> complexPropertyProperties = (List<Property>) collPropertyComp.get(1);
+    assertEquals(Short.valueOf((short) 789), complexPropertyProperties.get(0).getValue());
+    assertEquals("TEST 3", complexPropertyProperties.get(1).getValue());
+  }
+
+  @Test
+  public void validJsonValueForPrimPropertyInComplexTypeNull() throws Exception {
+    final String entityString = "{"
+            + "\"PropertyComp\":{\"PropertyInt16\":null,\"PropertyString\":\"TEST A\"}"
+            + "}";
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity entity = deserializer.entity(stream, edm.getEntityType(
+            new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+
+    assertNull(entity.getProperty("PropertyComp").asComplex().get(0).getValue());
+    assertEquals("TEST A", entity.getProperty("PropertyComp").asComplex().get(1).getValue());
+  }
+
+  @Test
+  public void eTMixEnumDefCollCompNavValidComplexEnumValueNull() throws Exception {
+    String entityString = "{"
+            + "\"PropertyEnumString\" : 2,"
+            + "\"PropertyCompMixedEnumDef\" : {"
+            + "\"PropertyEnumString\" : null"
+            + "}}";
+
+    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
+    Entity e = deserializer.entity(stream, edm.getEntityType(
+            new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
+
+    assertEquals(Short.valueOf("2"), e.getProperty("PropertyEnumString").getValue());
+    Property propertyCompMixedEnumDef = e.getProperty("PropertyCompMixedEnumDef");
+    assertNull(propertyCompMixedEnumDef.asComplex().get(0).getValue());
+  }
+
+
 //  ---------------------------------- Negative Tests -----------------------------------------------------------
 
   @Test(expected = DeserializerException.class)
-  public void etAllPrimWithNullValue() throws Exception {
+  public void etAllPrimWithInvalidNullValue() throws Exception {
     String entityString =
-        "{\"PropertyInt16\":32767," +
+        "{\"PropertyInt16\":null," +
             "\"PropertyString\":\"First Resource - positive values\"," +
             "\"PropertyBoolean\":true," +
-            "\"PropertyByte\":null," +
+            "\"PropertyByte\":255," +
             "\"PropertySByte\":127," +
             "\"PropertyInt32\":2147483647," +
             "\"PropertyInt64\":9223372036854775807," +
@@ -471,40 +636,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   }
 
   @Test(expected = DeserializerException.class)
-  public void eTCollAllPrimWithNullValue() throws Exception {
-    final String entityString = "{"
-        + "\"PropertyInt16\":1,"
-        + "\"CollPropertyString\":"
-        + "[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"],"
-        + "\"CollPropertyBoolean\":[true,null,true],"
-        + "\"CollPropertyByte\":[50,200,249],"
-        + "\"CollPropertySByte\":[-120,120,126],"
-        + "\"CollPropertyInt16\":[1000,2000,30112],"
-        + "\"CollPropertyInt32\":[23232323,11223355,10000001],"
-        + "\"CollPropertyInt64\":[929292929292,333333333333,444444444444],"
-        + "\"CollPropertySingle\":[1790.0,26600.0,3210.0],"
-        + "\"CollPropertyDouble\":[-17900.0,-2.78E7,3210.0],"
-        + "\"CollPropertyDecimal\":[12,-2,1234],"
-        + "\"CollPropertyBinary\":[\"q83v\",\"ASNF\",\"VGeJ\"],"
-        + "\"CollPropertyDate\":[\"1958-12-03\",\"1999-08-05\",\"2013-06-25\"],"
-        + "\"CollPropertyDateTimeOffset\":[\"2015-08-12T03:08:34Z\",\"1970-03-28T12:11:10Z\","
-        + "\"1948-02-17T09:09:09Z\"],"
-        + "\"CollPropertyDuration\":[\"PT13S\",\"PT5H28M0S\",\"PT1H0S\"],"
-        + "\"CollPropertyGuid\":[\"ffffff67-89ab-cdef-0123-456789aaaaaa\",\"eeeeee67-89ab-cdef-0123-456789bbbbbb\","
-        + "\"cccccc67-89ab-cdef-0123-456789cccccc\"],"
-        + "\"CollPropertyTimeOfDay\":[\"04:14:13\",\"23:59:59\",\"01:12:33\"]"
-        + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
-  }
-
-  @Test(expected = DeserializerException.class)
   public void doublePrimitiveProperty() throws Exception {
     final String entityString = "{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\"," +
         "\"PropertyInt16\":32766,\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
@@ -1017,52 +1148,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   }
 
   @Test(expected = DeserializerException.class)
-  public void invalidJsonValueForComplexTypeNull() throws Exception {
-    final String entityString = "{"
-        + "\"PropertyComp\":null"
-        + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
-  }
-
-  @Test(expected = DeserializerException.class)
-  public void invalidJsonValueForComplexCollectionNullValue() throws Exception {
-    final String entityString = "{"
-        + "\"CollPropertyComp\":["
-        + "null,"
-        + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
-  }
-
-  @Test(expected = DeserializerException.class)
-  public void invalidJsonValueForPrimPropertyInComplexTypeNull() throws Exception {
-    final String entityString = "{"
-        + "\"PropertyComp\":{\"PropertyInt16\":null,\"PropertyString\":\"TEST A\"}"
-        + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
-  }
-
-  @Test(expected = DeserializerException.class)
   public void provokedPrimitiveTypeException() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767000000000000000000000000000000000000"
@@ -1087,30 +1172,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
-  }
-
-  @Test(expected = DeserializerException.class)
-  public void eTMixEnumDefCollCompNavInvalidComplexEnumValueNull() throws Exception {
-    String entityString = "{"
-        + "\"PropertyEnumString\" : 2,"
-        + "\"PropertyCompMixedEnumDef\" : {"
-        + "\"PropertyEnumString\" : null"
-        + "}}";
+    Entity e = deserializer.entity(stream, edm.getEntityType(
+            new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
 
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    assertNull(e.getProperty("PropertyEnumString").getValue());
+    Property propertyCompMixedEnumDef = e.getProperty("PropertyCompMixedEnumDef");
+    assertEquals(Short.valueOf("2"), propertyCompMixedEnumDef.asComplex().get(0).getValue());
   }
 
   @Test(expected = DeserializerException.class)