You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ra...@apache.org on 2019/08/29 04:21:58 UTC

[olingo-odata4] branch master updated: [OLINGO-1155]Delta support in Json format

This is an automated email from the ASF dual-hosted git repository.

ramyav pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git


The following commit(s) were added to refs/heads/master by this push:
     new 7632ec7  [OLINGO-1155]Delta support in Json format
7632ec7 is described below

commit 7632ec726845345467d07800e56723c30a053a3b
Author: ramya vasanth <ra...@sap.com>
AuthorDate: Thu Aug 29 09:51:44 2019 +0530

    [OLINGO-1155]Delta support in Json format
---
 .../EntityCollectionSerializerOptions.java         |  12 ++
 .../json/JsonDeltaSerializerWithNavigations.java   |  80 +++++++---
 .../olingo/server/tecsvc/data/DataCreator.java     |  32 +++-
 .../JsonDeltaSerializerWithNavigationsTest.java    | 177 ++++++++++++++++++++-
 4 files changed, 272 insertions(+), 29 deletions(-)

diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
index 6e49f81..006e477 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
@@ -35,6 +35,7 @@ public class EntityCollectionSerializerOptions {
   private String id;
   private ODataContentWriteErrorCallback odataContentWriteErrorCallback;
   private String xml10InvalidCharReplacement;
+  private boolean isFullRepresentation = false;
 
   /** Gets the {@link ContextURL}. */
   public ContextURL getContextURL() {
@@ -81,6 +82,11 @@ public class EntityCollectionSerializerOptions {
   public String xml10InvalidCharReplacement() {
     return xml10InvalidCharReplacement;
   }  
+  
+  /** Inline entries will not have @delta if representation is full **/ 
+  public boolean isFullRepresentation() {
+    return isFullRepresentation;
+  }
 
   /** Initializes the options builder. */
   public static Builder with() {
@@ -150,6 +156,12 @@ public class EntityCollectionSerializerOptions {
       return this;
     } 
     
+    /** sets isFullRepresentation to represent inline entries**/
+    public Builder isFullRepresentation(boolean isFullRepresentation) {
+      options.isFullRepresentation = isFullRepresentation;
+      return this;
+    }
+    
     /** Builds the OData serializer options. */
     public EntityCollectionSerializerOptions build() {
       return options;
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigations.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigations.java
index ad8635d..bf74efd 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigations.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigations.java
@@ -142,7 +142,8 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
     json.writeStartArray();
     for (final Entity entity : entitySet.getEntities()) {
       writeAddedUpdatedEntity(metadata, entityType, entity, options.getExpand(), options.getSelect(),
-          options.getContextURL(), false, options.getContextURL().getEntitySetOrSingletonOrType(), json);
+          options.getContextURL(), false, options.getContextURL().getEntitySetOrSingletonOrType(), json,
+          options.isFullRepresentation());
     }
     for (final DeletedEntity deletedEntity : entitySet.getDeletedEntities()) {
       writeDeletedEntity(deletedEntity, json);
@@ -232,7 +233,7 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
 
   public void writeAddedUpdatedEntity(final ServiceMetadata metadata, final EdmEntityType entityType,
       final Entity entity, final ExpandOption expand, final SelectOption select, final ContextURL url,
-      final boolean onlyReference, String name, final JsonGenerator json)
+      final boolean onlyReference, String name, final JsonGenerator json, boolean isFullRepresentation)
       throws IOException, SerializerException {
     json.writeStartObject();
     if (entity.getId() != null && url != null) {
@@ -248,7 +249,7 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
     }
     json.writeStringField(Constants.AT + Constants.ATOM_ATTR_ID, getEntityId(entity, entityType, name));
     writeProperties(metadata, entityType, entity.getProperties(), select, json);
-    writeNavigationProperties(metadata, entityType, entity, expand, name, json);
+    writeNavigationProperties(metadata, entityType, entity, expand, name, json, isFullRepresentation);
     json.writeEndObject();
 
   }
@@ -503,7 +504,8 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
 
   protected void writeNavigationProperties(final ServiceMetadata metadata,
       final EdmStructuredType type, final Linked linked, final ExpandOption expand,
-      final String name, final JsonGenerator json) throws SerializerException, IOException {
+      final String name, final JsonGenerator json, boolean isFullRepresentation) 
+          throws SerializerException, IOException {
     if (ExpandSelectHelper.hasExpand(expand)) {
       final boolean expandAll = ExpandSelectHelper.getExpandAll(expand) != null;
       final Set<String> expanded = expandAll ? new HashSet<String>() : ExpandSelectHelper.getExpandedPropertyNames(
@@ -525,7 +527,15 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
                 innerOptions == null ? null : innerOptions.getCountOption(),
                 innerOptions == null ? false : innerOptions.hasCountPath(),
                 innerOptions == null ? false : innerOptions.isRef(),
-                name, json);
+                name, json, isFullRepresentation);
+          } else {
+            json.writeFieldName(property.getName());
+            if (property.isCollection()) {
+              json.writeStartArray();
+              json.writeEndArray();
+            } else {
+              json.writeNull();
+            }
           }
         }
       }
@@ -534,24 +544,28 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
 
   protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
       final AbstractEntityCollection entitySet, final ExpandOption expand, final SelectOption select,
-      final boolean onlyReference, String name, final JsonGenerator json) throws IOException,
-      SerializerException {
-    json.writeStartArray();
-    for (final Entity entity : entitySet) {
-      if (onlyReference) {
-        json.writeStartObject();
-        json.writeStringField(Constants.JSON_ID, getEntityId(entity, entityType, null));
-        json.writeEndObject();
-      } else {
-        if (entity instanceof DeletedEntity) {
-          writeDeletedEntity(entity, json);
+      final boolean onlyReference, String name, final JsonGenerator json, 
+      boolean isFullRepresentation) throws IOException, SerializerException {
+    if (entitySet instanceof AbstractEntityCollection) {
+      AbstractEntityCollection entities = (AbstractEntityCollection)entitySet;
+      json.writeStartArray();
+      for (final Entity entity : entities) {
+        if (onlyReference) {
+          json.writeStartObject();
+          json.writeStringField(Constants.JSON_ID, getEntityId(entity, entityType, null));
+          json.writeEndObject();
         } else {
-          writeAddedUpdatedEntity(metadata, entityType, entity, expand, select, null, false, name, json);
+          if (entity instanceof DeletedEntity) {
+            writeDeletedEntity(entity, json);
+          } else {
+            writeAddedUpdatedEntity(metadata, entityType, entity, expand, select, null, false, 
+                name, json, isFullRepresentation);
+          }
+  
         }
-
       }
+      json.writeEndArray();
     }
-    json.writeEndArray();
   }
 
   protected void writeExpandedNavigationProperty(
@@ -559,23 +573,37 @@ public class JsonDeltaSerializerWithNavigations implements EdmDeltaSerializer {
       final Link navigationLink, final ExpandOption innerExpand,
       final SelectOption innerSelect, final CountOption innerCount,
       final boolean writeOnlyCount, final boolean writeOnlyRef, final String name,
-      final JsonGenerator json) throws IOException, SerializerException {
+      final JsonGenerator json, boolean isFullRepresentation) throws IOException, SerializerException {
 
     if (property.isCollection()) {
-      if (navigationLink != null && navigationLink.getInlineEntitySet() != null) {
-        json.writeFieldName(property.getName() + Constants.AT + Constants.DELTAVALUE);
+      if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
+        json.writeFieldName(property.getName());
+        json.writeStartArray();
+        json.writeEndArray();
+      } else if (navigationLink != null && navigationLink.getInlineEntitySet() != null) {
+        if (isFullRepresentation) {
+          json.writeFieldName(property.getName());
+        } else {
+          json.writeFieldName(property.getName() + Constants.AT + Constants.DELTAVALUE);
+        }
         writeEntitySet(metadata, property.getType(), navigationLink.getInlineEntitySet(), innerExpand,
-            innerSelect, writeOnlyRef, name, json);
+            innerSelect, writeOnlyRef, name, json, isFullRepresentation);
       }
 
     } else {
-      json.writeFieldName(property.getName()+ Constants.AT + Constants.DELTAVALUE);
-      if (navigationLink != null && navigationLink.getInlineEntity() != null) {
+      if (isFullRepresentation) {
+        json.writeFieldName(property.getName());
+      } else {
+        json.writeFieldName(property.getName()+ Constants.AT + Constants.DELTAVALUE);
+      }
+      if (navigationLink == null || navigationLink.getInlineEntity() == null) {
+        json.writeNull();
+      } else if (navigationLink != null && navigationLink.getInlineEntity() != null) {
         if (navigationLink.getInlineEntity() instanceof DeletedEntity) {
           writeDeletedEntity(navigationLink.getInlineEntity(), json);
         } else {
           writeAddedUpdatedEntity(metadata, property.getType(), navigationLink.getInlineEntity(),
-              innerExpand, innerSelect, null, writeOnlyRef, name, json);
+              innerExpand, innerSelect, null, writeOnlyRef, name, json, isFullRepresentation);
         }
       }
     }
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index c5b62dc..3c188a0 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -1796,8 +1796,38 @@ public class DataCreator {
     setLinks(entityCollection.getEntities().get(0), "NavPropertyETAllPrimMany", targetEntities.get(1),
         targetEntities.get(2));
     setLink(entityCollection.getEntities().get(3), "NavPropertyETAllPrimOne", targetEntities.get(0));
+    setLinkForDelta(entityCollection.getEntities().get(1), "NavPropertyETAllPrimOne");
+    setLinksForDelta(entityCollection.getEntities().get(2), "NavPropertyETAllPrimMany");
   }
 
+  protected static void setLinkForDelta(final Entity entity, final String navigationPropertyName) {
+    Link link = entity.getNavigationLink(navigationPropertyName);
+    if (link == null) {
+      link = new Link();
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
+      link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
+      link.setTitle(navigationPropertyName);
+      link.setHref(null);
+      entity.getNavigationLinks().add(link);
+    }
+    link.setInlineEntity(null);
+  }
+  
+  protected static void setLinksForDelta(final Entity entity, final String navigationPropertyName) {
+    Link link = entity.getNavigationLink(navigationPropertyName);
+    if (link == null) {
+      link = new Link();
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
+      link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
+      link.setTitle(navigationPropertyName);
+      link.setInlineEntitySet(null);
+      link.setHref(entity.getId().toASCIIString() + "/" + navigationPropertyName);
+      entity.getNavigationLinks().add(link);
+    } else {
+      link.getInlineEntitySet().getEntities().addAll(null);
+    }
+  }
+  
   private void linkESPeople(final Map<String, EntityCollection> data) {
       final EntityCollection entityCollection = data.get("ESPeople");
       final List<Entity> targetEntities = data.get("ESPeople").getEntities();
@@ -2096,7 +2126,7 @@ public class DataCreator {
       link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
       link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
       link.setTitle(navigationPropertyName);
-      link.setHref(target.getId().toASCIIString());
+      link.setHref(target.getId() != null ? target.getId().toASCIIString() : null);
       entity.getNavigationLinks().add(link);
     }
     link.setInlineEntity(target);
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigationsTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigationsTest.java
index c09caf9..7bfd202 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigationsTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/JsonDeltaSerializerWithNavigationsTest.java
@@ -60,6 +60,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+@SuppressWarnings("deprecation")
 public class JsonDeltaSerializerWithNavigationsTest {
 
   EdmDeltaSerializer ser;
@@ -541,13 +542,58 @@ public class JsonDeltaSerializerWithNavigationsTest {
          + "\"PropertyDuration\":\"PT0S\",\"PropertyGuid\":"
          + "\"76543201-23ab-cdef-0123-456789cccddd\","
          + "\"PropertyTimeOfDay\":\"00:01:01\"}]},{\"@id\":\"ESDelta(-32768)\","
-         + "\"PropertyString\":\"Number:-32768\"}]"
+         + "\"PropertyString\":\"Number:-32768\",\"NavPropertyETAllPrimMany\":[]}]"
            + "}";
        Assert.assertNotNull(jsonString);
        Assert.assertEquals(expectedResult, jsonString);
      } 
   
   @Test
+  public void navigationInDeltaEntityInFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
+    final Entity entity2 = data.readAll(edmEntitySet).getEntities().get(1);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    Entity changedEntity = new Entity();
+    changedEntity.setId(entity2.getId());
+    changedEntity.addProperty(entity2.getProperty("PropertyString"));
+    addedEntity.add(entity);
+    addedEntity.add(changedEntity);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true).build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{"
+         + "\"@context\":\"$metadata#ESDelta/$delta\",\"value\":"
+         + "[{\"@id\":\"ESDelta(32767)\",\"PropertyInt16\":32767,\"PropertyString\":\"Number:32767\","
+         + "\"NavPropertyETAllPrimMany\":["
+         + "{\"@id\":\"ESAllPrim(-32768)\",\"PropertyInt16\":-32768,"
+         + "\"PropertyString\":\"Second Resource - negative values\","
+         + "\"PropertyBoolean\":false,\"PropertyByte\":0,\"PropertySByte\":-128,\"PropertyInt32\":-2147483648,"
+         + "\"PropertyInt64\":-9223372036854775808,\"PropertySingle\":-1.79E8,\"PropertyDouble\":-179000.0,"
+         + "\"PropertyDecimal\":-34,\"PropertyBinary\":\"ASNFZ4mrze8=\",\"PropertyDate\":\"2015-11-05\","
+         + "\"PropertyDateTimeOffset\":\"2005-12-03T07:17:08Z\",\"PropertyDuration\":\"PT9S\","
+         + "\"PropertyGuid\":\"76543201-23ab-cdef-0123-456789dddfff\",\"PropertyTimeOfDay\":\"23:49:14\"},"
+         + "{\"@id\":\"ESAllPrim(0)\",\"PropertyInt16\":0,\"PropertyString\":\"\","
+         + "\"PropertyBoolean\":false,\"PropertyByte\":0,\"PropertySByte\":0,\"PropertyInt32\":0,"
+         + "\"PropertyInt64\":0,\"PropertySingle\":0.0,\"PropertyDouble\":0.0,"
+         + "\"PropertyDecimal\":0,"
+         + "\"PropertyBinary\":\"\",\"PropertyDate\":\"1970-01-01\","
+         + "\"PropertyDateTimeOffset\":\"2005-12-03T00:00:00Z\","
+         + "\"PropertyDuration\":\"PT0S\",\"PropertyGuid\":"
+         + "\"76543201-23ab-cdef-0123-456789cccddd\","
+         + "\"PropertyTimeOfDay\":\"00:01:01\"}]},{\"@id\":\"ESDelta(-32768)\","
+         + "\"PropertyString\":\"Number:-32768\",\"NavPropertyETAllPrimMany\":[]}]}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     } 
+  
+  @Test
   public void navigationInDeltaEntityWithDeleted() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
     Delta delta = new Delta();
@@ -839,7 +885,8 @@ public class JsonDeltaSerializerWithNavigationsTest {
        String jsonString = IOUtils.toString(stream);
        final String expectedResult = "{"
            + "\"@context\":\"$metadata#ESDelta/$delta\",\"value\":[{\"@id\":\"ESDelta(32767)\","
-           + "\"PropertyInt16\":32767,\"PropertyString\":\"Number:32767\"},{\"@id\":\"ESDelta(100)\","
+           + "\"PropertyInt16\":32767,\"PropertyString\":\"Number:32767\",\"NavPropertyETAllPrimOne\":null},"
+           + "{\"@id\":\"ESDelta(100)\","
            + "\"PropertyInt16\":100,\"PropertyString\":\"Number:100\","
            + "\"NavPropertyETAllPrimOne@delta\":"
            + "{\"@id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,\"PropertyString\":"
@@ -854,6 +901,45 @@ public class JsonDeltaSerializerWithNavigationsTest {
        Assert.assertEquals(expectedResult, jsonString);
      } 
   
+  @Test
+  public void navigationEntityInDeltaEntityWithFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
+    final Entity entity2 = data.readAll(edmEntitySet).getEntities().get(3);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    Entity changedEntity = new Entity();
+    changedEntity.setId(entity.getId());
+    changedEntity.addProperty(entity.getProperty("PropertyString"));
+    addedEntity.add(entity);
+    addedEntity.add(entity2);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true)
+        .build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{"
+           + "\"@context\":\"$metadata#ESDelta/$delta\",\"value\":[{\"@id\":\"ESDelta(32767)\","
+           + "\"PropertyInt16\":32767,\"PropertyString\":\"Number:32767\",\"NavPropertyETAllPrimOne\":null},"
+           + "{\"@id\":\"ESDelta(100)\","
+           + "\"PropertyInt16\":100,\"PropertyString\":\"Number:100\","
+           + "\"NavPropertyETAllPrimOne\":"
+           + "{\"@id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,\"PropertyString\":"
+           + "\"First Resource - positive values\","
+           + "\"PropertyBoolean\":true,\"PropertyByte\":255,\"PropertySByte\":127,\"PropertyInt32\":2147483647,"
+           + "\"PropertyInt64\":9223372036854775807,\"PropertySingle\":1.79E20,\"PropertyDouble\":-1.79E19,"
+           + "\"PropertyDecimal\":34,\"PropertyBinary\":\"ASNFZ4mrze8=\",\"PropertyDate\":\"2012-12-03\","
+           + "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\",\"PropertyDuration\":\"PT6S\",\"PropertyGuid\":"
+           + "\"01234567-89ab-cdef-0123-456789abcdef\",\"PropertyTimeOfDay\":\"03:26:05\"}}]"
+           + "}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     } 
+  
   @Test(expected = SerializerException.class)
   public void negativeDeltaEntityTest() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
@@ -1010,4 +1096,91 @@ public class JsonDeltaSerializerWithNavigationsTest {
        Assert.assertEquals(expectedResult, jsonString);
      } 
   
+  @Test
+  public void emptynavigationToManyInDeltaEntityInFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(2);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    addedEntity.add(entity);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true).build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{\"@context\":\"$metadata#ESDelta/$delta\","
+           + "\"value\":[{\"@id\":\"ESDelta(0)\",\"PropertyInt16\":0,"
+           + "\"PropertyString\":\"Number:0\",\"NavPropertyETAllPrimMany\":[]}]}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     }
+  
+  @Test
+  public void emptynavigationToOneInDeltaEntityInFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    addedEntity.add(entity);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true).build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{\"@context\":\"$metadata#ESDelta/$delta\","
+           + "\"value\":[{\"@id\":\"ESDelta(-32768)\",\"PropertyInt16\":-32768,"
+           + "\"PropertyString\":\"Number:-32768\",\"NavPropertyETAllPrimOne\":null}]}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     }
+  
+  @Test
+  public void nullnavigationToOneInDeltaEntityInFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(4);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    addedEntity.add(entity);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true).build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{\"@context\":\"$metadata#ESDelta/$delta\","
+           + "\"value\":[{\"@id\":\"ESDelta(-1)\",\"PropertyInt16\":-1,"
+           + "\"PropertyString\":\"Number:-1\",\"NavPropertyETAllPrimOne\":null}]}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     }
+  
+  @Test
+  public void nullnavigationToManyInDeltaEntityInFullRepresentation() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESDelta");
+    Delta delta = new Delta();
+    final Entity entity = data.readAll(edmEntitySet).getEntities().get(4);
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
+        ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany")));
+    List<Entity> addedEntity = new ArrayList<Entity>();
+    addedEntity.add(entity);
+    delta.getEntities().addAll(addedEntity);
+     InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
+        EntityCollectionSerializerOptions.with()
+        .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).expand(expand)
+        .isFullRepresentation(true).build()).getContent();
+       String jsonString = IOUtils.toString(stream);
+       final String expectedResult = "{\"@context\":\"$metadata#ESDelta/$delta\","
+           + "\"value\":[{\"@id\":\"ESDelta(-1)\",\"PropertyInt16\":-1,"
+           + "\"PropertyString\":\"Number:-1\",\"NavPropertyETAllPrimMany\":[]}]}";
+       Assert.assertNotNull(jsonString);
+       Assert.assertEquals(expectedResult, jsonString);
+     }
 }