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/10/05 08:01:58 UTC

[01/11] olingo-odata4 git commit: [OLINGO-782] Functions with key predicates get validated

Repository: olingo-odata4
Updated Branches:
  refs/heads/olingo786 3ec5a161e -> 507236dd8


[OLINGO-782] Functions with key predicates get validated


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

Branch: refs/heads/olingo786
Commit: 64388ecf2bda2d4ed0854cc0addc8d2d65c62475
Parents: c66b659
Author: Christia Holzer <c....@sap.com>
Authored: Tue Sep 29 15:34:47 2015 +0200
Committer: Christia Holzer <c....@sap.com>
Committed: Wed Sep 30 15:04:22 2015 +0200

----------------------------------------------------------------------
 .../core/uri/parser/UriParseTreeVisitor.java    | 280 +++++++++++--------
 .../server/core/uri/validator/UriValidator.java |  23 +-
 .../server/core/PreconditionsValidatorTest.java |   2 +-
 .../core/uri/antlr/TestFullResourcePath.java    | 127 ++++++++-
 4 files changed, 305 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/64388ecf/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index bedfaf2..edd6058 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -40,16 +40,19 @@ import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmReturnType;
 import org.apache.olingo.commons.api.edm.EdmSingleton;
 import org.apache.olingo.commons.api.edm.EdmStructuredType;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.ex.ODataRuntimeException;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriInfoResource;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceFunction;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 import org.apache.olingo.server.api.uri.UriResourceRoot;
@@ -77,7 +80,9 @@ import org.apache.olingo.server.core.uri.UriResourceStartingTypeFilterImpl;
 import org.apache.olingo.server.core.uri.UriResourceTypedImpl;
 import org.apache.olingo.server.core.uri.UriResourceValueImpl;
 import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
-import org.apache.olingo.server.core.uri.antlr.*;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+import org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor;
+import org.apache.olingo.server.core.uri.antlr.UriParserParser;
 import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllEOFContext;
 import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllExprContext;
 import org.apache.olingo.server.core.uri.antlr.UriParserParser.AltAddContext;
@@ -1564,6 +1569,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
   @Override
   public Object visitNameValueOptList(final NameValueOptListContext ctx) {
     if (ctx.vVO != null) {
+      // This branch is chosen if the key predicate is a common expression e.g. EntitySet(0)
 
       // is single key predicate without a name
       String valueText = ctx.vVO.getText();
@@ -1580,67 +1586,98 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       if (!(last instanceof UriResourcePartTyped)) {
         throw wrap(new UriParserSemanticException("Parameters list on untyped resource path segment not allowed",
             UriParserSemanticException.MessageKeys.PARAMETERS_LIST_ONLY_FOR_TYPED_PARTS));
-      }
-      EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
-
-      // get list of keys for lastType
-      List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
-
-      // If there is exactly one key defined in the EDM, then this key is the key written in the URI,
-      // so fill the keylist with this key and return.
-      if (lastKeyPredicates.size() == 1) {
-        return Collections.singletonList(new UriParameterImpl()
-            .setName(lastKeyPredicates.get(0))
-            .setText(valueText)
-            .setExpression(expression));
-      }
 
-      // There are more keys defined in the EDM, but only one is written in the URI. This is allowed only if
-      // referential constraints are defined on this navigation property which can be used to fill up all
-      // required keys.
-      // For using referential constraints the last resource part must be a navigation property.
-      if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
-        throw wrap(new UriParserSemanticException("Wrong number of key properties.",
-            UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
-            Integer.toString(lastKeyPredicates.size()), "1"));
-      }
-      UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
+      } else if (last instanceof UriResourceFunction) {
+        // Handle functions
+        final UriResourceFunction uriResourceFunction =
+            (UriResourceFunction) context.contextUriInfo.getLastResourcePart();
+        final EdmReturnType returnType = uriResourceFunction.getFunction().getReturnType();
 
-      // get the partner of the navigation property
-      EdmNavigationProperty partner = lastNav.getProperty().getPartner();
-      if (partner == null) {
-        throw wrap(new UriParserSemanticException("Wrong number of key properties.",
-            UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
-            Integer.toString(lastKeyPredicates.size()), "1"));
-      }
+        if (returnType.getType().getKind() != EdmTypeKind.ENTITY || !returnType.isCollection()) {
+          throw wrap(new UriParserSemanticException("No keys allowed",
+              UriParserSemanticException.MessageKeys.KEY_NOT_ALLOWED));
+        } else {
+          // The functions returns a collection of entities
+          // Get the EDM Type and determine how many key predicates are needed. In this case only one 
+          // key predicate is allowed. If the entity type needs more than one key predicate, the client
+          // has to use the key value syntax e.g. EntitySet(ID=1,Order=2)
+          final EdmEntityType entityType = (EdmEntityType) uriResourceFunction.getFunction().getReturnType().getType();
+          final List<String> lastKeyPredicates = entityType.getKeyPredicateNames();
+
+          if (lastKeyPredicates.size() == 1) {
+            return Collections.singletonList(new UriParameterImpl()
+                .setName(lastKeyPredicates.get(0))
+                .setText(valueText)
+                .setExpression(expression));
+          } else {
+            throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+                UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+                Integer.toString(lastKeyPredicates.size()), "1"));
+          }
+        }
+      } else {
+        // Handle EntitySets
+        EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
+
+        // get list of keys for lastType
+        List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
+
+        // If there is exactly one key defined in the EDM, then this key is the key written in the URI,
+        // so fill the keylist with this key and return.
+        if (lastKeyPredicates.size() == 1) {
+          return Collections.singletonList(new UriParameterImpl()
+              .setName(lastKeyPredicates.get(0))
+              .setText(valueText)
+              .setExpression(expression));
+        }
 
-      // create the keylist
-      List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
+        // There are more keys defined in the EDM, but only one is written in the URI. This is allowed only if
+        // referential constraints are defined on this navigation property which can be used to fill up all
+        // required keys.
+        // For using referential constraints the last resource part must be a navigation property.
+        if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
+          throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+              UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+              Integer.toString(lastKeyPredicates.size()), "1"));
+        }
+        UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
+
+        // get the partner of the navigation property
+        EdmNavigationProperty partner = lastNav.getProperty().getPartner();
+        if (partner == null) {
+          throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+              UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+              Integer.toString(lastKeyPredicates.size()), "1"));
+        }
 
-      // Find the keys not filled by referential constraints
-      // and collect the other keys filled by referential constraints.
-      String missedKey = null;
-      for (String item : lastKeyPredicates) {
-        String property = partner.getReferencingPropertyName(item);
-        if (property != null) {
-          list.add(new UriParameterImpl().setName(item).setRefencedProperty(property));
-        } else {
-          if (missedKey == null) {
-            missedKey = item;
+        // create the keylist
+        List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
+
+        // Find the keys not filled by referential constraints
+        // and collect the other keys filled by referential constraints.
+        String missedKey = null;
+        for (String item : lastKeyPredicates) {
+          String property = partner.getReferencingPropertyName(item);
+          if (property != null) {
+            list.add(new UriParameterImpl().setName(item).setRefencedProperty(property));
           } else {
-            // two of more keys are missing
-            throw wrap(new UriParserSemanticException("Not enough referential constraints defined",
-                UriParserSemanticException.MessageKeys.NOT_ENOUGH_REFERENTIAL_CONSTRAINTS));
+            if (missedKey == null) {
+              missedKey = item;
+            } else {
+              // two of more keys are missing
+              throw wrap(new UriParserSemanticException("Not enough referential constraints defined",
+                  UriParserSemanticException.MessageKeys.NOT_ENOUGH_REFERENTIAL_CONSTRAINTS));
+            }
           }
         }
-      }
 
-      // the missing key is the one which is defined in the URI
-      list.add(new UriParameterImpl().setName(missedKey).setText(valueText).setExpression(expression));
+        // the missing key is the one which is defined in the URI
+        list.add(new UriParameterImpl().setName(missedKey).setText(valueText).setExpression(expression));
 
-      return list;
+        return list;
+      }
     } else if (ctx.vNVL != null) {
-
+      // The client provided a list of key values pairs e.g. EntitySet(ID=1,Order=2)
       List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
 
       for (ParseTree c : ctx.vNVL.vlNVP) {
@@ -1652,83 +1689,102 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       }
 
       UriResource last = context.contextUriInfo.getLastResourcePart();
-      // if the last resource part is a function
-      /*
-       * if (last instanceof UriResourceFunctionImpl) {
-       * UriResourceFunctionImpl function = (UriResourceFunctionImpl) last;
-       * if (!function.isParameterListFilled()) {
-       * return list;
-       * }
-       * }
-       */
 
       // get type of last resource part
       if (!(last instanceof UriResourcePartTyped)) {
         throw wrap(new UriParserSemanticException("Parameters list on untyped resource path segment not allowed",
             UriParserSemanticException.MessageKeys.PARAMETERS_LIST_ONLY_FOR_TYPED_PARTS));
       }
-      EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
-
-      // get list of keys for lastType
-      List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
-
-      // check if all key are filled from the URI
-      if (list.size() == lastKeyPredicates.size()) {
-        return list;
-      }
+      if(last instanceof UriResourceFunction) {
+        final UriResourceFunction uriResourceFunction = (UriResourceFunction) context.contextUriInfo
+            .getLastResourcePart();
+        final EdmReturnType returnType = uriResourceFunction.getFunction().getReturnType();
 
-      // if not, check if the missing key predicates can be satisfied with help of the defined
-      // referential constraints
-      // for using referential constraints the last resource part must be a navigation property
-      if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
-        throw wrap(new UriParserSemanticException("Wrong number of key properties.",
-            UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
-            Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
-      }
-      UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
-
-      // get the partner of the navigation property
-      EdmNavigationProperty partner = lastNav.getProperty().getPartner();
-      if (partner == null) {
-        throw wrap(new UriParserSemanticException("Wrong number of key properties.",
-            UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
-            Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
-      }
-
-      // fill missing keys from referential constraints
-      for (String key : lastKeyPredicates) {
-        boolean found = false;
-        for (UriParameterImpl item : list) {
-          if (item.getName().equals(key)) {
-            found = true;
-            break;
+        if (returnType.getType().getKind() != EdmTypeKind.ENTITY || !returnType.isCollection()) {
+          throw wrap(new UriParserSemanticException("No keys allowed",
+              UriParserSemanticException.MessageKeys.KEY_NOT_ALLOWED));
+        } else {
+          // The functions returns a collection of entities
+          // Get the EDM Type and determine how many key predicates are needed. 
+          // In case of functions all key predicates must be provided by the client.
+          final EdmEntityType entityType = (EdmEntityType) uriResourceFunction.getFunction().getReturnType().getType();
+          final List<String> lastKeyPredicates = entityType.getKeyPredicateNames();
+          
+          if(lastKeyPredicates.size() == list.size()) {
+            return list;
+          } else {
+            throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+                UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+                Integer.toString(lastKeyPredicates.size()), "1"));
           }
         }
-
-        if (!found) {
-          String property = partner.getReferencingPropertyName(key);
-          if (property != null) {
-            // store the key name as referenced property
-            list.add(0, new UriParameterImpl().setName(key).setRefencedProperty(property));
+      } else {
+        // Handle entity sets
+        EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
+  
+        // get list of keys for lastType
+        List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
+  
+        // check if all key are filled from the URI
+        if (list.size() == lastKeyPredicates.size()) {
+          return list;
+        }
+  
+        // if not, check if the missing key predicates can be satisfied with help of the defined
+        // referential constraints
+        // for using referential constraints the last resource part must be a navigation property
+        if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
+          throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+              UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+              Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
+        }
+        UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
+  
+        // get the partner of the navigation property
+        EdmNavigationProperty partner = lastNav.getProperty().getPartner();
+        if (partner == null) {
+          throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+              UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+              Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
+        }
+  
+        // fill missing keys from referential constraints
+        for (String key : lastKeyPredicates) {
+          boolean found = false;
+          for (UriParameterImpl item : list) {
+            if (item.getName().equals(key)) {
+              found = true;
+              break;
+            }
+          }
+  
+          if (!found) {
+            String property = partner.getReferencingPropertyName(key);
+            if (property != null) {
+              // store the key name as referenced property
+              list.add(0, new UriParameterImpl().setName(key).setRefencedProperty(property));
+            }
           }
         }
-      }
-
-      // check again if all key predicates are filled from the URI
-      if (list.size() == lastKeyPredicates.size()) {
-        return list;
-      } else {
-        throw wrap(new UriParserSemanticException("Wrong number of key properties.",
-            UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
-            Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
+  
+        // check again if all key predicates are filled from the URI
+        if (list.size() == lastKeyPredicates.size()) {
+          return list;
+        } else {
+          throw wrap(new UriParserSemanticException("Wrong number of key properties.",
+              UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES,
+              Integer.toString(lastKeyPredicates.size()), Integer.toString(list.size())));
+        }
       }
     } else {
+      // No key predicates are provided by the client
+      
       if (context.contextReadingFunctionParameters) {
         return Collections.emptyList();
       } else {
         final UriResource last = context.contextUriInfo.getLastResourcePart();
-        final int number = last instanceof UriResourcePartTyped ?
-            ((EdmEntityType) ((UriResourcePartTyped) last).getType()).getKeyPredicateNames().size() : 0;
+        final int number = last instanceof UriResourcePartTyped ? ((EdmEntityType) ((UriResourcePartTyped) last)
+            .getType()).getKeyPredicateNames().size() : 0;
         throw wrap(new UriParserSemanticException("Wrong number of key properties.",
             UriParserSemanticException.MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES, Integer.toString(number), "0"));
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/64388ecf/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
index d793b5c..8693f1e 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
@@ -527,16 +527,20 @@ public class UriValidator {
   private void validateKeyPredicates(final UriInfo uriInfo) throws UriValidationException {
     for (UriResource pathSegment : uriInfo.getUriResourceParts()) {
       final boolean isEntitySet = pathSegment.getKind() == UriResourceKind.entitySet;
-      if (isEntitySet || pathSegment.getKind() == UriResourceKind.navigationProperty) {
+      final boolean isEntityColFunction = isEntityColFunction(pathSegment);
+      
+      if (isEntitySet || pathSegment.getKind() == UriResourceKind.navigationProperty || isEntityColFunction) {
         final List<UriParameter> keyPredicates = isEntitySet ?
             ((UriResourceEntitySet) pathSegment).getKeyPredicates() :
-            ((UriResourceNavigation) pathSegment).getKeyPredicates();
-
+              isEntityColFunction ? ((UriResourceFunction) pathSegment).getKeyPredicates()
+              : ((UriResourceNavigation) pathSegment).getKeyPredicates();
+            
         if (keyPredicates != null) {
 
           final EdmEntityType entityType = isEntitySet ?
               ((UriResourceEntitySet) pathSegment).getEntityType() :
-              (EdmEntityType) ((UriResourceNavigation) pathSegment).getType();
+              isEntityColFunction ? (EdmEntityType) ((UriResourceFunction) pathSegment).getType() 
+              : (EdmEntityType) ((UriResourceNavigation) pathSegment).getType();
           final List<String> keyPredicateNames = entityType.getKeyPredicateNames();
           Map<String, EdmKeyPropertyRef> edmKeys = new HashMap<String, EdmKeyPropertyRef>();
           for (EdmKeyPropertyRef key : entityType.getKeyPropertyRefs()) {
@@ -590,6 +594,17 @@ public class UriValidator {
     }
   }
 
+  private boolean isEntityColFunction(final UriResource pathSegment) {
+    if(pathSegment.getKind() == UriResourceKind.function) {
+      final UriResourceFunction resourceFunction = (UriResourceFunction) pathSegment;
+      final EdmReturnType returnType = resourceFunction.getFunction().getReturnType();
+      
+      return returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY;
+    } else {
+      return false;
+    }
+  }
+  
   private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
       throws UriValidationException {
     final List<UriResource> parts = uriInfo.getUriResourceParts();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/64388ecf/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
index e2fe3ac..cf56edf 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/PreconditionsValidatorTest.java
@@ -96,7 +96,7 @@ public class PreconditionsValidatorTest {
 
   @Test
   public void navigationOnFunction() throws Exception {
-    assertTrue(mustValidate("FICRTESTwoKeyNav()(PropertyInt16=1,PropertyString='1')/NavPropertySINav", "SINav"));
+    assertTrue(mustValidate("FICRTESTwoKeyNav()/NavPropertySINav", "SINav"));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/64388ecf/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 4cd015a..9c859db 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1033,6 +1033,118 @@ public class TestFullResourcePath {
   }
   
   @Test
+  public void runFunctionsWithKeyPredicates() throws Exception {
+    testUri.run("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollETMixPrimCollCompTwoParam")
+      .isFunction("UFCRTCollETMixPrimCollCompTwoParam")
+      .isParameter(0, "ParameterString", "'1'")
+      .isParameter(1, "ParameterInt16", "1");
+    
+    testUri.run("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt16=0)")
+     .isKind(UriInfoKind.resource)
+     .goPath().first()
+     .isFunctionImport("FICRTCollETMixPrimCollCompTwoParam")
+     .isFunction("UFCRTCollETMixPrimCollCompTwoParam")
+     .isParameter(0, "ParameterString", "'1'")
+     .isParameter(1, "ParameterInt16", "1")
+     .isKeyPredicate(0, "PropertyInt16", "0");
+    
+    testUri.run("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)(0)")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollETMixPrimCollCompTwoParam")
+      .isFunction("UFCRTCollETMixPrimCollCompTwoParam")
+      .isParameter(0, "ParameterString", "'1'")
+      .isParameter(1, "ParameterInt16", "1")
+      .isKeyPredicate(0, "PropertyInt16", "0");
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt16 eq 0)")
+      .isExSemantic(MessageKeys.INVALID_KEY_VALUE);
+    
+    // PropertyInt32 does not exist
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt32=0)")
+      .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterString='1',ParameterInt16=1)" 
+        + "(PropertyInt16=0,PropertyInt16=1)")
+    .isExSemantic(MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES);
+  
+    testUri.run("FICRTCollCTTwoPrimTwoParam(ParameterString='1',ParameterInt16=1)")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollCTTwoPrimTwoParam")
+      .isFunction("UFCRTCollCTTwoPrimTwoParam")
+      .isParameter(0, "ParameterString", "'1'")
+      .isParameter(1, "ParameterInt16", "1");
+    
+    testUri.runEx("FICRTCollCTTwoPrimTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt16=1)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollCTTwoPrimTwoParam(ParameterString='1',ParameterInt16=1)(1)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollCTTwoPrimTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt32=1)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollCTTwoPrimTwoParam(ParameterString='1',ParameterInt16=1)(PropertyInt32=1,PropertyInt16=2)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+    
+    testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollESTwoKeyNavParam")
+      .isFunction("UFCRTCollETTwoKeyNavParam")
+      .isParameter(0, "ParameterInt16", "1");
+    
+    testUri.run("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='1')")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollESTwoKeyNavParam")
+      .isFunction("UFCRTCollETTwoKeyNavParam")
+      .isParameter(0, "ParameterInt16", "1")
+      .isKeyPredicate(0, "PropertyInt16", "1")
+      .isKeyPredicate(1,"PropertyString", "'1'");
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16 eq 1)")
+      .isExSemantic(MessageKeys.INVALID_KEY_VALUE);
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1)")
+      .isExSemantic(MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES);
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyInt32=1,PropertyString='1')")
+      .isExSemantic(MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES);
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)()")
+      .isExSemantic(MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES);
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyInt32=1)")
+      .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+    
+    testUri.runEx("FICRTCollESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,Unkown=1)")
+    .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+    
+    testUri.run("FICRTCollString()")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollString")
+      .isFunction("UFCRTCollString");
+    
+    testUri.run("FICRTString()")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTString")
+      .isFunction("UFCRTString");
+    
+    testUri.runEx("FICRTCollString()(0)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTString()(0)")
+      .isExSemantic(MessageKeys.KEY_NOT_ALLOWED);
+  }
+  
+  @Test
   public void runEsNameCast() throws Exception {
     testUri.run("ESTwoPrim/olingo.odata.test1.ETBase")
     .isKind(UriInfoKind.resource).goPath()
@@ -1759,14 +1871,12 @@ public class TestFullResourcePath {
     .isFunctionImport("FICRTETKeyNav")
     .isFunction("UFCRTETKeyNav")
     .isType(EntityTypeProvider.nameETKeyNav);
-
-    testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')")
+    
+    testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)")
     .isKind(UriInfoKind.resource).goPath()
     .first()
     .isFunctionImport("FICRTETTwoKeyNavParam")
-    .isParameter(0, "ParameterInt16", "1")
-    .isKeyPredicate(0, "PropertyInt16", "2")
-    .isKeyPredicate(1, "PropertyString", "'3'");
+    .isParameter(0, "ParameterInt16", "1");
 
     testUri.run("FICRTESMedia(ParameterInt16=1)/$value")
     .isKind(UriInfoKind.resource).goPath()
@@ -1799,16 +1909,13 @@ public class TestFullResourcePath {
     .isParameter(0, "ParameterInt16", "1")
     .isType(EntityTypeProvider.nameETTwoKeyNav)
     .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
-
-    testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')"
-            + "/olingo.odata.test1.ETBaseTwoKeyNav")
+    
+    testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/olingo.odata.test1.ETBaseTwoKeyNav")
         .isKind(UriInfoKind.resource).goPath()
         .first()
         .isFunctionImport("FICRTETTwoKeyNavParam")
         .isFunction("UFCRTETTwoKeyNavParam")
         .isParameter(0, "ParameterInt16", "1")
-        .isKeyPredicate(0, "PropertyInt16", "2")
-        .isKeyPredicate(1, "PropertyString", "'3'")
         .isType(EntityTypeProvider.nameETTwoKeyNav)
         .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
 


[02/11] olingo-odata4 git commit: [OLINGO-781] TecSvc: The atom id for functions without entity set is calculated by the URI of the function

Posted by mi...@apache.org.
[OLINGO-781] TecSvc: The atom id for functions without entity set is
calculated by the URI of the function


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

Branch: refs/heads/olingo786
Commit: b7dcae862ae226b1f2da43270418e14199af1a06
Parents: 64388ec
Author: Christia Holzer <c....@sap.com>
Authored: Tue Sep 29 15:44:10 2015 +0200
Committer: Christia Holzer <c....@sap.com>
Committed: Wed Sep 30 15:04:23 2015 +0200

----------------------------------------------------------------------
 .../server/tecsvc/processor/TechnicalEntityProcessor.java   | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b7dcae86/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 59d9a2a..b9afddd 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -506,8 +506,15 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
         expand);
     expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
     final CountOption countOption = uriInfo.getCountOption();
+    
+    String id;
+    if(edmEntitySet == null) {
+      // Used for functions, function imports etc.
+      id = request.getRawODataPath();
+    } else {
+      id = request.getRawBaseUri() + edmEntitySet.getName();
+    }
 
-    final String id = request.getRawBaseUri() + edmEntitySet.getName();
     // Serialize
     final SerializerResult serializerResult = (isReference) ?
         serializeReferenceCollection(entitySetSerialization, edmEntitySet, requestedContentType, countOption) :


[04/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
index a533820..f50cbc9 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
@@ -19,58 +19,56 @@
 package org.apache.olingo.server.core.deserializer.xml;
 
 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;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Parameter;
-import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmParameter;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlAction;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.core.edm.EdmActionImpl;
-import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.junit.Test;
-import org.mockito.Mockito;
 
-public class ODataXMLDeserializerActionParametersTest {
+public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeserializerTest {
+
+  private static final String PREAMBLE = "<?xml version='1.0' encoding='UTF-8'?>"
+      + "<metadata:parameters xmlns:data=\"" + Constants.NS_DATASERVICES + "\""
+      + " xmlns:metadata=\"" + Constants.NS_METADATA + "\">";
+  private static final String POSTAMBLE = "</metadata:parameters>";
 
   @Test
   public void empty() throws Exception {
-    final String input = "";
-    final Map<String, Parameter> parameters = deserialize(input, "UART");
+    final Map<String, Parameter> parameters = deserialize(PREAMBLE + POSTAMBLE, "UART", null);
     assertNotNull(parameters);
     assertTrue(parameters.isEmpty());
   }
 
   @Test
   public void primitive() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterInt16>42</ParameterInt16>"
-        +"<ParameterDuration>P42DT11H22M33S</ParameterDuration>"
-        +"</metadata:parameters>";
-    
-    final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam");
+    final String input = PREAMBLE
+        + "<ParameterDuration>P42DT11H22M33S</ParameterDuration>"
+        + "<ParameterInt16>42</ParameterInt16>"
+        + POSTAMBLE;
+
+    final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam", null);
     assertNotNull(parameters);
     assertEquals(2, parameters.size());
     Parameter parameter = parameters.get("ParameterInt16");
@@ -80,158 +78,115 @@ public class ODataXMLDeserializerActionParametersTest {
     assertNotNull(parameter);
     assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
   }
-  
+
+  @Test
+  public void primitiveCollection() throws Exception {
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(
+        OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration));
+    when(parameter.isCollection()).thenReturn(true);
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = PREAMBLE
+        + "<Parameter>"
+        + "<metadata:element>PT0S</metadata:element>"
+        + "<metadata:element>PT42S</metadata:element>"
+        + "<metadata:element>PT1H2M3S</metadata:element>"
+        + "</Parameter>"
+        + POSTAMBLE;
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isPrimitive());
+    assertTrue(parameterData.isCollection());
+    assertEquals(BigDecimal.ZERO, parameterData.asCollection().get(0));
+    assertEquals(BigDecimal.valueOf(42), parameterData.asCollection().get(1));
+    assertEquals(BigDecimal.valueOf(3723), parameterData.asCollection().get(2));
+  }
+
   @Test
   public void complex() throws Exception {
-    EdmProviderImpl provider = mock(EdmProviderImpl.class);
-    CsdlComplexType address = new CsdlComplexType();
-    address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"), 
-        createProperty("Zip", "Edm.Int32")));
-    address.setName("Address");
-    EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider, 
-        new FullQualifiedName("namespace.Address"), address);    
-    Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-    
-    List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
-    parameters.add(createParam("param1", "Edm.Int16"));
-    parameters.add(createParam("param2", "namespace.Address"));
-    parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
-    parameters.add(createParam("param4", "Edm.String").setNullable(true));
-    
-    FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
-    CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
-    EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-    
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>" + 
-        "<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">\n" + 
-        "  <param1>42</param1>\n" + 
-        "  <param2 metadata:type=\"#namespace.Address\">\n" + 
-        "    <Street>One Microsoft Way</Street>\n" + 
-        "    <Zip>98052</Zip>\n" + 
-        "  </param2>\n" + 
-        "  <param3>\n" + 
-        "    <element>1</element>\n" + 
-        "    <element>42</element>\n" + 
-        "    <element>99</element>\n" + 
-        "  </param3>\n" + 
-        "  <param4 metadata:null=\"true\"/>\n" + 
-        "</metadata:parameters>";
-    final Map<String, Parameter> response = OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-    
-    assertNotNull(response);
-    assertEquals(4, response.size());
-    Parameter parameter = response.get("param1");
-    assertNotNull(response);
-    assertEquals((short) 42, parameter.getValue());
-    parameter = response.get("param2");
-    assertNotNull(parameter);
-    ComplexValue addressValue = (ComplexValue)parameter.getValue();
-    assertEquals("Street", addressValue.getValue().get(0).getName());
-    assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals("Zip", addressValue.getValue().get(1).getName());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
-    
-    parameter = response.get("param3");
-    assertNotNull(parameter);
-    assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-    
-    parameter = response.get("param4");
-    assertNull(parameter.getValue());
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = PREAMBLE
+        + "<Parameter>"
+        + "<PropertyInt16>42</PropertyInt16>"
+        + "<PropertyString>Yes</PropertyString>"
+        + "</Parameter>"
+        + POSTAMBLE;
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    final Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isComplex());
+    assertFalse(parameterData.isCollection());
+    final List<Property> complexValues = parameterData.asComplex().getValue();
+    assertEquals((short) 42, complexValues.get(0).getValue());
+    assertEquals("Yes", complexValues.get(1).getValue());
   }
-  
+
   @Test
   public void complexCollection() throws Exception {
-    EdmProviderImpl provider = mock(EdmProviderImpl.class);
-    CsdlComplexType address = new CsdlComplexType();
-    address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"), 
-        createProperty("Zip", "Edm.Int32")));
-    address.setName("Address");
-    EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider, 
-        new FullQualifiedName("namespace.Address"), address);    
-    Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-    
-    List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
-    parameters.add(createParam("param1", "Edm.Int16"));
-    parameters.add(createParam("param2", "namespace.Address").setCollection(true));
-    parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
-    parameters.add(createParam("param4", "Edm.String").setNullable(true));
-    
-    FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
-    CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
-    EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-    
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>" + 
-        "<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">\n" + 
-        "  <param1>42</param1>\n" + 
-        "  <param2 metadata:type=\"#namespace.Address\">\n" +
-        "    <element>" +
-        "    <Street>One Microsoft Way</Street>\n" + 
-        "    <Zip>98052</Zip>\n" +
-        "    </element>" +
-        "    <element>" +
-        "    <Street>Two Microsoft Way</Street>\n" + 
-        "    <Zip>98052</Zip>\n" +
-        "    </element>" +        
-        "  </param2>\n" + 
-        "  <param3>\n" + 
-        "    <element>1</element>\n" + 
-        "    <element>42</element>\n" + 
-        "    <element>99</element>\n" + 
-        "  </param3>\n" + 
-        "  <param4 metadata:null=\"true\"/>\n" + 
-        "</metadata:parameters>";
-    final Map<String, Parameter> response = OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-    
-    assertNotNull(response);
-    assertEquals(4, response.size());
-    Parameter parameter = response.get("param1");
-    assertNotNull(response);
-    assertEquals((short) 42, parameter.getValue());
-    parameter = response.get("param2");
-    assertNotNull(parameter);
-    ComplexValue addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(0);
-    assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+    when(parameter.isCollection()).thenReturn(true);
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
 
-    addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(1);
-    assertEquals("Two Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
-    
-    parameter = response.get("param3");
-    assertNotNull(parameter);
-    assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-    
-    parameter = response.get("param4");
-    assertNull(parameter.getValue());
-  } 
+    final String input = PREAMBLE
+        + "<Parameter>"
+        + "<metadata:element>"
+        + "<PropertyInt16>9999</PropertyInt16><PropertyString>One</PropertyString>"
+        + "</metadata:element>"
+        + "<metadata:element>"
+        + "<PropertyInt16>-123</PropertyInt16><PropertyString>Two</PropertyString>"
+        + "</metadata:element>"
+        + "</Parameter>"
+        + POSTAMBLE;
+    final Map<String, Parameter> parameters = deserialize(input, action);
 
-  private CsdlParameter createParam(String name, String type) {
-    return new CsdlParameter().setName(name).setType(new FullQualifiedName(type));
-  }  
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isComplex());
+    assertTrue(parameterData.isCollection());
+    ComplexValue complexValue = (ComplexValue) parameterData.asCollection().get(0);
+    assertEquals((short) 9999, complexValue.getValue().get(0).getValue());
+    assertEquals("One", complexValue.getValue().get(1).getValue());
 
-  private CsdlProperty createProperty(String name, String type) {
-    return new CsdlProperty().setName(name).setType(type);
+    complexValue = (ComplexValue) parameterData.asCollection().get(1);
+    assertEquals((short) -123, complexValue.getValue().get(0).getValue());
+    assertEquals("Two", complexValue.getValue().get(1).getValue());
   }
-  
+
   @Test
   public void boundEmpty() throws Exception {
-    final String input = "";
-    final Map<String, Parameter> parameters = deserialize(input, "BAETAllPrimRT", "ETAllPrim");
+    final Map<String, Parameter> parameters = deserialize(PREAMBLE + POSTAMBLE,
+        "BAETAllPrimRT", "ETAllPrim");
     assertNotNull(parameters);
     assertTrue(parameters.isEmpty());
   }
 
   @Test
-  public void testParameterWithNullLiteral() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterInt16>1</ParameterInt16>"
-        +"</metadata:parameters>";
-    
-    final Map<String, Parameter> parameters = deserialize(input, 
-        "UARTCollStringTwoParam");
+  public void parameterWithNullLiteral() throws Exception {
+    final String input = PREAMBLE
+        + "<ParameterInt16>1</ParameterInt16>"
+        + "<ParameterDuration metadata:null=\"true\" />"
+        + POSTAMBLE;
+    final Map<String, Parameter> parameters = deserialize(input, "UARTCollStringTwoParam", null);
     assertNotNull(parameters);
     assertEquals(2, parameters.size());
     Parameter parameter = parameters.get("ParameterInt16");
@@ -241,63 +196,62 @@ public class ODataXMLDeserializerActionParametersTest {
     assertNotNull(parameter);
     assertEquals(null, parameter.getValue());
   }
-  
+
   @Test
   public void bindingParameter() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterETAllPrim>1</ParameterETAllPrim>"
-        +"</metadata:parameters>";    
+    final String input = PREAMBLE + "<ParameterETAllPrim>1</ParameterETAllPrim>" + POSTAMBLE;
     deserialize(input, "BAETAllPrimRT", "ETAllPrim");
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongName() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterWrong>1</ParameterWrong>"
-        +"</metadata:parameters>";      
-    deserialize(input, "UARTParam");
+    expectException(PREAMBLE + "<ParameterWrong>1</ParameterWrong>" + POSTAMBLE,
+        "UARTParam", null, MessageKeys.UNKNOWN_CONTENT);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void nullNotNullable() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterInt16>null</ParameterInt16>"
-        +"</metadata:parameters>";     
-    deserialize(input, "UARTCTTwoPrimParam");
+    expectException(PREAMBLE + "<ParameterInt16>null</ParameterInt16>" + POSTAMBLE,
+        "UARTCTTwoPrimParam", null, MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void missingParameter() throws Exception {
-    deserialize("", "UARTCTTwoPrimParam");
+    expectException(PREAMBLE + POSTAMBLE, "UARTCTTwoPrimParam", null, MessageKeys.INVALID_NULL_PARAMETER);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void parameterTwice() throws Exception {
-    final String input = "<?xml version='1.0' encoding='UTF-8'?>"
-        +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"        
-        +"<ParameterInt16>1</ParameterInt16>"
-        +"<ParameterInt16>2</ParameterInt16>"
-        +"</metadata:parameters>";      
-    deserialize(input, "UARTParam");
+    expectException(PREAMBLE
+        + "<ParameterInt16>1</ParameterInt16>"
+        + "<ParameterInt16>2</ParameterInt16>"
+        + POSTAMBLE,
+        "UARTParam", null, MessageKeys.DUPLICATE_PROPERTY);
   }
-  
-  protected static final Edm edm = OData.newInstance().createServiceMetadata(
-      new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
-  
-  private Map<String, Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
+
+  private Map<String, Parameter> deserialize(final String input, final EdmAction action) throws DeserializerException {
     return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()),
-            edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName))).getActionParameters();
+        .actionParameters(new ByteArrayInputStream(input.getBytes()), action)
+        .getActionParameters();
   }
 
-  private Map<String, Parameter> deserialize(final String input, final String actionName, final String typeName)
+  private Map<String, Parameter> deserialize(final String input, final String actionName, final String bindingTypeName)
       throws DeserializerException {
-    return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()),
-            edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName),
-                new FullQualifiedName("Namespace1_Alias", typeName), false)).getActionParameters();
+    return deserialize(input,
+        bindingTypeName == null ?
+            edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
+            edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
+                new FullQualifiedName(NAMESPACE, bindingTypeName),
+                false));
+  }
+
+  private void expectException(final String input, final String actionName, final String bindingTypeName,
+      final DeserializerException.MessageKeys messageKey) {
+    try {
+      deserialize(input, actionName, bindingTypeName);
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
+      assertEquals(messageKey, e.getMessageKey());
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
index 497e8f5..71f4d35 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
@@ -19,10 +19,11 @@
 package org.apache.olingo.server.core.deserializer.xml;
 
 import java.io.ByteArrayInputStream;
+import java.math.BigDecimal;
 import java.net.URI;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
+import java.util.UUID;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
@@ -40,39 +41,22 @@ import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
 import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
 import org.apache.olingo.commons.core.edm.EdmPropertyImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmGuid;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
-import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.core.ServiceMetadataImpl;
-import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
-import org.apache.olingo.server.tecsvc.MetadataETagSupport;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-public class ODataXmlDeserializerTest {
-  
-  private static final ServiceMetadata metadata = new ServiceMetadataImpl(
-      new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("WmetadataETag"));
-  private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer();
-  private final ODataDeserializer serializer = new ODataXmlDeserializer();
-  
+public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
+
+  private static final EdmEntityContainer entityContainer = edm.getEntityContainer();
+  private final ODataDeserializer deserializer = new ODataXmlDeserializer();
+
   @BeforeClass
   public static void setup() {
     XMLUnit.setIgnoreComments(true);
@@ -81,64 +65,24 @@ public class ODataXmlDeserializerTest {
     XMLUnit.setNormalizeWhitespace(true);
     XMLUnit.setCompareUnmatched(false);
   }
-  
-  protected Object edmInt16(String value) throws EdmPrimitiveTypeException {
-    return EdmInt16.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmInt16.getInstance().getDefaultType()); 
-  }
-  protected Object edmInt32(String value) throws EdmPrimitiveTypeException {
-    return EdmInt32.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmInt32.getInstance().getDefaultType()); 
-  }
-  protected Object edmInt64(String value) throws EdmPrimitiveTypeException {
-    return EdmInt64.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmInt64.getInstance().getDefaultType()); 
-  }
-  protected Object edmSingle(String value) throws EdmPrimitiveTypeException {
-    return EdmSingle.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmSingle.getInstance().getDefaultType()); 
-  }
-  protected Object edmDouble(String value) throws EdmPrimitiveTypeException {
-    return EdmDouble.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmDouble.getInstance().getDefaultType()); 
-  }
-  protected Object edmSByte(String value) throws EdmPrimitiveTypeException {
-    return EdmSByte.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmSByte.getInstance().getDefaultType()); 
-  }
-  protected Object edmByte(String value) throws EdmPrimitiveTypeException {
-    return EdmByte.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmByte.getInstance().getDefaultType()); 
-  }  
-  protected Object edmDecimal(String value) throws EdmPrimitiveTypeException {
-    return EdmDecimal.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmDecimal.getInstance().getDefaultType()); 
-  }
-  protected Object edmBinary(String value) throws EdmPrimitiveTypeException {
-    return EdmBinary.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmBinary.getInstance().getDefaultType()); 
+
+  protected byte[] edmBinary(String value) throws EdmPrimitiveTypeException {
+    return EdmBinary.getInstance().valueOfString(value, true, null, null, null, true,
+        byte[].class);
   }
   protected Object edmDate(String value) throws EdmPrimitiveTypeException {
-    return EdmDate.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmDate.getInstance().getDefaultType()); 
+    return EdmDate.getInstance().valueOfString(value, true, null, null, null, true,
+        EdmDate.getInstance().getDefaultType());
   }
   protected Object edmDateTimeOffset(String value) throws EdmPrimitiveTypeException {
-    return EdmDateTimeOffset.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmDateTimeOffset.getInstance().getDefaultType()); 
-  }  
-  protected Object edmDuration(String value) throws EdmPrimitiveTypeException {
-    return EdmDuration.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmDuration.getInstance().getDefaultType()); 
-  }   
-  protected Object edmGUID(String value) throws EdmPrimitiveTypeException {
-    return EdmGuid.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmGuid.getInstance().getDefaultType()); 
+    return EdmDateTimeOffset.getInstance().valueOfString(value, true, null, null, null, true, 
+        EdmDateTimeOffset.getInstance().getDefaultType());
   }  
   protected Object edmTimeOfDay(String value) throws EdmPrimitiveTypeException {
-    return EdmTimeOfDay.getInstance().valueOfString(value, true, 10, 10, 10, true, 
-        EdmTimeOfDay.getInstance().getDefaultType()); 
+    return EdmTimeOfDay.getInstance().valueOfString(value, true, null, null, null, true, 
+        EdmTimeOfDay.getInstance().getDefaultType());
   }
-  
+
   @Test
   public void entitySimple() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
@@ -179,32 +123,31 @@ public class ODataXmlDeserializerTest {
         "  </atom:content>\n" + 
         "</atom:entry>\n"; 
     
-    Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+    Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
         edmEntitySet.getEntityType()).getEntity();
 
     Assert.assertEquals(16, result.getProperties().size());
     Assert.assertEquals(2, result.getNavigationBindings().size());
     
-    Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
     Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
-    Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
-    Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
-    Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
-    Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
-    Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
-    Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
-    Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
-//    Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
+    Assert.assertEquals((short) 255, result.getProperty("PropertyByte").asPrimitive());
+    Assert.assertEquals((byte) 127, result.getProperty("PropertySByte").asPrimitive());
+    Assert.assertEquals(2147483647, result.getProperty("PropertyInt32").asPrimitive());
+    Assert.assertEquals(9223372036854775807L, result.getProperty("PropertyInt64").asPrimitive());
+    Assert.assertEquals(1.79E20F, result.getProperty("PropertySingle").asPrimitive());
+    Assert.assertEquals(-1.79E19, result.getProperty("PropertyDouble").asPrimitive());
+    Assert.assertEquals(BigDecimal.valueOf(34), result.getProperty("PropertyDecimal").asPrimitive());
+    Assert.assertArrayEquals(edmBinary("ASNFZ4mrze8="), (byte[]) result.getProperty("PropertyBinary").asPrimitive());
     Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
     Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
         .asPrimitive());
-    Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
-        .asPrimitive());
-    Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
-        .asPrimitive());
+    Assert.assertEquals(BigDecimal.valueOf(6), result.getProperty("PropertyDuration").asPrimitive());
+    Assert.assertEquals(UUID.fromString("01234567-89ab-cdef-0123-456789abcdef"),
+        result.getProperty("PropertyGuid").asPrimitive());
     Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
   }
-  
+
   @Test
   public void entitySimpleWithTypes() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
@@ -247,32 +190,31 @@ public class ODataXmlDeserializerTest {
         "  </atom:content>\n" + 
         "</atom:entry>\n"; 
     
-    Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+    Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
         edmEntitySet.getEntityType()).getEntity();
 
     Assert.assertEquals(16, result.getProperties().size());
     Assert.assertEquals(2, result.getNavigationBindings().size());
     
-    Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
     Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
-    Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
-    Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
-    Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
-    Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
-    Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
-    Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
-    Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
-//    Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
+    Assert.assertEquals((short) 255, result.getProperty("PropertyByte").asPrimitive());
+    Assert.assertEquals((byte) 127, result.getProperty("PropertySByte").asPrimitive());
+    Assert.assertEquals(2147483647, result.getProperty("PropertyInt32").asPrimitive());
+    Assert.assertEquals(9223372036854775807L, result.getProperty("PropertyInt64").asPrimitive());
+    Assert.assertEquals(1.79E20F, result.getProperty("PropertySingle").asPrimitive());
+    Assert.assertEquals(-1.79E19, result.getProperty("PropertyDouble").asPrimitive());
+    Assert.assertEquals(BigDecimal.valueOf(34), result.getProperty("PropertyDecimal").asPrimitive());
+    Assert.assertArrayEquals(edmBinary("ASNFZ4mrze8="), (byte[]) result.getProperty("PropertyBinary").asPrimitive());
     Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
     Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
         .asPrimitive());
-    Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
-        .asPrimitive());
-    Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
-        .asPrimitive());
+    Assert.assertEquals(BigDecimal.valueOf(6), result.getProperty("PropertyDuration").asPrimitive());
+    Assert.assertEquals(UUID.fromString("01234567-89ab-cdef-0123-456789abcdef"),
+        result.getProperty("PropertyGuid").asPrimitive());
     Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
   }  
-  
+
   @Test
   public void entityCompAllPrim() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompAllPrim");
@@ -309,7 +251,7 @@ public class ODataXmlDeserializerTest {
           + "</atom:content>"
         + "</atom:entry>";
     
-    Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+    Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
         edmEntitySet.getEntityType()).getEntity();
 
     Assert.assertEquals("olingo.odata.test1.ETCompAllPrim",result.getType());
@@ -317,8 +259,8 @@ public class ODataXmlDeserializerTest {
     Assert.assertEquals(2, result.getProperties().size());
     Assert.assertEquals(0, result.getNavigationLinks().size());
 
-    Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
-    
+    Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
+
     Assert.assertNotNull(result.getProperty("PropertyComp"));
     Property comp = result.getProperty("PropertyComp");
     Assert.assertEquals("olingo.odata.test1.CTAllPrim", comp.getType());
@@ -326,14 +268,14 @@ public class ODataXmlDeserializerTest {
     
     Assert.assertEquals(16, cv.getValue().size());
     
-    Assert.assertEquals(edmInt16("32767"), getCVProperty(cv, "PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 32767, getCVProperty(cv, "PropertyInt16").asPrimitive());
     Assert.assertEquals("First Resource - first", getCVProperty(cv, "PropertyString").asPrimitive());
-    Assert.assertEquals(edmByte("255"), getCVProperty(cv, "PropertyByte").asPrimitive());
-    Assert.assertEquals(edmSByte("127"), getCVProperty(cv, "PropertySByte").asPrimitive());
-    Assert.assertEquals(edmInt32("2147483647"), getCVProperty(cv, "PropertyInt32").asPrimitive());
-    Assert.assertEquals(edmInt64("9223372036854775807"), getCVProperty(cv, "PropertyInt64").asPrimitive());
+    Assert.assertEquals((short) 255, getCVProperty(cv, "PropertyByte").asPrimitive());
+    Assert.assertEquals((byte) 127, getCVProperty(cv, "PropertySByte").asPrimitive());
+    Assert.assertEquals(2147483647, getCVProperty(cv, "PropertyInt32").asPrimitive());
+    Assert.assertEquals(9223372036854775807L, getCVProperty(cv, "PropertyInt64").asPrimitive());
   }  
-  
+
   private Property getCVProperty(ComplexValue cv, String name) {
     for (Property p:cv.getValue()) {
       if (p.getName().equals(name)) {
@@ -343,7 +285,6 @@ public class ODataXmlDeserializerTest {
     return null;
   }
   
-  @SuppressWarnings("unchecked")
   @Test
   public void entityMixPrimCollComp() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
@@ -384,7 +325,7 @@ public class ODataXmlDeserializerTest {
         "  </atom:content>\n" + 
         "</atom:entry>\n"; 
 
-    Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+    Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
         edmEntitySet.getEntityType()).getEntity();
 
     Assert.assertEquals(4, result.getProperties().size());
@@ -398,22 +339,22 @@ public class ODataXmlDeserializerTest {
     ComplexValue cv = (ComplexValue)comp.getValue();
     
     Assert.assertEquals(2, cv.getValue().size());
-    Assert.assertEquals(edmInt16("111"), getCVProperty(cv, "PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 111, getCVProperty(cv, "PropertyInt16").asPrimitive());
     Assert.assertEquals("TEST A", getCVProperty(cv, "PropertyString").asPrimitive());
     
     comp = result.getProperty("CollPropertyComp");
     Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", comp.getType());
+    @SuppressWarnings("unchecked")
     List<ComplexValue> properties = (List<ComplexValue>)comp.getValue();
     
     Assert.assertEquals(3, properties.size());
     
-    Assert.assertEquals(edmInt16("123"), getCVProperty(properties.get(0), "PropertyInt16")
-        .asPrimitive());
-    Assert.assertEquals("TEST 1", getCVProperty(properties.get(0), "PropertyString")
-        .asPrimitive());
+    Assert.assertEquals((short) 123,
+        getCVProperty(properties.get(0), "PropertyInt16").asPrimitive());
+    Assert.assertEquals("TEST 1",
+        getCVProperty(properties.get(0), "PropertyString").asPrimitive());
 
-    Assert.assertEquals(edmInt16("789"), getCVProperty(properties.get(2), "PropertyInt16")
-        .asPrimitive());
+    Assert.assertEquals((short) 789, getCVProperty(properties.get(2), "PropertyInt16").asPrimitive());
     Assert.assertEquals("TEST 3", getCVProperty(properties.get(2), "PropertyString")
         .asPrimitive());    
   }
@@ -461,13 +402,13 @@ public class ODataXmlDeserializerTest {
         "</atom:entry>\n" + 
         "";
     
-    Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+    Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
         edmEntitySet.getEntityType()).getEntity();
 
     Assert.assertEquals(2, result.getProperties().size());
     Assert.assertEquals(1, result.getNavigationLinks().size());
     
-    Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
     Assert.assertEquals("Test String4", result.getProperty("PropertyString").asPrimitive());    
     
     Assert.assertEquals(1, result.getNavigationLinks().size());
@@ -491,8 +432,8 @@ public class ODataXmlDeserializerTest {
         + "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
         + "234</metadata:value>";
 
-    Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();    
-    Assert.assertEquals(edmInt16("234"), result.getValue()); 
+    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+    Assert.assertEquals((short) 234, result.getValue()); 
   }
 
   @Test
@@ -503,7 +444,7 @@ public class ODataXmlDeserializerTest {
         + "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
         + "metadata:null=\"true\"/>";
 
-    Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();    
+    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
     Assert.assertNull(result.getValue());    
   }
   
@@ -517,7 +458,7 @@ public class ODataXmlDeserializerTest {
         + "<metadata:element>Employee2@company.example</metadata:element>"
         + "<metadata:element>Employee3@company.example</metadata:element>"
         + "</metadata:value>";
-    Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();    
+    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
     Assert.assertEquals(Arrays.asList("Employee1@company.example", "Employee2@company.example",
         "Employee3@company.example"), result.getValue());
     
@@ -557,7 +498,7 @@ public class ODataXmlDeserializerTest {
         "  <data:PostalCode>12209</data:PostalCode>\n" + 
         "</data:ShipTo>";
     
-    Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();    
+    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
 
     Assert.assertEquals("ShipTo", result.getName());
     Assert.assertTrue(result.getValue() instanceof ComplexValue);
@@ -588,15 +529,15 @@ public class ODataXmlDeserializerTest {
         "    <data:PropertyString>TEST 3</data:PropertyString>\n" + 
         "  </metadata:element>\n" + 
         "</metadata:value>";
-    Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();    
+    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
 
     List<ComplexValue> complex = (List<ComplexValue>)result.getValue();
     
     Assert.assertEquals(3, complex.size());
     Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", result.getType());
-    Assert.assertEquals(edmInt16("123"), getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 123, getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
     Assert.assertEquals("TEST 1", getCVProperty(complex.get(0), "PropertyString").asPrimitive());
-    Assert.assertEquals(edmInt16("789"), getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 789, getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
     Assert.assertEquals("TEST 3", getCVProperty(complex.get(2), "PropertyString").asPrimitive());
   }
   
@@ -607,7 +548,7 @@ public class ODataXmlDeserializerTest {
         "              xmlns=\"http://www.w3.org/2005/Atom\" "+
         "              id=\"http://host/service/Orders(10643)\" />";
     
-    List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
+    List<URI> result = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
         .getEntityReferences();    
     Assert.assertEquals(1, result.size());
     Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
@@ -622,7 +563,7 @@ public class ODataXmlDeserializerTest {
         "  <metadata:ref id=\"http://host/service/Orders(10759)\" />\n" + 
         "</feed>";
     
-    List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
+    List<URI> result = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
         .getEntityReferences();    
     Assert.assertEquals(2, result.size());
     Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 9f79a84..b115fb8 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -18,12 +18,11 @@
  */
 package org.apache.olingo.server.core.uri.antlr;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.util.Arrays;
 
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.core.Encoder;
 import org.apache.olingo.commons.core.edm.EdmProviderImpl;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriResourceKind;
@@ -326,7 +325,7 @@ public class TestUriParserImpl {
   }
 
   @Test
-  public void testEntitySet() throws UnsupportedEncodingException {
+  public void entitySet() throws Exception {
 
     // plain entity set
     testRes.run("ESAllPrim")
@@ -351,7 +350,7 @@ public class TestUriParserImpl {
     .isKeyPredicate(1, "PropertyString", "'ABC'");
 
     // with all keys
-    testRes.run("ESAllKey(" + encode(allKeys) + ")")
+    testRes.run("ESAllKey(" + Encoder.encode(allKeys) + ")")
     .isEntitySet("ESAllKey")
     .isKeyPredicate(0, "PropertyString", "'ABC'")
     .isKeyPredicate(1, "PropertyInt16", "1")
@@ -1165,8 +1164,4 @@ public class TestUriParserImpl {
     testUri.runEx("ESMixPrimCollComp", "$select=/PropertyInt16")
     .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
   }
-
-  public static String encode(final String decoded) throws UnsupportedEncodingException {
-    return URLEncoder.encode(decoded, "UTF-8");
-  }
 }


[07/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertXmlITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertXmlITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertXmlITCase.java
deleted file mode 100644
index d9bda60..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertXmlITCase.java
+++ /dev/null
@@ -1,950 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.fit.tecsvc.client;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
-import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ClientComplexValue;
-import org.apache.olingo.client.api.domain.ClientEntity;
-import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.apache.olingo.client.api.domain.ClientInlineEntity;
-import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
-import org.apache.olingo.client.api.domain.ClientLink;
-import org.apache.olingo.client.api.domain.ClientObjectFactory;
-import org.apache.olingo.client.api.domain.ClientProperty;
-import org.apache.olingo.client.api.domain.ClientValue;
-import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * see the class comment on {@link DeepInsertITCase}
- */
-public class DeepInsertXmlITCase extends AbstractParamTecSvcITCase {
-
-  private static final String ES_KEY_NAV = "ESKeyNav";
-  private static final String ES_TWO_KEY_NAV = "ESTwoKeyNav";
-  private static final String ET_KEY_NAV_NAME = "ETKeyNav";
-  private static final String ET_TWO_KEY_NAV_NAME = "ETTwoKeyNav";
-  private static final FullQualifiedName ET_KEY_NAV = new FullQualifiedName(SERVICE_NAMESPACE, ET_KEY_NAV_NAME);
-  private static final FullQualifiedName ET_TWO_KEY_NAV = 
-      new FullQualifiedName(SERVICE_NAMESPACE, ET_TWO_KEY_NAV_NAME);
-  private static final String CT_PRIM_COMP = "CTPrimComp";
-  private static final String CT_TWO_PRIM = "CTTwoPrim";
-  private static final String CT_ALL_PRIM = "CTAllPrim";
-  private static final String CT_NAV_FIVE_PROP = "CTNavFiveProp";
-  private static final String CT_BASE_PRIM_COMP_NAV = "CTBasePrimCompNav";
-  private static final String PROPERTY_INT16 = "PropertyInt16";
-  private static final String PROPERTY_STRING = "PropertyString";
-  private static final String PROPERTY_COMP = "PropertyComp";
-  private static final String PROPERTY_COMP_NAV = "PropertyCompNav";
-  private static final String PROPERTY_COMP_COMP_NAV = "PropertyCompCompNav";
-  private static final String PROPERTY_COMP_TWO_PRIM = "PropertyCompTwoPrim";
-  private static final String PROPERTY_COMP_ALL_PRIM = "PropertyCompAllPrim";
-  private static final String NAV_PROPERTY_ET_KEY_NAV_ONE = "NavPropertyETKeyNavOne";
-  private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
-  private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
-  private static final String COL_PROPERTY_STRING = "CollPropertyString";
-  private static final String COL_PROPERTY_COMP_NAV = "CollPropertyCompNav";
-  private static final String EDM_STRING = "Edm.String";
-
-  @Test
-  public void deepInsertExpandedResponse() {
-    final ODataClient client = getClient(SERVICE_URI);
-    client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
-    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
-    final ClientObjectFactory of = client.getObjectFactory();
-    final ClientEntity entity = of.newEntity(ET_KEY_NAV);
-
-    // Root entity
-    entity.getProperties().add(
-        of.newPrimitiveProperty(PROPERTY_STRING, 
-            of.newPrimitiveValueBuilder().buildString("String Property level 0")));
-    entity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 41)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 0, complex level 1")))));
-
-    // First level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
-    final ClientEntity firstLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
-    firstLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 1, complex level 1")))));
-    firstLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    firstLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-    final ClientInlineEntity firstLevelTwoKeyOneInline =
-        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
-    entity.addLink(firstLevelTwoKeyOneInline);
-
-    // Second level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
-    final ClientEntity secondLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
-    secondLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 421)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 2, complex level 1")))));
-    secondLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    secondLevelTwoKeyNav.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-
-    // Binding links
-    secondLevelTwoKeyNav.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, client.newURIBuilder(
-        SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String, Object>() {
-          private static final long serialVersionUID = 3109256773218160485L;
-          {
-            put(PROPERTY_INT16, 3);
-            put(PROPERTY_STRING, "1");
-          }
-        }).build()));
-
-    final ClientInlineEntity secondLevelTwoKeyOneInline =
-        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, secondLevelTwoKeyNav);
-    firstLevelTwoKeyNav.addLink(secondLevelTwoKeyOneInline);
-
-    // Third level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
-    final ClientEntity thirdLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 3, complex level 1")))));
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-
-    final ClientEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 3, complex level 1")))));
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-
-    final ClientEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
-    entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
-    entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
-    secondLevelTwoKeyNav.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
-        entitySetThirdLevelTwoKeyNavMany));
-
-    // First level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
-    final ClientEntity firstLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 422)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
-                "String Property level 1, complex level 1")))));
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-
-    final ClientEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
-    entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
-    entity.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
-        entitySetfirstLevelTwoKeyNavMany));
-
-    final ODataEntityCreateResponse<ClientEntity> createResponse =
-        client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
-
-    // Check response
-    final ClientEntity resultEntityFirstLevel =
-        createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
-        .asInlineEntity().getEntity();
-    assertEquals(42, resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    assertEquals("String Property level 1, complex level 1", 
-        resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    final ClientEntity resultEntitySecondLevel =
-        resultEntityFirstLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
-    assertEquals(421, resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    assertEquals("String Property level 2, complex level 1", resultEntitySecondLevel
-        .getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    final ClientEntitySet thirdLevelEntitySetNavMany =
-        resultEntitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
-        .asInlineEntitySet().getEntitySet();
-    assertEquals(2, thirdLevelEntitySetNavMany.getEntities().size());
-
-    assertEquals(431, thirdLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(0)
-        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
-
-    assertEquals(432, thirdLevelEntitySetNavMany.getEntities().get(1).getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(1)
-        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
-
-    final ClientEntitySet firstLevelEntitySetNavMany =
-        createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
-        .asInlineEntitySet().getEntitySet();
-    assertEquals(1, firstLevelEntitySetNavMany.getEntities().size());
-    assertEquals(422, firstLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertEquals("String Property level 1, complex level 1", firstLevelEntitySetNavMany.getEntities().get(0)
-        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue()
-        .get(PROPERTY_STRING).getPrimitiveValue().toValue());
-  }
-
-  @Test
-  public void simpleDeepInsert() throws EdmPrimitiveTypeException {
-    final ODataClient client = getClient();
-    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
-    final ClientObjectFactory of = client.getObjectFactory();
-    final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
-
-    // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
-        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, 
-                of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
-
-    // Non collection navigation property
-    // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
-    final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntitySingle.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
-    inlineEntitySingle.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
-    inlineEntitySingle.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 430)))));
-    inlineEntitySingle.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
-    inlineEntitySingle.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("432")))));
-
-    // Collection navigation property
-    // The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
-    // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
-    final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntityCol1.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
-    inlineEntityCol1.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("44")));
-    inlineEntityCol1.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
-    inlineEntityCol1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-          .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 440)))));
-    inlineEntityCol1.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
-
-    final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntityCol2.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
-    inlineEntityCol2.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("45")));
-    inlineEntityCol2.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
-    inlineEntityCol2.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-          .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 450)))));
-    inlineEntityCol2.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
-
-    final ClientInlineEntity newDeepInsertEntityLink =
-        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
-    final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
-    newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
-    newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
-    final ClientInlineEntitySet newDeepInsertEntitySetLink =
-        of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
-
-    entity.addLink(newDeepInsertEntityLink);
-    entity.addLink(newDeepInsertEntitySetLink);
-
-    // Perform create request
-    final ODataEntityCreateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
-        .getEntityCreateRequest(createURI, entity)
-        .execute();
-    assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
-
-    final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
-
-    // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
-    ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
-    final URI esKeyNavURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
-            propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
-                NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
-
-    final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
-        .getEntityRequest(esKeyNavURI);
-    esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
-
-    ClientEntity clientEntity = esKeyNavResponse.getBody();
-    // Check nav. property NavPropertyETTwoKeyNavOne
-    assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
-    ClientInlineEntity navOne = (ClientInlineEntity)clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
-    assertShortOrInt(431, navOne.getEntity().getProperty(
-        PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Check nav. property NavPropertyETTwoKeyNavMany
-    assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
-    ClientInlineEntitySet navMany = (ClientInlineEntitySet)clientEntity
-        .getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
-    assertEquals(2, navMany.getEntitySet().getEntities().size());
-    
-    assertShortOrInt(441,  navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV)
-        .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV)
-        .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
-    Map<String, Object> composedKey = new HashMap<String, Object>();
-    composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, navOne.getEntity().getProperty(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
-        .appendEntitySetSegment(ES_TWO_KEY_NAV)
-        .appendKeySegment(composedKey)
-        .build();
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
-        .getEntityRequest(esTwoKeyNavEntitySingleURI);
-    esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
-    assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue()
-        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
-    composedKey.clear();
-    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    URI esTwoKeyNavEntityManyOneURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
-        .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
-    esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
-
-    assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    
-    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
-    ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
-    composedKey.clear();
-    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    URI esTwoKeyNavEntityManyTwoURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
-        .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
-    esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
-
-    assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
-    
-    nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-  }
-
-  @Test
-  public void deepInsertSameEntitySet() throws EdmPrimitiveTypeException {
-    final ODataClient client = getClient();
-    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
-    final ClientObjectFactory of = client.getObjectFactory();
-    final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
-
-    // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
-        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, 
-                of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
-    entity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
-        client.newURIBuilder(SERVICE_URI)
-        .appendEntitySetSegment(ES_TWO_KEY_NAV)
-        .appendKeySegment(new LinkedHashMap<String, Object>() {
-          private static final long serialVersionUID = 1L;
-
-          {
-            put(PROPERTY_INT16, 1);
-            put(PROPERTY_STRING, "1");
-          }
-        })
-        .build()));
-
-    // Prepare inline entity(EntitySet: ESKeyNav, Type: ETKeyNav)
-    final ClientEntity innerEntity = of.newEntity(ET_KEY_NAV);
-    innerEntity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
-    innerEntity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
-    innerEntity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
-    innerEntity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))));
-    innerEntity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))));
-    innerEntity
-    .getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))
-        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder()
-                .buildInt16((short) 431)))))));
-    innerEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
-        client.newURIBuilder(SERVICE_URI)
-        .appendEntitySetSegment(ES_TWO_KEY_NAV)
-        .appendKeySegment(new LinkedHashMap<String, Object>() {
-          private static final long serialVersionUID = 1L;
-
-          {
-            put(PROPERTY_INT16, 1);
-            put(PROPERTY_STRING, "1");
-          }
-        })
-        .build()));
-
-    ClientInlineEntity inlineEntity = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
-    entity.addLink(inlineEntity);
-
-    final ODataEntityCreateResponse<ClientEntity> responseCreate =
-        client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
-    final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
-    final Short esKeyNavEntityKey =
-        responseCreate.getBody().getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
-
-    // Fetch Entity
-    URI fetchEntityURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(esKeyNavEntityKey)
-        .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
-
-    ODataEntityRequest<ClientEntity> entityRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
-    entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
-
-    ClientEntity clientEntity = entityResponse.getBody();
-    ClientInlineEntity navOne =
-        (ClientInlineEntity) clientEntity.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
-
-    // Check values
-    assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
-        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    Short innerEntityInt16Key = navOne.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toCastValue(Short.class);
-
-    final URI innerEntityURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(innerEntityInt16Key)
-        .build();
-    final ODataEntityRequest<ClientEntity> innerRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(innerEntityURI);
-    innerRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    ODataRetrieveResponse<ClientEntity> innerResponse = innerRequest.execute();
-
-    assertShortOrInt(431, innerResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-  }
-
-  @Test
-  public void consistency() throws EdmPrimitiveTypeException {
-    final EdmEnabledODataClient client = getClient(SERVICE_URI);
-    final ClientObjectFactory of = client.getObjectFactory();
-    final String cookie = getCookie();
-
-    // Do not set PropertyString(Nullable=false)
-    final ClientEntity entity = of.newEntity(ET_KEY_NAV);
-    entity.getProperties().add(
-        of.newCollectionProperty(COL_PROPERTY_STRING,
-            of.newCollectionValue(EDM_STRING).add(
-                of.newPrimitiveValueBuilder().buildString("Test"))));
-
-    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
-
-    try {
-      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
-          .getEntityCreateRequest(targetURI, entity);
-      request.addCustomHeader(HttpHeader.COOKIE, cookie);
-      request.execute();
-      fail("Expecting bad request");
-    } catch (ODataClientErrorException e) {
-      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
-    }
-
-    // Entity must not be created
-    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
-  }
-
-  @Test
-  public void invalidType() throws EdmPrimitiveTypeException {
-    final EdmEnabledODataClient client = getClient(SERVICE_URI);
-    final ClientObjectFactory of = client.getObjectFactory();
-    final String cookie = getCookie();
-
-    final ClientEntity entity = of.newEntity(ET_KEY_NAV);
-    entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, 
-        of.newPrimitiveValueBuilder().buildInt32(1)));
-    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
-
-    try {
-      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
-          .getEntityCreateRequest(targetURI, entity);
-      request.addCustomHeader(HttpHeader.COOKIE, cookie);
-      request.execute();
-    } catch (ODataClientErrorException e) {
-      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
-    }
-
-    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
-
-    entity.getProperties().add(
-        of.newCollectionProperty(PROPERTY_STRING,
-            of.newCollectionValue(EDM_STRING).add(
-                of.newPrimitiveValueBuilder().buildString("Test"))));
-
-    try {
-      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
-          .getEntityCreateRequest(targetURI, entity);
-      request.addCustomHeader(HttpHeader.COOKIE, cookie);
-      request.execute();
-    } catch (ODataClientErrorException e) {
-      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
-    }
-
-    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
-  }
-
-  @Test
-  @Ignore
-  public void deepInsertOnNavigationPropertyInComplexProperty() {
-    final EdmEnabledODataClient client = getClient(SERVICE_URI);
-    final ClientObjectFactory of = client.getObjectFactory();
-
-    final ClientEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
-    inlineEntity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    inlineEntity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-    inlineEntity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
-
-    final ClientEntity entity = of.newEntity(ET_TWO_KEY_NAV);
-    entity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
-    entity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-    entity.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 2)))
-            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
-
-    final ClientLink link = of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
-    final ClientComplexValue complexValueCreate = of.newComplexValue(CT_NAV_FIVE_PROP);
-    complexValueCreate.getNavigationLinks().add(link);
-
-    entity.getProperties().add(
-        of.newCollectionProperty(COL_PROPERTY_COMP_NAV, of.newCollectionValue(CT_NAV_FIVE_PROP)
-            .add(complexValueCreate)));
-
-    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
-    final ODataEntityCreateResponse<ClientEntity> response = client.getCUDRequestFactory()
-        .getEntityCreateRequest(targetURI, entity)
-        .execute();
-
-    assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
-    final Iterator<ClientValue> iter = response.getBody()
-        .getProperty(COL_PROPERTY_COMP_NAV)
-        .getCollectionValue()
-        .iterator();
-
-    assertTrue(iter.hasNext());
-    final ClientComplexValue complexValue = iter.next().asComplex();
-    final ClientLink linkedEntity = complexValue.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
-    assertNotNull(linkedEntity);
-    assertEquals(1, linkedEntity.asInlineEntity()
-        .getEntity()
-        .getProperty(PROPERTY_INT16)
-        .getPrimitiveValue()
-        .toValue());
-  }
-
-  @Test
-  public void deepUpsert() {
-    final ODataClient client = getClient();
-    final URI updateURI = client.newURIBuilder(SERVICE_URI)
-        .appendEntitySetSegment(ES_KEY_NAV)
-        .appendKeySegment(815)
-        .build();
-    final ClientObjectFactory of = client.getObjectFactory();
-    final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
-
-    // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
-    entity.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
-    entity.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
-        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, 
-                of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
-
-    // Non collection navigation property
-    // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
-    final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntitySingle.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
-    inlineEntitySingle.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
-    inlineEntitySingle.getProperties().add(of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)))));
-    inlineEntitySingle.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
-    inlineEntitySingle.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("432")))));
-
-    // Collection navigation property
-    // The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
-    // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
-    final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntityCol1.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
-    inlineEntityCol1.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("44")));
-    inlineEntityCol1.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
-    inlineEntityCol1.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
-    inlineEntityCol1.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
-
-    final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntityCol2.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
-    inlineEntityCol2.getProperties()
-    .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("45")));
-    inlineEntityCol2.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
-    inlineEntityCol2.getProperties().add(
-        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
-            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
-    inlineEntityCol2.getProperties()
-    .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
-        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
-        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
-
-    final ClientInlineEntity newDeepInsertEntityLink =
-        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
-    final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
-    newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
-    newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
-    final ClientInlineEntitySet newDeepInsertEntitySetLink =
-        of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
-
-    entity.addLink(newDeepInsertEntityLink);
-    entity.addLink(newDeepInsertEntitySetLink);
-
-    // Perform update request (upsert)
-    final ODataEntityUpdateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
-        .getEntityUpdateRequest(updateURI, UpdateType.PATCH, entity)
-        .execute();
-    assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
-
-    final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
-
-    // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
-    ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
-    final URI esKeyNavURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
-            propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
-                NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
-
-    final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
-        .getEntityRequest(esKeyNavURI);
-    esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
-
-    // Check nav. property NavPropertyETTwoKeyNavOne
-    assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
-    ClientInlineEntity navOne = (ClientInlineEntity)esKeyNavResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
-    assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
-        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Check nav. property NavPropertyETTwoKeyNavMany
-    assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
-    ClientInlineEntitySet navMany = (ClientInlineEntitySet)esKeyNavResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
-    assertEquals(2, navMany.getEntitySet().getEntities().size());
-
-    assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV).getValue()
-        .asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    
-    assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV).getValue()
-        .asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
-    Map<String, Object> composedKey = new HashMap<String, Object>();
-    composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING,  navOne.getEntity().getProperty(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
-
-    final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
-        .appendEntitySetSegment(ES_TWO_KEY_NAV)
-        .appendKeySegment(composedKey)
-        .build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
-        .getEntityRequest(esTwoKeyNavEntitySingleURI);
-    esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
-    assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
-    composedKey.clear();
-    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0)
-        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(0)
-        .getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
-
-    URI esTwoKeyNavEntityManyOneURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
-        .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
-    esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
-
-    assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
-    ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE); 
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-
-    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
-    composedKey.clear();
-    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1)
-        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(1)
-        .getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
-
-    URI esTwoKeyNavEntityManyTwoURI =
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
-        .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
-        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
-    esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
-
-    assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
-        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
-    nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
-        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(),nvLink.getEntity()
-        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
-  }
-
-  private String getCookie() {
-    final EdmEnabledODataClient client = getClient(SERVICE_URI);
-    final ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
-        .getEntitySetRequest(client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
-        .execute();
-
-    return response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
-  }
-
-  private void validateSet(final URI uri, final String cookie, final short... keys) 
-      throws EdmPrimitiveTypeException {
-    final EdmEnabledODataClient client = getClient(SERVICE_URI);
-    final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
-        .getEntitySetRequest(uri);
-    request.addCustomHeader(HttpHeader.COOKIE, cookie);
-    final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
-
-    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
-    assertEquals(3, response.getBody().getEntities().size());
-
-    for (final ClientEntity responseEntity : response.getBody().getEntities()) {
-      short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16)
-          .getPrimitiveValue().toCastValue(Short.class);
-
-      boolean found = false;
-      for (int i = 0; i < keys.length && !found; i++) {
-        if (propertyInt16 == keys[i]) {
-          found = true;
-        }
-      }
-
-      if (!found) {
-        fail("Invalid key " + propertyInt16);
-      }
-    }
-  }
-
-  @Override
-  protected ODataClient getClient() {
-    ODataClient odata = ODataClientFactory.getClient();
-    odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
-    return odata;
-  }  
-
-  @Override
-  protected void assertContentType(final String content) {
-    assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
-  }
-
-  @Override
-  protected EdmEnabledODataClient getClient(final String serviceRoot) {
-    return ODataClientFactory.getEdmEnabledClient(serviceRoot, ContentType.APPLICATION_ATOM_XML);
-  }  
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
index 22794f7..507b9a9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
@@ -216,7 +216,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
   @Test
   @Ignore("Server do not support navigation property count annotations")
   public void count() {
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
     options.put(QueryOption.SELECT, "PropertyInt16");
     options.put(QueryOption.COUNT, true);
@@ -254,7 +254,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
   @Test
   public void singleEntityWithExpand() {
     /* A single entity request will be dispatched to a different processor method than entity set request */
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
     options.put(QueryOption.FILTER, "PropertyInt16 lt 2");
     Map<String, Object> keys = new HashMap<String, Object>();
@@ -295,7 +295,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
     // Entity with Key (PropertyInt16=1, PropertyString='2') holds references to (PropertyInt16=1, PropertyString='1')
     // Define filters to select explicit the entities at any level => Circle
 
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
     options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
         + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
@@ -370,7 +370,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
 
   @Test
   public void systemQueryOptionOnThirdLevel() {
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
     options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
         + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
@@ -443,7 +443,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
 
   @Test
   public void expandWithSearchQuery() {
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
     expandOptions.put(QueryOption.SEARCH, "abc");
     expandOptions.put(QueryOption.FILTER, "PropertyInt16 eq 1");
@@ -463,7 +463,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
  
   @Test
   public void expandWithLevels() {
-    final ODataClient client = getClient(SERVICE_URI);
+    final ODataClient client = getEdmEnabledClient();
     Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
     expandOptions.put(QueryOption.LEVELS, 2);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java
index 9f3a87c..34ddab6 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java
@@ -31,7 +31,7 @@ public interface EdmNavigationProperty extends EdmElement, EdmAnnotationsTarget,
   EdmEntityType getType();
 
   /**
-   * @return true if nullable or null if not specified
+   * @return true if nullable or not specified
    */
   boolean isNullable();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java
index ded6462..876b6f0 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java
@@ -26,7 +26,7 @@ import org.apache.olingo.commons.api.edm.geo.SRID;
 public interface EdmParameter extends EdmElement, EdmMappable, EdmAnnotatable {
 
   /**
-   * @return true if nullable or null if not specified
+   * @return true if nullable or not specified
    */
   boolean isNullable();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java
index f530218..aba2b4b 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java
@@ -42,7 +42,7 @@ public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotationsTarg
   boolean isPrimitive();
 
   /**
-   * @return true if nullable or null if not specified
+   * @return true if nullable or not specified
    */
   boolean isNullable();
 
@@ -67,7 +67,7 @@ public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotationsTarg
   SRID getSrid();
 
   /**
-   * @return true if unicode or null if not specified
+   * @return true if unicode or not specified
    */
   boolean isUnicode();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java
index 311b06a..2f3e142 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java
@@ -26,7 +26,7 @@ import org.apache.olingo.commons.api.edm.geo.SRID;
 public interface EdmReturnType extends EdmTyped {
 
   /**
-   * @return true if nullable or null if not specified
+   * @return true if nullable or not specified
    */
   boolean isNullable();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index 22fdc2b..ad7d410 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -112,18 +112,15 @@ public class ODataImpl extends OData {
 
   @Override
   public ODataDeserializer createDeserializer(final ContentType contentType) throws DeserializerException {
-    ODataDeserializer deserializer;
-
     if (contentType.isCompatible(ContentType.JSON)) {
-      deserializer = new ODataJsonDeserializer(contentType);
+      return new ODataJsonDeserializer(contentType);
     } else if (contentType.isCompatible(ContentType.APPLICATION_XML)
         || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
-      deserializer = new ODataXmlDeserializer();      
+      return new ODataXmlDeserializer();
     } else {
       throw new DeserializerException("Unsupported format: " + contentType.toContentTypeString(),
           DeserializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
     }
-    return deserializer;
   }
 
   @Override


[08/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index 683c6ed..d8a467a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 import java.net.URI;
 import java.util.HashMap;
@@ -29,6 +30,8 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.request.cud.UpdateType;
@@ -53,20 +56,7 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.junit.Ignore;
 import org.junit.Test;
 
-/**
- * The issue I see with this unit test, or in general with JSON metadata=minimal case is
- * none of the navigation properties will be represented as such in deserialized form, because
- * no navigation link information will be written when metadata=minimal. The client will
- * interpret those results as complex properties (which I do not think is right).
- * 
- * Where as in the atom+xml case, there is no intermediate results, it is equivalent to
- * metadata=full, thus the navigation links and inline content is correctly represented through
- * deserialization. 
- * 
- * For above reason, the DeepInsertXMLITCase case re-written slightly differently.  
- *
- */
-public class DeepInsertITCase extends AbstractTecSvcITCase {
+public class DeepInsertITCase extends AbstractParamTecSvcITCase {
 
   private static final String ES_KEY_NAV = "ESKeyNav";
   private static final String ES_TWO_KEY_NAV = "ESTwoKeyNav";
@@ -95,58 +85,74 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
 
   @Test
   public void deepInsertExpandedResponse() {
-    final URI createURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+    assumeTrue("The server XML deserializer does not (yet?!) fill the expand information;"
+        + " the response is therefore not expanded in XML.",
+        isJson());  // TODO: XML case
+    final ODataClient client = getEdmEnabledClient();
+    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
     final ClientObjectFactory factory = getFactory();
     final ClientEntity entity = factory.newEntity(ET_KEY_NAV);
 
     // Root entity
-    entity.getProperties().add(
-        factory.newPrimitiveProperty(PROPERTY_STRING,
-                factory.newPrimitiveValueBuilder().buildString("String Property level 0")));
-    entity.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    entity.getProperties()
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+            factory.newPrimitiveValueBuilder().buildString("String Property level 0")));
+    entity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 41)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 41)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 0, complex level " +
-                                "1")))));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 0, complex level 1")))));
 
     // First level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
     final ClientEntity firstLevelTwoKeyNav = factory.newEntity(ET_TWO_KEY_NAV);
-    firstLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    firstLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 42)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 42)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 1, complex level 1")))));
-    firstLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
-    firstLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 1, complex level 1")))));
+    firstLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 9999)))));
+    firstLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 8888)))));
     final ClientInlineEntity firstLevelTwoKeyOneInline =
         factory.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
     entity.addLink(firstLevelTwoKeyOneInline);
 
     // Second level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
     final ClientEntity secondLevelTwoKeyNav = factory.newEntity(ET_TWO_KEY_NAV);
-    secondLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    secondLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 421)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 421)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 2, complex level 1")))));
-    secondLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
-    secondLevelTwoKeyNav.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 2, complex level 1")))));
+    secondLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 9999)))));
+    secondLevelTwoKeyNav.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 8888)))));
 
     // Binding links
-    secondLevelTwoKeyNav.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, getClient()
-            .newURIBuilder(
-                    SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String,
-                    Object>() {
+    secondLevelTwoKeyNav.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(
+            new LinkedHashMap<String, Object>() {
               private static final long serialVersionUID = 3109256773218160485L;
-
               {
                 put(PROPERTY_INT16, 3);
                 put(PROPERTY_STRING, "1");
@@ -159,57 +165,76 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
 
     // Third level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
     final ClientEntity thirdLevelTwoKeyNavMany1 = factory.newEntity(ET_TWO_KEY_NAV);
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    thirdLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 431)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 431)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 3, complex level " +
-                                "1")))));
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
-    thirdLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 3, complex level 1")))));
+    thirdLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 9999)))));
+    thirdLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 8888)))));
 
     final ClientEntity thirdLevelTwoKeyNavMany2 = factory.newEntity(ET_TWO_KEY_NAV);
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    thirdLevelTwoKeyNavMany2.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 432)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 432)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 3, complex level " +
-                                "1")))));
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
-    thirdLevelTwoKeyNavMany2.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 3, complex level 1")))));
+    thirdLevelTwoKeyNavMany2.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 9999)))));
+    thirdLevelTwoKeyNavMany2.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 8888)))));
 
     final ClientEntitySet entitySetThirdLevelTwoKeyNavMany = factory.newEntitySet();
     entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
     entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
     secondLevelTwoKeyNav.addLink(factory.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
-            entitySetThirdLevelTwoKeyNavMany));
+        entitySetThirdLevelTwoKeyNavMany));
 
     // First level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
     final ClientEntity firstLevelTwoKeyNavMany1 = factory.newEntity(ET_TWO_KEY_NAV);
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
+    firstLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 422)))
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 422)))
                 .add(factory.newPrimitiveProperty(PROPERTY_STRING,
-                        factory.newPrimitiveValueBuilder().buildString("String Property level 1, complex level 1")))));
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
-    firstLevelTwoKeyNavMany1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+                    factory.newPrimitiveValueBuilder().buildString("String Property level 1, complex level 1")))));
+    firstLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 9999)))));
+    firstLevelTwoKeyNavMany1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 8888)))));
 
     final ClientEntitySet entitySetfirstLevelTwoKeyNavMany = factory.newEntitySet();
     entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
     entity.addLink(factory.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
-            entitySetfirstLevelTwoKeyNavMany));
+        entitySetfirstLevelTwoKeyNavMany));
 
     final ODataEntityCreateResponse<ClientEntity> createResponse =
-        getEdmEnabledClient().getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
+        client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
 
     // Check response
     final ClientEntity resultEntityFirstLevel =
@@ -254,58 +279,66 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
 
   @Test
   public void simpleDeepInsert() throws Exception {
-    final URI createURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+    final ODataClient client = getEdmEnabledClient();
+    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
     final ClientObjectFactory factory = getFactory();
     final ClientEntity entity = factory.newEntity(ET_KEY_NAV);
 
     // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            42)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42)));
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_NAV_FIVE_PROP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 42)))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM, factory.newComplexValue(CT_ALL_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM,
+            factory.newComplexValue(CT_ALL_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    42)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 42)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("42")))
-            .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-                    .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))
+                .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+                    factory.newComplexValue(CT_NAV_FIVE_PROP)
+                        .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                             factory.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
 
     // Non collection navigation property
     // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
     final ClientEntity inlineEntitySingle = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntitySingle.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43)));
+    inlineEntitySingle.getProperties()
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
     inlineEntitySingle.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
-    inlineEntitySingle.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 430)))));
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 430)))));
     inlineEntitySingle.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 431)))));
     inlineEntitySingle.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    432)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 432)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
                     factory.newPrimitiveValueBuilder().buildString("432")))));
 
     // Collection navigation property
@@ -313,45 +346,49 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
     final ClientEntity inlineEntityCol1 = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntityCol1.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 44)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 44)));
     inlineEntityCol1.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("44")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("44")));
     inlineEntityCol1.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 441)))));
-    inlineEntityCol1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)
+    inlineEntityCol1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 440)))));
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 440)))));
     inlineEntityCol1.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short) 442)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("442"))
-            )));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 442)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("442")))));
 
     final ClientEntity inlineEntityCol2 = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntityCol2.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            45)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 45)));
     inlineEntityCol2.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("45")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("45")));
     inlineEntityCol2.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 451)))));
-    inlineEntityCol2.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)
+    inlineEntityCol2.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 450)))));
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 450)))));
     inlineEntityCol2.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    452)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("452")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 452)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("452")))));
 
     final ClientInlineEntity newDeepInsertEntityLink =
         factory.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
@@ -365,7 +402,7 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     entity.addLink(newDeepInsertEntitySetLink);
 
     // Perform create request
-    final ODataEntityCreateResponse<ClientEntity> responseCreate = getClient().getCUDRequestFactory()
+    final ODataEntityCreateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
         .getEntityCreateRequest(createURI, entity)
         .execute();
     assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
@@ -375,241 +412,251 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
     ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
     final URI esKeyNavURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
             propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
                 NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
 
-    final ODataEntityRequest<ClientEntity> esKeyNavRequest = getClient().getRetrieveRequestFactory()
+    final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
         .getEntityRequest(esKeyNavURI);
     esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
 
+    final ClientEntity clientEntity = esKeyNavResponse.getBody();
     // Check nav. property NavPropertyETTwoKeyNavOne
-    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
-    assertEquals(431, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).getComplexValue().get(
-        PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
+    ClientInlineEntity navOne = ((ClientInlineEntity) clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
+    assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
+        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Check nav. property NavPropertyETTwoKeyNavMany
-    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
-    assertEquals(2, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue()
-        .size());
-    Iterator<ClientValue> twoKeyNavManyIterator =
-        esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue().iterator();
-    final ClientValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
-    assertEquals(441, firstTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    final ClientValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
-    assertEquals(451, secondTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    ClientInlineEntitySet navMany = (ClientInlineEntitySet)
+        clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
+    assertEquals(2, navMany.getEntitySet().getEntities().size());
+    
+    assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV)
+        .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV)
+        .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
     Map<String, Object> composedKey = new HashMap<String, Object>();
-    composedKey.put(PROPERTY_INT16, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
-        .getComplexValue().get(PROPERTY_INT16)
-        .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
-        .getComplexValue().get(PROPERTY_STRING)
-        .getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, navOne.getEntity().getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
 
-    final URI esTwoKeyNavEntitySingleURI = getClient().newURIBuilder(SERVICE_URI)
+    final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
         .appendEntitySetSegment(ES_TWO_KEY_NAV)
         .appendKeySegment(composedKey)
         .build();
-
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = getClient().getRetrieveRequestFactory()
+    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
         .getEntityRequest(esTwoKeyNavEntitySingleURI);
     esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
-    assertEquals(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue()
+        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
     composedKey.clear();
-    composedKey.put(PROPERTY_INT16, firstTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, firstTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
-        .toValue());
+    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_STRING)
+        .getPrimitiveValue().toValue());
 
     URI esTwoKeyNavEntityManyOneURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
         .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
 
     final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
     esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
 
-    assertEquals(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyOneResponse.getBody().getProperty(
-        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    
+    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
+    ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
 
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
     composedKey.clear();
-    composedKey.put(PROPERTY_INT16, secondTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, secondTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
-        .toValue());
+    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_STRING)
+        .getPrimitiveValue().toValue());
 
     URI esTwoKeyNavEntityManyTwoURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
         .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
 
     final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
     esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
 
-    assertEquals(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyTwoResponse.getBody().getProperty(
-        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
+    
+    nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
   }
 
   @Test
-  public void deepInsertSameEntitySet() throws EdmPrimitiveTypeException {
-    final URI createURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+  public void deepInsertSameEntitySet() throws Exception {
+    final ODataClient client = getEdmEnabledClient();
+    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
     final ClientObjectFactory factory = getFactory();
     final ClientEntity entity = factory.newEntity(ET_KEY_NAV);
 
     // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            42)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42)));
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_NAV_FIVE_PROP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 42)))));
-
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM, factory.newComplexValue(CT_ALL_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM,
+            factory.newComplexValue(CT_ALL_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    42)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 42)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("42")))
-            .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-                    .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))
+                .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+                    factory.newComplexValue(CT_NAV_FIVE_PROP)
+                        .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                             factory.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
     entity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
-            getClient().newURIBuilder(SERVICE_URI)
-                    .appendEntitySetSegment(ES_TWO_KEY_NAV)
-                    .appendKeySegment(new LinkedHashMap<String, Object>() {
-                      private static final long serialVersionUID = 1L;
-
-                      {
-                        put(PROPERTY_INT16, 1);
-                        put(PROPERTY_STRING, "1");
-                      }
-                    })
-                    .build()));
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(
+            new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+              {
+                put(PROPERTY_INT16, 1);
+                put(PROPERTY_STRING, "1");
+              }
+            }).build()));
 
     // Prepare inline entity(EntitySet: ESKeyNav, Type: ETKeyNav)
     final ClientEntity innerEntity = factory.newEntity(ET_KEY_NAV);
     innerEntity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            43)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43)));
     innerEntity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
     innerEntity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_NAV_FIVE_PROP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 431)))));
     innerEntity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM, factory.newComplexValue(CT_ALL_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("431"))
-            )));
+        .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM,
+            factory.newComplexValue(CT_ALL_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("431")))));
+    innerEntity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 431)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("431")))));
     innerEntity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    431)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("431"))
-            )));
-    innerEntity
-    .getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("431")))
-            .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-                    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder()
-                            .buildInt16((short) 431)))))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("431")))
+                .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+                    factory.newComplexValue(CT_NAV_FIVE_PROP)
+                        .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                            factory.newPrimitiveValueBuilder().buildInt16((short) 431)))))));
     innerEntity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
-            getClient().newURIBuilder(SERVICE_URI)
-                    .appendEntitySetSegment(ES_TWO_KEY_NAV)
-                    .appendKeySegment(new LinkedHashMap<String, Object>() {
-                      private static final long serialVersionUID = 1L;
-
-                      {
-                        put(PROPERTY_INT16, 1);
-                        put(PROPERTY_STRING, "1");
-                      }
-                    })
-                    .build()));
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(
+            new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+              {
+                put(PROPERTY_INT16, 1);
+                put(PROPERTY_STRING, "1");
+              }
+            }).build()));
 
     ClientInlineEntity inlineEntity = factory.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
     entity.addLink(inlineEntity);
 
     final ODataEntityCreateResponse<ClientEntity> responseCreate =
-        getClient().getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
+        client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
     final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
     final Short esKeyNavEntityKey =
         responseCreate.getBody().getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
 
     // Fetch Entity
     URI fetchEntityURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(esKeyNavEntityKey)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(esKeyNavEntityKey)
         .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
 
     ODataEntityRequest<ClientEntity> entityRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
+        client.getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
     entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
 
+    ClientEntity clientEntity = entityResponse.getBody();
+    ClientInlineEntity navOne =
+        (ClientInlineEntity) clientEntity.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
+
     // Check values
-    assertEquals(431, entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(
-        PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
+        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
-    Short innerEntityInt16Key =
-        entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16)
-        .getPrimitiveValue().toCastValue(Short.class);
+    Short innerEntityInt16Key = navOne.getEntity().getProperty(PROPERTY_INT16).getPrimitiveValue()
+        .toCastValue(Short.class);
 
     final URI innerEntityURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(innerEntityInt16Key)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(innerEntityInt16Key)
         .build();
     final ODataEntityRequest<ClientEntity> innerRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(innerEntityURI);
+        client.getRetrieveRequestFactory().getEntityRequest(innerEntityURI);
     innerRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     ODataRetrieveResponse<ClientEntity> innerResponse = innerRequest.execute();
 
-    assertEquals(431, innerResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16)
+    assertShortOrInt(431, innerResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16)
         .getPrimitiveValue().toValue());
   }
 
   @Test
-  public void consistency() throws EdmPrimitiveTypeException {
+  public void consistency() throws Exception {
+    final EdmEnabledODataClient client = getEdmEnabledClient();
+    final ClientObjectFactory factory = getFactory();
     final String cookie = getCookie();
 
     // Do not set PropertyString(Nullable=false)
-    final ClientEntity entity = getFactory().newEntity(ET_KEY_NAV);
+    final ClientEntity entity = factory.newEntity(ET_KEY_NAV);
     entity.getProperties().add(
-        getFactory().newCollectionProperty(COL_PROPERTY_STRING,
-            getFactory().newCollectionValue(EDM_STRING).add(
-                getFactory().newPrimitiveValueBuilder().buildString("Test"))));
+        factory.newCollectionProperty(COL_PROPERTY_STRING,
+            factory.newCollectionValue(EDM_STRING).add(
+                factory.newPrimitiveValueBuilder().buildString("Test"))));
 
-    final URI targetURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
 
     try {
-      ODataEntityCreateRequest<ClientEntity> request = getEdmEnabledClient().getCUDRequestFactory()
+      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
           .getEntityCreateRequest(targetURI, entity);
       request.addCustomHeader(HttpHeader.COOKIE, cookie);
       request.execute();
@@ -623,20 +670,21 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
   }
 
   @Test
-  public void invalidType() throws EdmPrimitiveTypeException {
+  public void invalidType() throws Exception {
+    final EdmEnabledODataClient client = getEdmEnabledClient();
+    final ClientObjectFactory factory = getFactory();
     final String cookie = getCookie();
 
-    final ClientEntity entity = getFactory().newEntity(ET_KEY_NAV);
-    entity.getProperties().add(getFactory().newPrimitiveProperty(PROPERTY_STRING,
-        getFactory().newPrimitiveValueBuilder().buildInt32(1)));
-    final URI targetURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+    final ClientEntity entity = factory.newEntity(ET_KEY_NAV);
+    entity.getProperties().add(factory.newPrimitiveProperty(PROPERTY_STRING, 
+        factory.newPrimitiveValueBuilder().buildInt32(1)));
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
 
     try {
-      ODataEntityCreateRequest<ClientEntity> request = getEdmEnabledClient().getCUDRequestFactory()
+      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
           .getEntityCreateRequest(targetURI, entity);
       request.addCustomHeader(HttpHeader.COOKIE, cookie);
       request.execute();
-      fail("Expecting bad request");
     } catch (ODataClientErrorException e) {
       assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
     }
@@ -644,16 +692,15 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
 
     entity.getProperties().add(
-        getFactory().newCollectionProperty(PROPERTY_STRING,
-            getFactory().newCollectionValue(EDM_STRING).add(
-                getFactory().newPrimitiveValueBuilder().buildString("Test"))));
+        factory.newCollectionProperty(PROPERTY_STRING,
+            factory.newCollectionValue(EDM_STRING).add(
+                factory.newPrimitiveValueBuilder().buildString("Test"))));
 
     try {
-      ODataEntityCreateRequest<ClientEntity> request = getEdmEnabledClient().getCUDRequestFactory()
+      ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
           .getEntityCreateRequest(targetURI, entity);
       request.addCustomHeader(HttpHeader.COOKIE, cookie);
       request.execute();
-      fail("Expecting bad request");
     } catch (ODataClientErrorException e) {
       assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
     }
@@ -664,40 +711,45 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
   @Test
   @Ignore
   public void deepInsertOnNavigationPropertyInComplexProperty() {
-    final ClientEntity inlineEntity = getFactory().newEntity(ET_TWO_KEY_NAV);
-    inlineEntity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP, getFactory().newComplexValue(CT_PRIM_COMP)));
-    inlineEntity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP_NAV, getFactory().newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-    inlineEntity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP_TWO_PRIM, getFactory().newComplexValue(CT_TWO_PRIM)
-            .add(getFactory().newPrimitiveProperty(PROPERTY_INT16,
-                getFactory().newPrimitiveValueBuilder().buildInt16((short) 1)))
-            .add(getFactory().newPrimitiveProperty(PROPERTY_STRING,
-                getFactory().newPrimitiveValueBuilder().buildString("1")))));
-
-    final ClientEntity entity = getFactory().newEntity(ET_TWO_KEY_NAV);
-    entity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP, getFactory().newComplexValue(CT_PRIM_COMP)));
-    entity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP_NAV, getFactory().newComplexValue(CT_BASE_PRIM_COMP_NAV)));
-    entity.getProperties().add(
-        getFactory().newComplexProperty(PROPERTY_COMP_TWO_PRIM, getFactory().newComplexValue(CT_TWO_PRIM)
-            .add(getFactory().newPrimitiveProperty(PROPERTY_INT16,
-                getFactory().newPrimitiveValueBuilder().buildInt16((short) 2)))
-            .add(getFactory().newPrimitiveProperty(PROPERTY_STRING,
-                getFactory().newPrimitiveValueBuilder().buildString("2")))));
-
-    final ClientLink link = getFactory().newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
-    final ClientComplexValue complexValueCreate = getFactory().newComplexValue(CT_NAV_FIVE_PROP);
+    final EdmEnabledODataClient client = getEdmEnabledClient();
+    final ClientObjectFactory factory = getFactory();
+
+    final ClientEntity inlineEntity = factory.newEntity(ET_TWO_KEY_NAV);
+    inlineEntity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
+    inlineEntity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    inlineEntity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 1)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("1")))));
+
+    final ClientEntity entity = factory.newEntity(ET_TWO_KEY_NAV);
+    entity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)));
+    entity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    entity.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 2)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("2")))));
+
+    final ClientLink link = factory.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
+    final ClientComplexValue complexValueCreate = factory.newComplexValue(CT_NAV_FIVE_PROP);
     complexValueCreate.getNavigationLinks().add(link);
 
-    entity.getProperties().add(
-        getFactory().newCollectionProperty(COL_PROPERTY_COMP_NAV, getFactory().newCollectionValue(CT_NAV_FIVE_PROP)
-            .add(complexValueCreate)));
+    entity.getProperties()
+        .add(factory.newCollectionProperty(COL_PROPERTY_COMP_NAV,
+            factory.newCollectionValue(CT_NAV_FIVE_PROP).add(complexValueCreate)));
 
-    final URI targetURI = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
-    final ODataEntityCreateResponse<ClientEntity> response = getEdmEnabledClient().getCUDRequestFactory()
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
+    final ODataEntityCreateResponse<ClientEntity> response = client.getCUDRequestFactory()
         .getEntityCreateRequest(targetURI, entity)
         .execute();
 
@@ -720,7 +772,8 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
 
   @Test
   public void deepUpsert() {
-    final URI updateURI = getClient().newURIBuilder(SERVICE_URI)
+    final ODataClient client = getEdmEnabledClient();
+    final URI updateURI = client.newURIBuilder(SERVICE_URI)
         .appendEntitySetSegment(ES_KEY_NAV)
         .appendKeySegment(815)
         .build();
@@ -729,51 +782,58 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
 
     // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            42)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42)));
     entity.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_NAV_FIVE_PROP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 42)))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM, factory.newComplexValue(CT_ALL_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM,
+            factory.newComplexValue(CT_ALL_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short)
-                    42)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 42)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))));
     entity.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("42")))
-            .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP)
-                    .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("42")))
+                .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+                    factory.newComplexValue(CT_NAV_FIVE_PROP)
+                        .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                             factory.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
 
     // Non collection navigation property
     // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
     final ClientEntity inlineEntitySingle = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntitySingle.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43)));
     inlineEntitySingle.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43")));
     inlineEntitySingle.getProperties().add(factory.newComplexProperty(PROPERTY_COMP,
-            factory.newComplexValue(CT_PRIM_COMP)
-                    .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                            factory.newPrimitiveValueBuilder().buildInt16((short) 43)))));
-    inlineEntitySingle.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
+        factory.newComplexValue(CT_PRIM_COMP)
             .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                factory.newPrimitiveValueBuilder().buildInt16((short) 43)))));
+    inlineEntitySingle.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 431)))));
     inlineEntitySingle.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short) 432)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 432)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
                     factory.newPrimitiveValueBuilder().buildString("432")))));
 
     // Collection navigation property
@@ -781,44 +841,51 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
     final ClientEntity inlineEntityCol1 = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntityCol1.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 44)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 44)));
     inlineEntityCol1.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("44")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("44")));
     inlineEntityCol1.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 441)))));
-    inlineEntityCol1.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)
+    inlineEntityCol1.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 441)))));
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 441)))));
     inlineEntityCol1.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short) 442)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("442"))
-            )));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 442)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("442")))));
 
     final ClientEntity inlineEntityCol2 = factory.newEntity(ET_TWO_KEY_NAV);
     inlineEntityCol2.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short)
-            45)));
+        .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+            factory.newPrimitiveValueBuilder().buildInt16((short) 45)));
     inlineEntityCol2.getProperties()
-    .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("45")));
+        .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+            factory.newPrimitiveValueBuilder().buildString("45")));
     inlineEntityCol2.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+        .add(factory.newComplexProperty(PROPERTY_COMP_NAV,
+            factory.newComplexValue(CT_PRIM_COMP)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
                     factory.newPrimitiveValueBuilder().buildInt16((short) 451)))));
-    inlineEntityCol2.getProperties().add(
-        factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP)
+    inlineEntityCol2.getProperties()
+        .add(factory.newComplexProperty(PROPERTY_COMP,
+            factory.newComplexValue(CT_PRIM_COMP)
                 .add(factory.newPrimitiveProperty(PROPERTY_INT16,
-                        factory.newPrimitiveValueBuilder().buildInt16((short) 451)))));
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 451)))));
     inlineEntityCol2.getProperties()
-    .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM)
-            .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16
-                    ((short) 452)))
-            .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder()
-                    .buildString("452")))));
+        .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM,
+            factory.newComplexValue(CT_TWO_PRIM)
+                .add(factory.newPrimitiveProperty(PROPERTY_INT16,
+                    factory.newPrimitiveValueBuilder().buildInt16((short) 452)))
+                .add(factory.newPrimitiveProperty(PROPERTY_STRING,
+                    factory.newPrimitiveValueBuilder().buildString("452")))));
 
     final ClientInlineEntity newDeepInsertEntityLink =
         factory.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
@@ -832,7 +899,7 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     entity.addLink(newDeepInsertEntitySetLink);
 
     // Perform update request (upsert)
-    final ODataEntityUpdateResponse<ClientEntity> responseCreate = getClient().getCUDRequestFactory()
+    final ODataEntityUpdateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
         .getEntityUpdateRequest(updateURI, UpdateType.PATCH, entity)
         .execute();
     assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
@@ -842,109 +909,115 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
     ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
     final URI esKeyNavURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
             propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
                 NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
 
-    final ODataEntityRequest<ClientEntity> esKeyNavRequest = getClient().getRetrieveRequestFactory()
+    final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
         .getEntityRequest(esKeyNavURI);
     esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
 
     // Check nav. property NavPropertyETTwoKeyNavOne
-    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
-    assertEquals(431, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).getComplexValue().get(
-        PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
+    ClientInlineEntity navOne = (ClientInlineEntity)esKeyNavResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
+    assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
+        .get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Check nav. property NavPropertyETTwoKeyNavMany
-    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
-    assertEquals(2, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue()
-        .size());
-    Iterator<ClientValue> twoKeyNavManyIterator =
-        esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue().iterator();
-    final ClientValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
-    assertEquals(441, firstTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    final ClientValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
-    assertEquals(451, secondTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    ClientInlineEntitySet navMany = (ClientInlineEntitySet)esKeyNavResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
+    assertEquals(2, navMany.getEntitySet().getEntities().size());
+
+    assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV).getValue()
+        .asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    
+    assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV).getValue()
+        .asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
     Map<String, Object> composedKey = new HashMap<String, Object>();
-    composedKey.put(PROPERTY_INT16, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
-        .getComplexValue().get(PROPERTY_INT16)
+    composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16)
         .getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
-        .getComplexValue().get(PROPERTY_STRING)
+    composedKey.put(PROPERTY_STRING,  navOne.getEntity().getProperty(PROPERTY_STRING)
         .getPrimitiveValue().toValue());
 
-    final URI esTwoKeyNavEntitySingleURI = getClient().newURIBuilder(SERVICE_URI)
+    final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
         .appendEntitySetSegment(ES_TWO_KEY_NAV)
         .appendKeySegment(composedKey)
         .build();
 
-    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = getClient().getRetrieveRequestFactory()
+    final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
         .getEntityRequest(esTwoKeyNavEntitySingleURI);
     esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
-    assertEquals(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
 
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
     composedKey.clear();
-    composedKey.put(PROPERTY_INT16, firstTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, firstTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
-        .toValue());
+    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0)
+        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(0)
+        .getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
 
     URI esTwoKeyNavEntityManyOneURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
         .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
 
     final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
     esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
 
-    assertEquals(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyOneResponse.getBody().getProperty(
-        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
+    ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE); 
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
 
     // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
     composedKey.clear();
-    composedKey.put(PROPERTY_INT16, secondTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-    composedKey.put(PROPERTY_STRING, secondTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
-        .toValue());
+    composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1)
+        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(1)
+        .getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
 
     URI esTwoKeyNavEntityManyTwoURI =
-        getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
         .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
 
     final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
-        getClient().getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
     esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
 
-    assertEquals(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
-        PROPERTY_INT16).getPrimitiveValue().toValue());
-    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
-    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyTwoResponse.getBody().getProperty(
-        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
-
+    assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
+    nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
+        .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(),nvLink.getEntity()
+        .getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
   }
 
   private String getCookie() {
-    final ODataRetrieveResponse<ClientEntitySet> response = getEdmEnabledClient().getRetrieveRequestFactory()
-        .getEntitySetRequest(getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
+    final EdmEnabledODataClient client = getEdmEnabledClient();
+    final ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
+        .getEntitySetRequest(client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
         .execute();
 
     return response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
   }
 
   private void validateSet(final URI uri, final String cookie, final short... keys) throws EdmPrimitiveTypeException {
-    final ODataEntitySetRequest<ClientEntitySet> request = getEdmEnabledClient().getRetrieveRequestFactory()
+    final EdmEnabledODataClient client = getEdmEnabledClient();
+    final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
         .getEntitySetRequest(uri);
     request.addCustomHeader(HttpHeader.COOKIE, cookie);
     final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
@@ -953,7 +1026,8 @@ public class DeepInsertITCase extends AbstractTecSvcITCase {
     assertEquals(3, response.getBody().getEntities().size());
 
     for (final ClientEntity responseEntity : response.getBody().getEntities()) {
-      short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
+      short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16)
+          .getPrimitiveValue().toCastValue(Short.class);
 
       boolean found = false;
       for (int i = 0; i < keys.length && !found; i++) {


[05/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
index ff350a0..12ee6af 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
@@ -19,184 +19,190 @@
 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;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Parameter;
+import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmParameter;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlAction;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.core.edm.EdmActionImpl;
-import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.junit.Test;
-import org.mockito.Mockito;
 
 public class ODataJsonDeserializerActionParametersTest extends AbstractODataDeserializerTest {
 
   @Test
   public void empty() throws Exception {
-    final String input = "{}";
-    final Map<String, Parameter> parameters = deserialize(input, "UART");
+    final Map<String, Parameter> parameters = deserialize("{}", "UART", null);
     assertNotNull(parameters);
     assertTrue(parameters.isEmpty());
   }
 
   @Test
   public void primitive() throws Exception {
-    final String input = "{\"ParameterDuration\":\"P42DT11H22M33S\",\"ParameterInt16\":42}";
-    final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam");
+    final Map<String, Parameter> parameters = deserialize(
+        "{\"ParameterDuration\":\"P42DT11H22M33S\",\"ParameterInt16\":42}",
+        "UARTTwoParam", null);
     assertNotNull(parameters);
     assertEquals(2, parameters.size());
     Parameter parameter = parameters.get("ParameterInt16");
     assertNotNull(parameter);
+    assertTrue(parameter.isPrimitive());
+    assertFalse(parameter.isCollection());
     assertEquals((short) 42, parameter.getValue());
     parameter = parameters.get("ParameterDuration");
     assertNotNull(parameter);
     assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
   }
-  
+
+  @Test
+  public void primitiveCollection() throws Exception {
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(
+        OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration));
+    when(parameter.isCollection()).thenReturn(true);
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = "{\"Parameter\": [ \"PT0S\", \"PT42S\", \"PT1H2M3S\" ]}";
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isPrimitive());
+    assertTrue(parameterData.isCollection());
+    assertEquals(BigDecimal.ZERO, parameterData.asCollection().get(0));
+    assertEquals(BigDecimal.valueOf(42), parameterData.asCollection().get(1));
+    assertEquals(BigDecimal.valueOf(3723), parameterData.asCollection().get(2));
+  }
+
   @Test
   public void complex() throws Exception {
-    EdmProviderImpl provider = mock(EdmProviderImpl.class);
-    CsdlComplexType address = new CsdlComplexType();
-    address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"), 
-        createProperty("Zip", "Edm.Int32")));
-    address.setName("Address");
-    EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider, 
-        new FullQualifiedName("namespace.Address"), address);    
-    Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-    
-    List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
-    parameters.add(createParam("param1", "Edm.Int16"));
-    parameters.add(createParam("param2", "namespace.Address"));
-    parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
-    parameters.add(createParam("param4", "Edm.String").setNullable(true));
-    
-    FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
-    CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
-    EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-    
-    final String input = "{\n" + 
-        "  \"param1\": 42,\n" + 
-        "  \"param2\": {\n" + 
-        "    \"Street\": \"One Microsoft Way\",\n" + 
-        "    \"Zip\": 98052\n" + 
-        "  },\n" + 
-        "  \"param3\": [ 1, 42, 99 ],\n" + 
-        "  \"param4\": null\n" + 
-        "}";
-    final Map<String, Parameter> response = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-    
-    assertNotNull(response);
-    assertEquals(4, response.size());
-    Parameter parameter = response.get("param1");
-    assertNotNull(response);
-    assertEquals((short) 42, parameter.getValue());
-    parameter = response.get("param2");
-    assertNotNull(parameter);
-    ComplexValue addressValue = (ComplexValue)parameter.getValue();
-    assertEquals("Street", addressValue.getValue().get(0).getName());
-    assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals("Zip", addressValue.getValue().get(1).getName());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
-    
-    parameter = response.get("param3");
-    assertNotNull(parameter);
-    assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-    
-    parameter = response.get("param4");
-    assertNull(parameter.getValue());
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = "{\"Parameter\": { \"PropertyString\": \"Yes\", \"PropertyInt16\": 42 }}";
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    final Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isComplex());
+    assertFalse(parameterData.isCollection());
+    final List<Property> complexValues = parameterData.asComplex().getValue();
+    assertEquals((short) 42, complexValues.get(0).getValue());
+    assertEquals("Yes", complexValues.get(1).getValue());
   }
-  
+
   @Test
   public void complexCollection() throws Exception {
-    EdmProviderImpl provider = mock(EdmProviderImpl.class);
-    CsdlComplexType address = new CsdlComplexType();
-    address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"), 
-        createProperty("Zip", "Edm.Int32")));
-    address.setName("Address");
-    EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider, 
-        new FullQualifiedName("namespace.Address"), address);    
-    Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-    
-    List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
-    parameters.add(createParam("param1", "Edm.Int16"));
-    parameters.add(createParam("param2", "namespace.Address").setCollection(true));
-    parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
-    parameters.add(createParam("param4", "Edm.String").setNullable(true));
-    
-    FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
-    CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
-    EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-    
-    final String input = "{\n" + 
-        "  \"param1\": 42,\n" + 
-        "  \"param2\": [{\n" + 
-        "    \"Street\": \"One Microsoft Way\",\n" + 
-        "    \"Zip\": 98052\n" + 
-        "  },\n" +
-        "  {\n" + 
-        "    \"Street\": \"Two Microsoft Way\",\n" + 
-        "    \"Zip\": 98052\n" + 
-        "  }],\n" +         
-        "  \"param3\": [ 1, 42, 99 ],\n" + 
-        "  \"param4\": null\n" + 
-        "}";
-    final Map<String, Parameter> response = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-    
-    assertNotNull(response);
-    assertEquals(4, response.size());
-    Parameter parameter = response.get("param1");
-    assertNotNull(response);
-    assertEquals((short) 42, parameter.getValue());
-    parameter = response.get("param2");
-    assertNotNull(parameter);
-    ComplexValue addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(0);
-    assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
-
-    addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(1);
-    assertEquals("Two Microsoft Way", addressValue.getValue().get(0).getValue());
-    assertEquals(98052, addressValue.getValue().get(1).getValue());
-    
-    parameter = response.get("param3");
-    assertNotNull(parameter);
-    assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-    
-    parameter = response.get("param4");
-    assertNull(parameter.getValue());
-  }  
-
-  private CsdlParameter createParam(String name, String type) {
-    return new CsdlParameter().setName(name).setType(new FullQualifiedName(type));
-  }  
-
-  private CsdlProperty createProperty(String name, String type) {
-    return new CsdlProperty().setName(name).setType(type);
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+    when(parameter.isCollection()).thenReturn(true);
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = "{\"Parameter\": [\n"
+        + "  { \"PropertyInt16\": 9999, \"PropertyString\": \"One\" },\n"
+        + "  { \"PropertyInt16\": -123, \"PropertyString\": \"Two\" }]}";
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isComplex());
+    assertTrue(parameterData.isCollection());
+    ComplexValue complexValue = (ComplexValue) parameterData.asCollection().get(0);
+    assertEquals((short) 9999, complexValue.getValue().get(0).getValue());
+    assertEquals("One", complexValue.getValue().get(1).getValue());
+
+    complexValue = (ComplexValue) parameterData.asCollection().get(1);
+    assertEquals((short) -123, complexValue.getValue().get(0).getValue());
+    assertEquals("Two", complexValue.getValue().get(1).getValue());
   }
-  
+
+  @Test
+  public void entity() throws Exception {
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getEntityType(new FullQualifiedName(NAMESPACE, "ETTwoPrim")));
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = "{\"Parameter\": { \"PropertyInt16\": 42, \"PropertyString\": \"Yes\" }}";
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    final Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isEntity());
+    assertFalse(parameterData.isCollection());
+    final List<Property> entityValues = parameterData.asEntity().getProperties();
+    assertEquals((short) 42, entityValues.get(0).getValue());
+    assertEquals("Yes", entityValues.get(1).getValue());
+  }
+
+  @Test
+  public void entityCollection() throws Exception {
+    EdmParameter parameter = mock(EdmParameter.class);
+    when(parameter.getType()).thenReturn(edm.getEntityType(new FullQualifiedName(NAMESPACE, "ETTwoPrim")));
+    when(parameter.isCollection()).thenReturn(true);
+    EdmAction action = mock(EdmAction.class);
+    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+    when(action.getParameter("Parameter")).thenReturn(parameter);
+
+    final String input = "{\"Parameter\": [\n"
+        + "  { \"PropertyInt16\": 1234, \"PropertyString\": \"One\" },\n"
+        + "  { \"PropertyInt16\": -321, \"PropertyString\": \"Two\" }]}";
+    final Map<String, Parameter> parameters = deserialize(input, action);
+
+    assertNotNull(parameters);
+    assertEquals(1, parameters.size());
+    Parameter parameterData = parameters.get("Parameter");
+    assertNotNull(parameterData);
+    assertTrue(parameterData.isEntity());
+    assertTrue(parameterData.isCollection());
+    Entity entity = ((EntityCollection) parameterData.getValue()).getEntities().get(0);
+    assertEquals((short) 1234, entity.getProperties().get(0).getValue());
+    assertEquals("One", entity.getProperties().get(1).getValue());
+
+    entity = ((EntityCollection) parameterData.getValue()).getEntities().get(1);
+    assertEquals((short) -321, entity.getProperties().get(0).getValue());
+    assertEquals("Two", entity.getProperties().get(1).getValue());
+  }
+
   @Test
   public void boundEmpty() throws Exception {
-    final String input = "{}";
-    final Map<String, Parameter> parameters = deserialize(input, "BAETAllPrimRT", "ETAllPrim");
+    final Map<String, Parameter> parameters = deserialize("{}", "BAETAllPrimRT", "ETAllPrim");
     assertNotNull(parameters);
     assertTrue(parameters.isEmpty());
   }
@@ -206,7 +212,7 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
     final String input =
         "{\"ParameterDuration@odata.type\":\"Edm.Duration\","
             + "\"ParameterDuration\":\"P42DT11H22M33S\",\"ParameterInt16\":42}";
-    final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam");
+    final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam", null);
     assertNotNull(parameters);
     assertEquals(2, parameters.size());
     Parameter parameter = parameters.get("ParameterInt16");
@@ -218,9 +224,9 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
   }
   
   @Test
-  public void testParameterWithNullLiteral() throws Exception {
-    final Map<String, Parameter> parameters = deserialize("{\"ParameterInt16\":1,\"ParameterDuration\":null}", 
-        "UARTCollStringTwoParam");
+  public void parameterWithNullLiteral() throws Exception {
+    final Map<String, Parameter> parameters = deserialize("{\"ParameterInt16\":1,\"ParameterDuration\":null}",
+        "UARTCollStringTwoParam", null);
     assertNotNull(parameters);
     assertEquals(2, parameters.size());
     Parameter parameter = parameters.get("ParameterInt16");
@@ -231,52 +237,60 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
     assertEquals(null, parameter.getValue());
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void noContent() throws Exception {
-    deserialize("", "BAETAllPrimRT", "ETAllPrim");
+    expectException("", "UARTTwoParam", null, MessageKeys.JSON_SYNTAX_EXCEPTION);
+    expectException("", "BAETAllPrimRT", "ETAllPrim", MessageKeys.JSON_SYNTAX_EXCEPTION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindingParameter() throws Exception {
-    deserialize("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim");
-  }
-
-  @Test(expected = DeserializerException.class)
-  public void wrongName() throws Exception {
-    deserialize("{\"ParameterWrong\":null}", "UARTParam");
+    expectException("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim",
+        MessageKeys.UNKNOWN_CONTENT);
   }
 
-  @Test(expected = DeserializerException.class)
-  public void nullNotNullable() throws Exception {
-    deserialize("{\"ParameterInt16\":null}", "UARTCTTwoPrimParam");
-  }
-
-  @Test(expected = DeserializerException.class)
+  @Test
   public void missingParameter() throws Exception {
-    deserialize("{}", "UARTCTTwoPrimParam");
+    expectException("{\"ParameterWrong\":null}", "UARTParam", null, MessageKeys.UNKNOWN_CONTENT);
+    expectException("{}", "UARTCTTwoPrimParam", null, MessageKeys.INVALID_NULL_PARAMETER);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void parameterTwice() throws Exception {
-    deserialize("{\"ParameterInt16\":1,\"ParameterInt16\":2}", "UARTParam");
+    expectException("{\"ParameterInt16\":1,\"ParameterInt16\":2}", "UARTParam", null, MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongType() throws Exception {
-    deserialize("{\"ParameterInt16\":\"42\"}", "UARTParam");
+    expectException("{\"ParameterInt16\":null}", "UARTCTTwoPrimParam", null, MessageKeys.INVALID_NULL_PARAMETER);
+    expectException("{\"ParameterInt16\":\"42\"}", "UARTParam", null, MessageKeys.INVALID_VALUE_FOR_PROPERTY);
+    expectException("{\"ParameterInt16\":123456}", "UARTParam", null, MessageKeys.INVALID_VALUE_FOR_PROPERTY);
+    expectException("{\"ParameterInt16\":[42]}", "UARTParam", null, MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
-  
-  private Map<String, Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
-    return OData.newInstance().createDeserializer(CONTENT_TYPE_JSON)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()),
-            edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName))).getActionParameters();
+
+  private Map<String, Parameter> deserialize(final String input, final EdmAction action) throws DeserializerException {
+    return OData.newInstance().createDeserializer(ContentType.JSON)
+        .actionParameters(new ByteArrayInputStream(input.getBytes()), action)
+        .getActionParameters();
   }
 
-  private Map<String, Parameter> deserialize(final String input, final String actionName, final String typeName)
+  private Map<String, Parameter> deserialize(final String input, final String actionName, final String bindingTypeName)
       throws DeserializerException {
-    return OData.newInstance().createDeserializer(CONTENT_TYPE_JSON)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()),
-            edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName),
-                new FullQualifiedName("Namespace1_Alias", typeName), false)).getActionParameters();
+    return deserialize(input,
+        bindingTypeName == null ?
+            edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
+            edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
+                new FullQualifiedName(NAMESPACE, bindingTypeName),
+                false));
+  }
+
+  private void expectException(final String input, final String actionName, final String bindingTypeName,
+      final DeserializerException.MessageKeys messageKey) {
+    try {
+      deserialize(input, actionName, bindingTypeName);
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
+      assertEquals(messageKey, e.getMessageKey());
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/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 02a461d..f3899d1 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
@@ -31,7 +31,6 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -45,25 +44,24 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.provider.CsdlMapping;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.junit.Test;
 
 public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTest {
 
+  private static final ContentType CONTENT_TYPE_JSON_IEEE754Compatible =
+      ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true");
+
   @Test
   public void emptyEntity() throws Exception {
-    String entityString = "{}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final String entityString = "{}";
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -89,11 +87,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -136,11 +130,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -157,11 +147,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"" +
             "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -187,11 +173,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -222,11 +204,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         "\"PropertyInt64\":9223372036854775807," +
         "\"PropertySByte\":127," +
         "\"PropertyTimeOfDay\":\"01:00:01\"}}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETCompAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -264,17 +242,13 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "\"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(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETCollAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
     assertEquals(17, properties.size());
 
-    // All properties need 3 entires
+    // All properties need 3 entries.
     for (Property prop : properties) {
       if (!prop.getName().equals("PropertyInt16")) {
         assertEquals(ValueType.COLLECTION_PRIMITIVE, prop.getValueType());
@@ -301,12 +275,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -327,19 +296,14 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   }
 
   @Test
-  public void eTMixPrimCollCompMIssingPropertyInComplexType() throws Exception {
+  public void eTMixPrimCollCompMissingPropertyInComplexType() throws Exception {
     final String entityString = "{"
         + "\"PropertyComp\":{\"PropertyInt16\":111},"
         + "\"CollPropertyComp\":["
         + "{\"PropertyInt16\":123},"
         + "{\"PropertyInt16\":456},"
         + "{\"PropertyInt16\":789}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -384,11 +348,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
   }
 
@@ -402,9 +362,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             + "\"Association@odata.associationLink\":\"test\","
             + "\"PropertyString\":\"First Resource - positive values\""
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+    deserialize(entityString, "ETAllPrim");
   }
 
   @Test
@@ -420,10 +378,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":456,\"Navigation@odata.navigationLink\": 12," +
         "\"Association@odata.associationLink\": 12,\"PropertyString@odata.type\": 12,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+    deserialize(entityString, "ETMixPrimCollComp");
   }
 
   @Test
@@ -442,11 +397,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             + "\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\""
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -461,11 +412,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             + "\"NavPropertyETTwoPrimOne@odata.bind\":\"ESTwoPrim(2)\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":[\"ESTwoPrim(2)\",\"ESTwoPrim(3)\"]"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     assertNotNull(entity);
 
     Link bindingToOne = entity.getNavigationBinding("NavPropertyETTwoPrimOne");
@@ -495,11 +442,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":[]"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
-            .getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim");
     Link bindingToMany = entity.getNavigationBinding("NavPropertyETTwoPrimMany");
     assertNotNull(bindingToMany);
     assertTrue(bindingToMany.getBindingLinks().isEmpty());
@@ -508,11 +451,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
   @Test
   public void eTMixEnumDefCollCompTest() throws Exception {
     InputStream stream = getFileAsStream("EntityETMixEnumDefCollComp.json");
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, edm
-            .getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")))
-            .getEntity();
+    final Entity entity = deserialize(stream, "ETMixEnumDefCollComp", ContentType.JSON);
 
     assertEquals(6, entity.getProperties().size());
 
@@ -554,14 +493,10 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "\"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(CONTENT_TYPE_JSON);
-    Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim"))).getEntity();
-
-    assertTrue((Boolean) e.getProperty("CollPropertyBoolean").asCollection().get(0));
-    assertNull(e.getProperty("CollPropertyBoolean").asCollection().get(1));
-    assertFalse((Boolean) e.getProperty("CollPropertyBoolean").asCollection().get(2));
+    final Entity entity = deserialize(entityString, "ETCollAllPrim");
+    assertTrue((Boolean) entity.getProperty("CollPropertyBoolean").asCollection().get(0));
+    assertNull(entity.getProperty("CollPropertyBoolean").asCollection().get(1));
+    assertFalse((Boolean) entity.getProperty("CollPropertyBoolean").asCollection().get(2));
   }
 
   @Test
@@ -569,11 +504,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     final String entityString = "{"
         + "\"PropertyComp\":null"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity = deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias",
-        "ETMixPrimCollComp"))).getEntity();
-
+    final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
     assertNull(entity.getProperty("PropertyComp").getValue());
   }
 
@@ -583,11 +514,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "\"CollPropertyComp\":["
         + "null,"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-
-    Entity entity = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp"))).getEntity();
+    final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
     List<?> collPropertyComp = entity.getProperty("CollPropertyComp").asCollection();
     assertNull(collPropertyComp.get(0));
     List<Property> complexPropertyProperties = ((ComplexValue) collPropertyComp.get(1)).getValue();
@@ -600,11 +527,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     final String entityString = "{"
         + "\"PropertyComp\":{\"PropertyString\":\"TEST A\",\"PropertyInt16\":null}"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim"))).getEntity();
-
+    final Entity entity = deserialize(entityString, "ETCompAllPrim");
     assertEquals("TEST A", entity.getProperty("PropertyComp").asComplex().getValue().get(0).getValue());
     assertNull(entity.getProperty("PropertyComp").asComplex().getValue().get(1).getValue());
   }
@@ -616,14 +539,9 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "\"PropertyCompMixedEnumDef\" : {"
         + "\"PropertyEnumString\" : null"
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp"))).getEntity();
-
-    assertEquals((short) 2, e.getProperty("PropertyEnumString").getValue());
-    Property propertyCompMixedEnumDef = e.getProperty("PropertyCompMixedEnumDef");
+    final Entity entity = deserialize(entityString, "ETMixEnumDefCollComp");
+    assertEquals((short) 2, entity.getProperty("PropertyEnumString").getValue());
+    Property propertyCompMixedEnumDef = entity.getProperty("PropertyCompMixedEnumDef");
     assertNull(propertyCompMixedEnumDef.asComplex().getValue().get(0).getValue());
   }
 
@@ -632,20 +550,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     String entityString = "{"
         + "\"PropertyEnumString\" : \"String1,String2\""
         + "}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp"))).getEntity();
-
-    assertEquals((short) 3, e.getProperty("PropertyEnumString").getValue());
+    final Entity entity = deserialize(entityString, "ETMixEnumDefCollComp");
+    assertEquals((short) 3, entity.getProperty("PropertyEnumString").getValue());
   }
 
   @Test
   public void mappingTest() throws Exception {
-    OData.newInstance().createServiceMetadata(new EdmTechProvider(), Collections.<EdmxReference> emptyList())
-        .getEdm();
-
     EdmEntityType entityType = mock(EdmEntityType.class);
     when(entityType.getFullQualifiedName()).thenReturn(new FullQualifiedName("napespace", "name"));
     List<String> propertyNames = new ArrayList<String>();
@@ -670,9 +580,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         "{\"PropertyDate\":\"2012-12-03\","
             + "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"}";
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    Entity entity =
-        deserializer.entity(stream, entityType).getEntity();
+    ODataDeserializer deserializer = OData.newInstance().createDeserializer(ContentType.JSON);
+    Entity entity = deserializer.entity(stream, entityType).getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -686,14 +595,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
   // ---------------------------------- Negative Tests -----------------------------------------------------------
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void emptyInput() throws Exception {
-    OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(
-        new ByteArrayInputStream(new byte[] {}),
-        edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+    expectException("", "ETAllPrim", DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void etAllPrimWithInvalidNullValue() throws Exception {
     String entityString =
         "{\"PropertyInt16\":null," +
@@ -712,32 +619,19 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void doublePrimitiveProperty() throws Exception {
     final String entityString = "{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\"," +
         "\"PropertyInt16\":32766,\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.DUPLICATE_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETTwoPrim",
+        DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void doubleComplexProperty() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -749,18 +643,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.DUPLICATE_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void doubleComplexPropertyCollection() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -776,18 +663,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]"
         + "}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.DUPLICATE_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void doublePrimitivePropertyCollection() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -800,18 +680,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.DUPLICATE_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void customAnnotationInEntityLeadToNotImplemented() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -823,18 +696,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void customAnnotationInComplexValueLeadToNotImplemented() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -846,18 +712,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void customAnnotationInComplexCollectionValueLeadToNotImplemented() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -868,18 +727,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"CollPropertyString@custom.annotation\": 12,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void unkownContentInEntity() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -891,18 +743,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.UNKNOWN_CONTENT, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.UNKNOWN_CONTENT);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void unkownContentInComplexProperty() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -913,18 +758,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.UNKNOWN_CONTENT, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.UNKNOWN_CONTENT);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void unkownContentInComplexCollectionProperty() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767,"
@@ -935,15 +773,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
         + "{\"PropertyInt16\":456,\"unknown\": 12,\"PropertyString\":\"TEST 2\"},"
         + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    try {
-      ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.UNKNOWN_CONTENT, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.UNKNOWN_CONTENT);
   }
 
   @Test
@@ -1042,386 +873,241 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     checkPropertyJsonType("{\"PropertyTimeOfDay\":true}");
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindOperationWrongJsonTypeForToOne() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimOne@odata.bind\":[\"ESTwoPrim(2)\"]"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindOperationWrongJsonTypeForToMany() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":\"ESTwoPrim(2)\""
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindOperationWrongJsonTypeForToManyNumberInArray() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":[123,456]"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindOperationWrongAnnotationFormat() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"@odata.bind\":\"ESTwoPrim(2)\""
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NAVIGATION_PROPERTY_NOT_FOUND, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.NAVIGATION_PROPERTY_NOT_FOUND);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindingOperationNullOnToOne() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimOne@odata.bind\":null"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindingOperationNullOnToMany() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":null"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void bindingOperationNullInArray() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimMany@odata.bind\":[null]"
             + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonSyntax() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonValueForPrimTypeArray() throws Exception {
     String entityString =
         "{\"PropertyInt16\":[]}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonValueForPrimTypeObject() throws Exception {
     String entityString =
         "{\"PropertyInt16\":{}}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonValueForPrimCollectionTypeObject() throws Exception {
     final String entityString = "{"
         + "\"CollPropertyString\":"
         + "{\"Employee1@company.example\":1234}"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_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;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonValueForComplexTypeTypeString() throws Exception {
     final String entityString = "{"
         + "\"PropertyComp\":\"InvalidString\""
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_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;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidNullValueForComplexTypeNullableFalse() throws Exception {
     final String entityString = "{"
         + "\"PropertyComp\":null"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoKeyNav")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETTwoKeyNav",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidNullValueForPrimBeforeComplexTypeNullableFalse() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\": null, \"PropertyString\": \"321\", "
         + "\"PropertyComp\":{\"PropertyInt16\": null, "
         + "\"PropertyComp\": {\"PropertyString\":\"StringValue\"}}"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoKeyNav")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETTwoKeyNav",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidNullValueForComplexTypePropertyNullableFalse() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\": 123, "
         + "\"PropertyCompTwoPrim\":{\"PropertyInt16\": null, \"PropertyString\":\"StringValue\"}"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETKeyNav")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETKeyNav",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidNullValueForPrimCollectionNullableFalse() throws Exception {
     final String entityString = "{"
         + "\"CollPropertyString\":["
         + "null,"
         + "\"StringValue_1\",\"TEST 3\"]}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETCollAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidNullValueForPrimIntCollectionNullableFalse() throws Exception {
     final String entityString = "{"
         + "\"CollPropertyInt16\":[123,\"null\",4711]"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETCollAllPrim",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void provokedPrimitiveTypeException() throws Exception {
     final String entityString = "{"
         + "\"PropertyInt16\":32767000000000000000000000000000000000000"
         + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixPrimCollComp",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void eTMixEnumDefCollCompInvalidEnumValueNull() throws Exception {
     String entityString = "{"
         + "\"PropertyEnumString\" : null,"
         + "\"PropertyCompMixedEnumDef\" : {"
         + "\"PropertyEnumString\" : \"2\""
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_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;
-    }
+    expectException(entityString, "ETMixEnumDefCollComp",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void eTMixEnumDefCollCompInvalidEnumValueArray() throws Exception {
     String entityString = "{"
         + "\"PropertyEnumString\" : [],"
         + "\"PropertyCompEnum\" : {"
         + "\"PropertyEnumString\" : \"2\""
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixEnumDefCollComp",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void eTMixEnumDefCollCompInvalidEnumValueObject() throws Exception {
     String entityString = "{"
         + "\"PropertyEnumString\" : {},"
         + "\"PropertyCompEnum\" : {"
         + "\"PropertyEnumString\" : \"2\""
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixEnumDefCollComp",
+        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void eTMixEnumDefCollCompInvalidEnumValue() throws Exception {
     String entityString = "{"
         + "\"PropertyEnumString\" : \"invalid\","
         + "\"PropertyCompEnum\" : {"
         + "\"PropertyEnumString\" : \"2\""
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixEnumDefCollComp",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void eTMixEnumDefCollCompInvalidEnumValueByPrimitiveTypeException() throws Exception {
     String entityString = "{"
         + "\"PropertyEnumString\" : \"18\","
         + "\"PropertyCompEnum\" : {"
         + "\"PropertyEnumString\" : \"2\""
         + "}}";
-
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
-    try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(entityString, "ETMixEnumDefCollComp",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
   @Test
   public void ieee754Compatible() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON_IEEE754Compatible);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1439,10 +1125,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    final Entity entity = deserializer
-        .entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim", CONTENT_TYPE_JSON_IEEE754Compatible);
 
     assertEquals(9223372036854775807L, entity.getProperty("PropertyInt64").asPrimitive());
     assertEquals(BigDecimal.valueOf(34), entity.getProperty("PropertyDecimal").asPrimitive());
@@ -1450,7 +1133,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
   @Test
   public void ieee754CompatibleNull() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON_IEEE754Compatible);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1468,18 +1150,14 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    final Entity entity = deserializer
-        .entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+    final Entity entity = deserialize(entityString, "ETAllPrim", CONTENT_TYPE_JSON_IEEE754Compatible);
 
     assertTrue(entity.getProperty("PropertyInt64").isNull());
     assertTrue(entity.getProperty("PropertyDecimal").isNull());
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void ieee754CompatibleEmptyString() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON_IEEE754Compatible);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1497,14 +1175,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+    expectException(entityString, "ETAllPrim", CONTENT_TYPE_JSON_IEEE754Compatible,
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void ieee754CompatibleNullAsString() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON_IEEE754Compatible);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1522,14 +1198,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+    expectException(entityString, "ETAllPrim", CONTENT_TYPE_JSON_IEEE754Compatible,
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void ieee754CompatibleAsNumber() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON_IEEE754Compatible);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1547,14 +1221,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
-
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+    expectException(entityString, "ETAllPrim", CONTENT_TYPE_JSON_IEEE754Compatible,
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void ieee754NotCompatibleAsString() throws Exception {
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
     String entityString =
         "{\"PropertyInt16\":32767," +
             "\"PropertyString\":\"First Resource - positive values\"," +
@@ -1572,19 +1244,43 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
             "\"PropertyDuration\":\"PT6S\"," +
             "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
             "\"PropertyTimeOfDay\":\"03:26:05\"}";
+    expectException(entityString, "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
+  }
 
-    final InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"))).getEntity();
+  protected static Entity deserialize(final InputStream stream, final String entityTypeName,
+      final ContentType contentType) throws DeserializerException {
+    return OData.newInstance().createDeserializer(contentType)
+        .entity(stream, edm.getEntityType(new FullQualifiedName(NAMESPACE, entityTypeName)))
+        .getEntity();
   }
 
-  private void checkPropertyJsonType(final String entityString) throws DeserializerException {
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    ODataDeserializer deserializer = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON);
+  private static Entity deserialize(final String entityString, final String entityTypeName,
+      final ContentType contentType) throws DeserializerException {
+    return deserialize(new ByteArrayInputStream(entityString.getBytes()), entityTypeName, contentType);
+  }
+
+  protected static Entity deserialize(final String entityString, final String entityTypeName)
+      throws DeserializerException {
+    return deserialize(entityString, entityTypeName, ContentType.JSON);
+  }
+
+  private static void checkPropertyJsonType(final String entityString) throws DeserializerException {
+    expectException(entityString, "ETAllPrim", DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
+  }
+
+  protected static void expectException(final String entityString, final String entityTypeName,
+      final DeserializerException.MessageKeys messageKey) {
+    expectException(entityString, entityTypeName, ContentType.JSON, messageKey);
+  }
+
+  private static void expectException(final String entityString, final String entityTypeName,
+      final ContentType contentType, final DeserializerException.MessageKeys messageKey) {
     try {
-      deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
-      fail("Expected an exception but was not thrown: " + this.getClass().getName());
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, e.getMessageKey());
+      deserialize(entityString, entityTypeName, contentType);
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
+      assertEquals(messageKey, e.getMessageKey());
     }
   }
 }


[10/11] olingo-odata4 git commit: [OLINGO-789] more tests of server support for action parameters

Posted by mi...@apache.org.
[OLINGO-789] more tests of server support for action parameters

Signed-off-by: Michael Bolz <mi...@sap.com>


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

Branch: refs/heads/olingo786
Commit: b736c43495078a12a152b0b19a44242304b7e73f
Parents: d6db341
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Oct 2 16:16:19 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Oct 5 07:50:00 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/ActionImportITCase.java   |  26 +++
 .../deserializer/xml/ODataXmlDeserializer.java  |  67 +++----
 .../olingo/server/tecsvc/data/ActionData.java   |  15 ++
 .../server/tecsvc/provider/ActionProvider.java  |  99 ++++++----
 .../tecsvc/provider/ContainerProvider.java      |   7 +
 .../server/tecsvc/provider/SchemaProvider.java  |   1 +
 ...ataJsonDeserializerActionParametersTest.java | 192 +++++++++----------
 ...DataXMLDeserializerActionParametersTest.java | 187 +++++++++---------
 8 files changed, 316 insertions(+), 278 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index c21671b..bb17242 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -286,6 +286,32 @@ public class ActionImportITCase extends AbstractParamTecSvcITCase {
     assertEquals("UARTCollStringTwoParam duration value: null", iter.next().asPrimitive().toValue());
   }
 
+  @Test
+  public void allParameterKinds() {
+    Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
+    parameters.put("ParameterEnum", getFactory().newEnumValue(null, "String3"));
+    parameters.put("ParameterDef", getFactory().newPrimitiveValueBuilder().build());
+    parameters.put("ParameterComp", getFactory().newComplexValue(null)
+        .add(getFactory().newPrimitiveProperty("PropertyInt16",
+            getFactory().newPrimitiveValueBuilder().buildInt16((short) 3))));
+    parameters.put("ParameterETTwoPrim", getFactory().newComplexValue(null));
+    parameters.put("CollParameterByte", getFactory().newCollectionValue(null)
+        .add(getFactory().newPrimitiveValueBuilder().buildInt16((short) 10)));
+    parameters.put("CollParameterEnum", getFactory().newCollectionValue(null)
+        .add(getFactory().newEnumValue(null, "String1")));
+    parameters.put("CollParameterDef", getFactory().newCollectionValue(null)
+        .add(getFactory().newPrimitiveValueBuilder().setValue("CollDefString").build()));
+    parameters.put("CollParameterComp", getFactory().newCollectionValue(null)
+        .add(getFactory().newComplexValue(null)
+            .add(getFactory().newPrimitiveProperty("PropertyString",
+                getFactory().newPrimitiveValueBuilder().setValue("CollCompString").build()))));
+    parameters.put("CollParameterETTwoPrim", getFactory().newCollectionValue(null));
+    final ODataInvokeResponse<ClientProperty> response =
+        callAction("AIRTByteNineParam", ClientProperty.class, parameters, false);
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    assertEquals(6, response.getBody().getPrimitiveValue().toValue());
+  }
+
   private Map<String, ClientValue> buildParameterInt16(final int value) {
     return Collections.singletonMap("ParameterInt16",
         (ClientValue) getFactory().newPrimitiveValueBuilder().buildInt16((short) value));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
index 776868b..9fb08ab 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
@@ -54,6 +54,8 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 import org.apache.olingo.commons.core.edm.primitivetype.AbstractGeospatialType;
@@ -103,14 +105,15 @@ public class ODataXmlDeserializer implements ODataDeserializer {
           throw new DeserializerException("geo types support not implemented",
               DeserializerException.MessageKeys.NOT_IMPLEMENTED);
         }
+        final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type;
         final String stringValue = event.asCharacters().getData();
-        value = ((EdmPrimitiveType)type).valueOfString(stringValue, 
+        value = primitiveType.valueOfString(stringValue, 
             isNullable, 
             maxLength, 
             precision, 
             scale, 
             isUnicode, 
-            ((EdmPrimitiveType)type).getDefaultType());
+            primitiveType.getDefaultType());
       }
 
       if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -152,13 +155,13 @@ public class ODataXmlDeserializer implements ODataDeserializer {
       final XMLEvent event = reader.nextEvent();
 
       if (event.isStartElement()) {        
-        if (edmType instanceof SingletonPrimitiveType) {
+        if (edmType instanceof SingletonPrimitiveType
+            || edmType.getKind() == EdmTypeKind.ENUM
+            || edmType.getKind() == EdmTypeKind.DEFINITION) {
           values.add(primitive(reader, event.asStartElement(), type, isNullable, 
               maxLength, precision, scale, isUnicode));          
         } else if (edmType instanceof EdmComplexType) {
           values.add(complex(reader, event.asStartElement(), (EdmComplexType) edmType));                    
-        } else if (edmType instanceof EdmEnumType) {
-          values.add(readEnum(reader, event.asStartElement()));          
         }
         // do not add null or empty values
       }
@@ -170,21 +173,6 @@ public class ODataXmlDeserializer implements ODataDeserializer {
     valuable.setValue(getValueType(edmType, true), values);
   }
 
-  private Object readEnum(XMLEventReader reader, StartElement start) throws XMLStreamException {
-    boolean foundEndProperty = false;
-    Object value = null;
-    while (reader.hasNext() && !foundEndProperty) {
-      final XMLEvent event = reader.nextEvent();
-      if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        value = event.asCharacters().getData();
-      }
-      if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
-        foundEndProperty = true;
-      }
-    }
-    return value;
-  }
-
   private Property property(final XMLEventReader reader, final StartElement start, final EdmType edmType,
       final boolean isNullable, final Integer maxLength, final Integer precision,
       final Integer scale, final boolean isUnicode, final boolean isCollection)
@@ -212,11 +200,13 @@ public class ODataXmlDeserializer implements ODataDeserializer {
       return isCollection? ValueType.COLLECTION_COMPLEX:ValueType.COMPLEX;
     } else if (edmType instanceof EdmEnumType) {
       return isCollection?ValueType.COLLECTION_ENUM:ValueType.ENUM;
+    } else if (edmType instanceof EdmTypeDefinition) {
+      return isCollection?ValueType.COLLECTION_PRIMITIVE:ValueType.PRIMITIVE;
     } else {
       return ValueType.PRIMITIVE;
     }
   }
-  
+
   private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start,
       final EdmType edmType, final boolean isNullable, final Integer maxLength, final Integer precision,
       final Integer scale, final boolean isUnicode, final boolean isCollection) throws XMLStreamException,
@@ -236,22 +226,19 @@ public class ODataXmlDeserializer implements ODataDeserializer {
       return;
     }
 
+    final String typeName = edmType.getFullQualifiedName().getFullQualifiedNameAsString();
+    valuable.setType(isCollection ? ("Collection(" + typeName + ")") : typeName);
     if (isCollection) {
       collection(valuable, reader, start, edmType, isNullable, maxLength, precision, scale, isUnicode);
-      valuable.setType("Collection("+edmType.getFullQualifiedName().getFullQualifiedNameAsString()+")");
-    } else if (edmType instanceof SingletonPrimitiveType) {
-      valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
-      valuable.setValue(ValueType.PRIMITIVE, 
+    } else if (edmType instanceof SingletonPrimitiveType
+        || edmType.getKind() == EdmTypeKind.ENUM
+        || edmType.getKind() == EdmTypeKind.DEFINITION) {
+      valuable.setValue(getValueType(edmType, false),
           primitive(reader, start, edmType, isNullable, maxLength, precision, scale, isUnicode));          
     } else if (edmType instanceof EdmComplexType) {
       valuable.setValue(ValueType.COMPLEX, complex(reader, start, (EdmComplexType) edmType));
-      valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
-    } else if (edmType instanceof EdmEnumType) {
-      valuable.setValue(ValueType.ENUM, readEnum(reader, start));
-      valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
     } else if (edmType instanceof EdmEntityType) {
-      valuable.setValue(ValueType.ENTITY, entity(reader, start, (EdmEntityType)edmType));
-      valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
+      valuable.setValue(ValueType.ENTITY, entity(reader, start, (EdmEntityType) edmType));
     }
     // do not add null or empty values    
   }
@@ -791,12 +778,13 @@ public class ODataXmlDeserializer implements ODataDeserializer {
   private Parameter createParameter(XMLEventReader reader, StartElement start, String paramName, 
       EdmParameter edmParameter) throws DeserializerException, EdmPrimitiveTypeException, XMLStreamException {
     
+    Parameter parameter = new Parameter();
+    parameter.setName(paramName);
     switch (edmParameter.getType().getKind()) {
     case PRIMITIVE:
     case ENUM:
+    case DEFINITION:
     case COMPLEX:
-      Parameter parameter = new Parameter();
-      parameter.setName(paramName);
       Property property = property(reader, start, 
         edmParameter.getType(),
         edmParameter.isNullable(), 
@@ -806,14 +794,21 @@ public class ODataXmlDeserializer implements ODataDeserializer {
         true,
         edmParameter.isCollection());
       parameter.setValue(property.getValueType(), property.getValue());
-      return parameter;
+      break;
     case ENTITY:
-      throw new DeserializerException("Entity parameters are not allowed",
-          DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE);
+      if (edmParameter.isCollection()) {
+        final EntityCollection entityCollection = entitySet(reader, start, (EdmEntityType) edmParameter.getType());
+        parameter.setValue(ValueType.COLLECTION_ENTITY, entityCollection);
+      } else {
+        final Entity entity = entity(reader, start, (EdmEntityType) edmParameter.getType());
+        parameter.setValue(ValueType.ENTITY, entity);
+      }
+      break;
     default:
       throw new DeserializerException("Invalid type kind " + edmParameter.getType().getKind().toString()
           + " for action parameter: " + paramName, DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE,
           paramName);
     }
+    return parameter;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
index 2adf7c2..1169959 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
@@ -52,6 +52,21 @@ public class ActionData {
       throws DataProviderException {
     if ("UARTString".equals(name)) {
       return DataCreator.createPrimitive(null, "UARTString string value");
+    } else if ("UARTByteNineParam".equals(name)) {
+      short count = 0;  // counts non-empty parameters
+      for (final String parameterName : parameters.keySet()) {
+        final Parameter parameter = parameters.get(parameterName);
+        if (!(parameter.isNull()
+            || !parameter.isCollection()
+                && (parameter.isComplex() && parameter.asComplex().getValue().isEmpty()
+                    || parameter.isEntity() && ((Entity) parameter.getValue()).getProperties().isEmpty())
+            || parameter.isCollection()
+                && (parameter.isEntity() && ((EntityCollection) parameter.getValue()).getEntities().isEmpty()
+                    || parameter.asCollection().isEmpty()))) {
+          count++;
+        }
+      }
+      return DataCreator.createPrimitive(null, count);
     }
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java
index 2227315..c62b5d7 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java
@@ -77,6 +77,8 @@ public class ActionProvider {
       new FullQualifiedName(SchemaProvider.NAMESPACE, "UARTParam");
   public static final FullQualifiedName nameUARTTwoParam =
       new FullQualifiedName(SchemaProvider.NAMESPACE, "UARTTwoParam");
+  public static final FullQualifiedName nameUARTByteNineParam =
+      new FullQualifiedName(SchemaProvider.NAMESPACE, "UARTByteNineParam");
 
   public List<CsdlAction> getActions(final FullQualifiedName actionName) throws ODataException {
     if (actionName.equals(nameUARTString)) {
@@ -160,39 +162,56 @@ public class ActionProvider {
                   new CsdlParameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16),
                   new CsdlParameter().setName("ParameterDuration").setType(PropertyProvider.nameDuration))));
 
+    } else if (actionName.equals(nameUARTByteNineParam)) {
+      return Collections.singletonList(
+          new CsdlAction()
+              .setName(nameUARTByteNineParam.getName())
+              .setParameters(Arrays.asList(
+                  new CsdlParameter().setName("ParameterEnum").setType(EnumTypeProvider.nameENString),
+                  new CsdlParameter().setName("ParameterDef").setType(TypeDefinitionProvider.nameTDString),
+                  new CsdlParameter().setName("ParameterComp").setType(ComplexTypeProvider.nameCTTwoPrim),
+                  new CsdlParameter().setName("ParameterETTwoPrim").setType(EntityTypeProvider.nameETTwoPrim),
+                  new CsdlParameter().setName("CollParameterByte").setType(PropertyProvider.nameByte)
+                      .setCollection(true),
+                  new CsdlParameter().setName("CollParameterEnum").setType(EnumTypeProvider.nameENString)
+                      .setCollection(true),
+                  new CsdlParameter().setName("CollParameterDef").setType(TypeDefinitionProvider.nameTDString)
+                      .setCollection(true),
+                  new CsdlParameter().setName("CollParameterComp").setType(ComplexTypeProvider.nameCTTwoPrim)
+                      .setCollection(true),
+                  new CsdlParameter().setName("CollParameterETTwoPrim").setType(EntityTypeProvider.nameETTwoPrim)
+                      .setCollection(true)))
+              .setReturnType(new CsdlReturnType().setType(PropertyProvider.nameByte)));
+
     } else if (actionName.equals(nameBAETTwoKeyNavRTETTwoKeyNav)) {
       return Arrays.asList(
-          new CsdlAction().setName("BAETTwoKeyNavRTETTwoKeyNav")
-              .setParameters(Arrays.asList(
+          new CsdlAction().setName(nameBAETTwoKeyNavRTETTwoKeyNav.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
                       .setNullable(false)))
               .setBound(true)
-              .setReturnType(
-                  new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
-          ,
-          new CsdlAction().setName("BAETTwoKeyNavRTETTwoKeyNav")
-              .setParameters(Arrays.asList(
+              .setReturnType(new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)),
+
+          new CsdlAction().setName(nameBAETTwoKeyNavRTETTwoKeyNav.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETKeyNav").setType(EntityTypeProvider.nameETKeyNav)
                       .setNullable(false)))
               .setBound(true)
-              .setReturnType(
-                  new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
-          );
+              .setReturnType(new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)));
 
     } else if (actionName.equals(nameBAESAllPrimRTETAllPrim)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAESAllPrimRTETAllPrim")
-              .setParameters(Arrays.asList(
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAESAllPrimRTETAllPrim.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim)
                       .setCollection(true).setNullable(false)))
               .setBound(true)
-              .setReturnType(
-                  new CsdlReturnType().setType(EntityTypeProvider.nameETAllPrim)));
+              .setReturnType(new CsdlReturnType().setType(EntityTypeProvider.nameETAllPrim)));
 
     } else if (actionName.equals(nameBAESTwoKeyNavRTESTwoKeyNav)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAESTwoKeyNavRTESTwoKeyNav")
-              .setParameters(Arrays.asList(
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAESTwoKeyNavRTESTwoKeyNav.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
                       .setCollection(true).setNullable(false)))
               .setBound(true)
@@ -200,11 +219,11 @@ public class ActionProvider {
                   new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)));
 
     } else if (actionName.equals(nameBAESTwoKeyNavRTESKeyNav)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAESTwoKeyNavRTESKeyNav")
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAESTwoKeyNavRTESKeyNav.getName())
               .setBound(true)
               .setEntitySetPath("BindingParam/NavPropertyETKeyNavMany")
-              .setParameters(Arrays.asList(
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETTwoKeyNav")
                       .setType(EntityTypeProvider.nameETTwoKeyNav)
                       .setCollection(true)
@@ -213,46 +232,42 @@ public class ActionProvider {
                   new CsdlReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true)));
 
     } else if (actionName.equals(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
-              .setParameters(Arrays.asList(
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
                       .setNullable(false)))
               .setBound(true)
-              .setReturnType(
-                  new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)));
+              .setReturnType(new CsdlReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)));
 
     } else if (actionName.equals(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
-              .setParameters(Arrays.asList(
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav.getName())
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETTwoBaseTwoKeyNav")
                       .setType(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
                       .setNullable(false)))
               .setBound(true)
-              .setReturnType(
-                  new CsdlReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav)));
+              .setReturnType(new CsdlReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav)));
 
     } else if (actionName.equals(nameBAETAllPrimRT)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAETAllPrimRT")
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAETAllPrimRT.getName())
               .setBound(true)
-              .setParameters(Arrays.asList(
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETAllPrim")
                       .setNullable(false)
-                      .setType(EntityTypeProvider.nameETAllPrim)
-                  )));
+                      .setType(EntityTypeProvider.nameETAllPrim))));
+
     } else if (actionName.equals(nameBAESAllPrimRT)) {
-      return Arrays.asList(
-          new CsdlAction().setName("BAESAllPrimRT")
+      return Collections.singletonList(
+          new CsdlAction().setName(nameBAESAllPrimRT.getName())
               .setBound(true)
-              .setParameters(Arrays.asList(
+              .setParameters(Collections.singletonList(
                   new CsdlParameter().setName("ParameterETAllPrim")
                       .setNullable(false)
                       .setCollection(true)
-                      .setType(EntityTypeProvider.nameETAllPrim)
-                  ))
-          );
+                      .setType(EntityTypeProvider.nameETAllPrim))));
     }
 
     return null;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
index ff53d09..799a816 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
@@ -46,6 +46,7 @@ public class ContainerProvider {
   public static final String AIRT = "AIRT";
   public static final String AIRT_PARAM = "AIRTParam";
   public static final String AIRT_TWO_PARAM = "AIRTTwoParam";
+  public static final String AIRT_BYTE_NINE_PARAM = "AIRTByteNineParam";
 
   CsdlEntityContainerInfo entityContainerInfoTest1 =
       new CsdlEntityContainerInfo().setContainerName(nameContainer);
@@ -123,6 +124,7 @@ public class ContainerProvider {
     actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, AIRT));
     actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, AIRT_PARAM));
     actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, AIRT_TWO_PARAM));
+    actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, AIRT_BYTE_NINE_PARAM));
 
     // FunctionImports
     List<CsdlFunctionImport> functionImports = new ArrayList<CsdlFunctionImport>();
@@ -500,6 +502,11 @@ public class ContainerProvider {
         return new CsdlActionImport()
             .setName(AIRT_TWO_PARAM)
             .setAction(ActionProvider.nameUARTTwoParam);
+
+      } else if (name.equals(AIRT_BYTE_NINE_PARAM)) {
+        return new CsdlActionImport()
+            .setName(AIRT_BYTE_NINE_PARAM)
+            .setAction(ActionProvider.nameUARTByteNineParam);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
index b07ae60..03588b3 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java
@@ -130,6 +130,7 @@ public class SchemaProvider {
     actions.addAll(prov.getActions(ActionProvider.nameUART));
     actions.addAll(prov.getActions(ActionProvider.nameUARTParam));
     actions.addAll(prov.getActions(ActionProvider.nameUARTTwoParam));
+    actions.addAll(prov.getActions(ActionProvider.nameUARTByteNineParam));
 
     // Functions
     List<CsdlFunction> functions = new ArrayList<CsdlFunction>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
index 12ee6af..20d4fa2 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
@@ -23,12 +23,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -37,9 +34,6 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmParameter;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
@@ -76,126 +70,99 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
 
   @Test
   public void primitiveCollection() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(
-        OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration));
-    when(parameter.isCollection()).thenReturn(true);
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterByte", "[1,42]");
+    assertTrue(parameter.isPrimitive());
+    assertTrue(parameter.isCollection());
+    assertEquals((short) 1, parameter.asCollection().get(0));
+    assertEquals((short) 42, parameter.asCollection().get(1));
+  }
 
-    final String input = "{\"Parameter\": [ \"PT0S\", \"PT42S\", \"PT1H2M3S\" ]}";
-    final Map<String, Parameter> parameters = deserialize(input, action);
+  @Test
+  public void enumeration() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterEnum", "\"String3,String1\"");
+    assertTrue(parameter.isEnum());
+    assertFalse(parameter.isCollection());
+    assertEquals((short) 5, parameter.getValue());
+  }
 
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isPrimitive());
-    assertTrue(parameterData.isCollection());
-    assertEquals(BigDecimal.ZERO, parameterData.asCollection().get(0));
-    assertEquals(BigDecimal.valueOf(42), parameterData.asCollection().get(1));
-    assertEquals(BigDecimal.valueOf(3723), parameterData.asCollection().get(2));
+  @Test
+  public void enumCollection() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterEnum",
+        "[ \"String1,String2\", \"String3,String3,String3\" ]");
+    assertTrue(parameter.isEnum());
+    assertTrue(parameter.isCollection());
+    assertEquals((short) 3, parameter.asCollection().get(0));
+    assertEquals((short) 4, parameter.asCollection().get(1));
   }
 
   @Test
-  public void complex() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
+  public void typeDefinition() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterDef", "\"Test String\"");
+    assertTrue(parameter.isPrimitive());
+    assertFalse(parameter.isCollection());
+    assertEquals("Test String", parameter.getValue());
+  }
 
-    final String input = "{\"Parameter\": { \"PropertyString\": \"Yes\", \"PropertyInt16\": 42 }}";
-    final Map<String, Parameter> parameters = deserialize(input, action);
+  @Test
+  public void typeDefinitionCollection() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterDef",
+        "[ \"Test String\", \"Another String\" ]");
+    assertTrue(parameter.isPrimitive());
+    assertTrue(parameter.isCollection());
+    assertEquals("Test String", parameter.asCollection().get(0));
+    assertEquals("Another String", parameter.asCollection().get(1));
+  }
 
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    final Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isComplex());
-    assertFalse(parameterData.isCollection());
-    final List<Property> complexValues = parameterData.asComplex().getValue();
+  @Test
+  public void complex() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterComp",
+        "{ \"PropertyString\": \"Yes\", \"PropertyInt16\": 42 }");
+    assertTrue(parameter.isComplex());
+    assertFalse(parameter.isCollection());
+    final List<Property> complexValues = parameter.asComplex().getValue();
     assertEquals((short) 42, complexValues.get(0).getValue());
     assertEquals("Yes", complexValues.get(1).getValue());
   }
 
   @Test
   public void complexCollection() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
-    when(parameter.isCollection()).thenReturn(true);
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
-
-    final String input = "{\"Parameter\": [\n"
-        + "  { \"PropertyInt16\": 9999, \"PropertyString\": \"One\" },\n"
-        + "  { \"PropertyInt16\": -123, \"PropertyString\": \"Two\" }]}";
-    final Map<String, Parameter> parameters = deserialize(input, action);
-
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isComplex());
-    assertTrue(parameterData.isCollection());
-    ComplexValue complexValue = (ComplexValue) parameterData.asCollection().get(0);
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterComp",
+        "[ { \"PropertyInt16\": 9999, \"PropertyString\": \"One\" },"
+        + "  { \"PropertyInt16\": -123, \"PropertyString\": \"Two\" }]");
+    assertTrue(parameter.isComplex());
+    assertTrue(parameter.isCollection());
+    ComplexValue complexValue = (ComplexValue) parameter.asCollection().get(0);
     assertEquals((short) 9999, complexValue.getValue().get(0).getValue());
     assertEquals("One", complexValue.getValue().get(1).getValue());
 
-    complexValue = (ComplexValue) parameterData.asCollection().get(1);
+    complexValue = (ComplexValue) parameter.asCollection().get(1);
     assertEquals((short) -123, complexValue.getValue().get(0).getValue());
     assertEquals("Two", complexValue.getValue().get(1).getValue());
   }
 
   @Test
   public void entity() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getEntityType(new FullQualifiedName(NAMESPACE, "ETTwoPrim")));
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
-
-    final String input = "{\"Parameter\": { \"PropertyInt16\": 42, \"PropertyString\": \"Yes\" }}";
-    final Map<String, Parameter> parameters = deserialize(input, action);
-
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    final Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isEntity());
-    assertFalse(parameterData.isCollection());
-    final List<Property> entityValues = parameterData.asEntity().getProperties();
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterETTwoPrim",
+        "{ \"PropertyInt16\": 42, \"PropertyString\": \"Yes\" }");
+    assertTrue(parameter.isEntity());
+    assertFalse(parameter.isCollection());
+    final List<Property> entityValues = parameter.asEntity().getProperties();
     assertEquals((short) 42, entityValues.get(0).getValue());
     assertEquals("Yes", entityValues.get(1).getValue());
   }
 
   @Test
   public void entityCollection() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getEntityType(new FullQualifiedName(NAMESPACE, "ETTwoPrim")));
-    when(parameter.isCollection()).thenReturn(true);
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
-
-    final String input = "{\"Parameter\": [\n"
-        + "  { \"PropertyInt16\": 1234, \"PropertyString\": \"One\" },\n"
-        + "  { \"PropertyInt16\": -321, \"PropertyString\": \"Two\" }]}";
-    final Map<String, Parameter> parameters = deserialize(input, action);
-
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isEntity());
-    assertTrue(parameterData.isCollection());
-    Entity entity = ((EntityCollection) parameterData.getValue()).getEntities().get(0);
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterETTwoPrim",
+        "[ { \"PropertyInt16\": 1234, \"PropertyString\": \"One\" },"
+        + "  { \"PropertyInt16\": -321, \"PropertyString\": \"Two\" }]");
+    assertTrue(parameter.isEntity());
+    assertTrue(parameter.isCollection());
+    Entity entity = ((EntityCollection) parameter.getValue()).getEntities().get(0);
     assertEquals((short) 1234, entity.getProperties().get(0).getValue());
     assertEquals("One", entity.getProperties().get(1).getValue());
 
-    entity = ((EntityCollection) parameterData.getValue()).getEntities().get(1);
+    entity = ((EntityCollection) parameter.getValue()).getEntities().get(1);
     assertEquals((short) -321, entity.getProperties().get(0).getValue());
     assertEquals("Two", entity.getProperties().get(1).getValue());
   }
@@ -222,7 +189,7 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
     assertNotNull(parameter);
     assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
   }
-  
+
   @Test
   public void parameterWithNullLiteral() throws Exception {
     final Map<String, Parameter> parameters = deserialize("{\"ParameterInt16\":1,\"ParameterDuration\":null}",
@@ -268,20 +235,33 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
     expectException("{\"ParameterInt16\":[42]}", "UARTParam", null, MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY);
   }
 
-  private Map<String, Parameter> deserialize(final String input, final EdmAction action) throws DeserializerException {
-    return OData.newInstance().createDeserializer(ContentType.JSON)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action)
-        .getActionParameters();
+  private Parameter deserializeUARTByteNineParam(final String parameterName, final String parameterJsonValue)
+      throws DeserializerException {
+    final Map<String, Parameter> parameters = deserialize(
+        "{" + (parameterName.equals("CollParameterByte") ? "" : "\"CollParameterByte\":[],")
+            + (parameterName.equals("CollParameterEnum") ? "" : "\"CollParameterEnum\":[],")
+            + (parameterName.equals("CollParameterDef") ? "" : "\"CollParameterDef\":[],")
+            + (parameterName.equals("CollParameterComp") ? "" : "\"CollParameterComp\":[],")
+            + (parameterName.equals("CollParameterETTwoPrim") ? "" : "\"CollParameterETTwoPrim\":[],")
+            + "\"" + parameterName + "\":" + parameterJsonValue + "}",
+        "UARTByteNineParam", null);
+    assertNotNull(parameters);
+    assertEquals(9, parameters.size());
+    Parameter parameter = parameters.get(parameterName);
+    assertNotNull(parameter);
+    return parameter;
   }
 
   private Map<String, Parameter> deserialize(final String input, final String actionName, final String bindingTypeName)
       throws DeserializerException {
-    return deserialize(input,
-        bindingTypeName == null ?
-            edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
-            edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
-                new FullQualifiedName(NAMESPACE, bindingTypeName),
-                false));
+    return OData.newInstance().createDeserializer(ContentType.JSON)
+        .actionParameters(new ByteArrayInputStream(input.getBytes()),
+            bindingTypeName == null ?
+                edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
+                edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
+                    new FullQualifiedName(NAMESPACE, bindingTypeName),
+                    false))
+        .getActionParameters();
   }
 
   private void expectException(final String input, final String actionName, final String bindingTypeName,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b736c434/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
index f50cbc9..18162da 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
@@ -23,12 +23,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -36,9 +33,6 @@ import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmParameter;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
@@ -64,8 +58,8 @@ public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeser
   @Test
   public void primitive() throws Exception {
     final String input = PREAMBLE
-        + "<ParameterDuration>P42DT11H22M33S</ParameterDuration>"
-        + "<ParameterInt16>42</ParameterInt16>"
+        + "<data:ParameterDuration>P42DT11H22M33S</data:ParameterDuration>"
+        + "<data:ParameterInt16>42</data:ParameterInt16>"
         + POSTAMBLE;
 
     final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam", null);
@@ -81,93 +75,84 @@ public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeser
 
   @Test
   public void primitiveCollection() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(
-        OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration));
-    when(parameter.isCollection()).thenReturn(true);
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterByte",
+        "<metadata:element>0</metadata:element>"
+        + "<metadata:element>42</metadata:element>"
+        + "<metadata:element>255</metadata:element>");
+    assertNotNull(parameter);
+    assertTrue(parameter.isPrimitive());
+    assertTrue(parameter.isCollection());
+    assertEquals((short) 0, parameter.asCollection().get(0));
+    assertEquals((short) 42, parameter.asCollection().get(1));
+    assertEquals((short) 255, parameter.asCollection().get(2));
+  }
 
-    final String input = PREAMBLE
-        + "<Parameter>"
-        + "<metadata:element>PT0S</metadata:element>"
-        + "<metadata:element>PT42S</metadata:element>"
-        + "<metadata:element>PT1H2M3S</metadata:element>"
-        + "</Parameter>"
-        + POSTAMBLE;
-    final Map<String, Parameter> parameters = deserialize(input, action);
+  @Test
+  public void enumeration() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterEnum", "String3,String1");
+    assertTrue(parameter.isEnum());
+    assertFalse(parameter.isCollection());
+    assertEquals((short) 5, parameter.getValue());
+  }
 
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isPrimitive());
-    assertTrue(parameterData.isCollection());
-    assertEquals(BigDecimal.ZERO, parameterData.asCollection().get(0));
-    assertEquals(BigDecimal.valueOf(42), parameterData.asCollection().get(1));
-    assertEquals(BigDecimal.valueOf(3723), parameterData.asCollection().get(2));
+  @Test
+  public void enumCollection() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterEnum",
+        "<metadata:element>String1,String2</metadata:element>"
+        + "<metadata:element>String3,String3,String3</metadata:element>");
+    assertTrue(parameter.isEnum());
+    assertTrue(parameter.isCollection());
+    assertEquals((short) 3, parameter.asCollection().get(0));
+    assertEquals((short) 4, parameter.asCollection().get(1));
   }
 
   @Test
-  public void complex() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
+  public void typeDefinition() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterDef", "Test String");
+    assertTrue(parameter.isPrimitive());
+    assertFalse(parameter.isCollection());
+    assertEquals("Test String", parameter.getValue());
+  }
 
-    final String input = PREAMBLE
-        + "<Parameter>"
-        + "<PropertyInt16>42</PropertyInt16>"
-        + "<PropertyString>Yes</PropertyString>"
-        + "</Parameter>"
-        + POSTAMBLE;
-    final Map<String, Parameter> parameters = deserialize(input, action);
+  @Test
+  public void typeDefinitionCollection() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterDef",
+        "<metadata:element>Test String</metadata:element>"
+        + "<metadata:element>Another String</metadata:element>");
+    assertTrue(parameter.isPrimitive());
+    assertTrue(parameter.isCollection());
+    assertEquals("Test String", parameter.asCollection().get(0));
+    assertEquals("Another String", parameter.asCollection().get(1));
+  }
 
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    final Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isComplex());
-    assertFalse(parameterData.isCollection());
-    final List<Property> complexValues = parameterData.asComplex().getValue();
+  @Test
+  public void complex() throws Exception {
+    final Parameter parameter = deserializeUARTByteNineParam("ParameterComp",
+        "<data:PropertyInt16>42</data:PropertyInt16>    <data:PropertyString>Yes</data:PropertyString>");
+    assertNotNull(parameter);
+    assertTrue(parameter.isComplex());
+    assertFalse(parameter.isCollection());
+    final List<Property> complexValues = parameter.asComplex().getValue();
     assertEquals((short) 42, complexValues.get(0).getValue());
     assertEquals("Yes", complexValues.get(1).getValue());
   }
 
   @Test
   public void complexCollection() throws Exception {
-    EdmParameter parameter = mock(EdmParameter.class);
-    when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
-    when(parameter.isCollection()).thenReturn(true);
-    EdmAction action = mock(EdmAction.class);
-    when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
-    when(action.getParameter("Parameter")).thenReturn(parameter);
-
-    final String input = PREAMBLE
-        + "<Parameter>"
-        + "<metadata:element>"
-        + "<PropertyInt16>9999</PropertyInt16><PropertyString>One</PropertyString>"
+    final Parameter parameter = deserializeUARTByteNineParam("CollParameterComp",
+        "<metadata:element>"
+        + "<data:PropertyInt16>9999</data:PropertyInt16><data:PropertyString>One</data:PropertyString>"
         + "</metadata:element>"
         + "<metadata:element>"
-        + "<PropertyInt16>-123</PropertyInt16><PropertyString>Two</PropertyString>"
-        + "</metadata:element>"
-        + "</Parameter>"
-        + POSTAMBLE;
-    final Map<String, Parameter> parameters = deserialize(input, action);
-
-    assertNotNull(parameters);
-    assertEquals(1, parameters.size());
-    Parameter parameterData = parameters.get("Parameter");
-    assertNotNull(parameterData);
-    assertTrue(parameterData.isComplex());
-    assertTrue(parameterData.isCollection());
-    ComplexValue complexValue = (ComplexValue) parameterData.asCollection().get(0);
+        + "<data:PropertyInt16>-123</data:PropertyInt16><data:PropertyString>Two</data:PropertyString>"
+        + "</metadata:element>");
+    assertTrue(parameter.isComplex());
+    assertTrue(parameter.isCollection());
+    ComplexValue complexValue = (ComplexValue) parameter.asCollection().get(0);
     assertEquals((short) 9999, complexValue.getValue().get(0).getValue());
     assertEquals("One", complexValue.getValue().get(1).getValue());
 
-    complexValue = (ComplexValue) parameterData.asCollection().get(1);
+    complexValue = (ComplexValue) parameter.asCollection().get(1);
     assertEquals((short) -123, complexValue.getValue().get(0).getValue());
     assertEquals("Two", complexValue.getValue().get(1).getValue());
   }
@@ -183,8 +168,8 @@ public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeser
   @Test
   public void parameterWithNullLiteral() throws Exception {
     final String input = PREAMBLE
-        + "<ParameterInt16>1</ParameterInt16>"
-        + "<ParameterDuration metadata:null=\"true\" />"
+        + "<data:ParameterInt16>1</data:ParameterInt16>"
+        + "<data:ParameterDuration metadata:null=\"true\" />"
         + POSTAMBLE;
     final Map<String, Parameter> parameters = deserialize(input, "UARTCollStringTwoParam", null);
     assertNotNull(parameters);
@@ -199,19 +184,19 @@ public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeser
 
   @Test
   public void bindingParameter() throws Exception {
-    final String input = PREAMBLE + "<ParameterETAllPrim>1</ParameterETAllPrim>" + POSTAMBLE;
+    final String input = PREAMBLE + "<data:ParameterETAllPrim>1</data:ParameterETAllPrim>" + POSTAMBLE;
     deserialize(input, "BAETAllPrimRT", "ETAllPrim");
   }
 
   @Test
   public void wrongName() throws Exception {
-    expectException(PREAMBLE + "<ParameterWrong>1</ParameterWrong>" + POSTAMBLE,
+    expectException(PREAMBLE + "<data:ParameterWrong>1</data:ParameterWrong>" + POSTAMBLE,
         "UARTParam", null, MessageKeys.UNKNOWN_CONTENT);
   }
 
   @Test
   public void nullNotNullable() throws Exception {
-    expectException(PREAMBLE + "<ParameterInt16>null</ParameterInt16>" + POSTAMBLE,
+    expectException(PREAMBLE + "<data:ParameterInt16>null</data:ParameterInt16>" + POSTAMBLE,
         "UARTCTTwoPrimParam", null, MessageKeys.INVALID_VALUE_FOR_PROPERTY);
   }
 
@@ -223,26 +208,40 @@ public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeser
   @Test
   public void parameterTwice() throws Exception {
     expectException(PREAMBLE
-        + "<ParameterInt16>1</ParameterInt16>"
-        + "<ParameterInt16>2</ParameterInt16>"
+        + "<data:ParameterInt16>1</data:ParameterInt16>"
+        + "<data:ParameterInt16>2</data:ParameterInt16>"
         + POSTAMBLE,
         "UARTParam", null, MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  private Map<String, Parameter> deserialize(final String input, final EdmAction action) throws DeserializerException {
-    return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
-        .actionParameters(new ByteArrayInputStream(input.getBytes()), action)
-        .getActionParameters();
+  private Parameter deserializeUARTByteNineParam(final String parameterName, final String parameterXmlValue)
+      throws DeserializerException {
+    final Map<String, Parameter> parameters = deserialize(
+        PREAMBLE + (parameterName.equals("CollParameterByte") ? "" : "<data:CollParameterByte />")
+            + (parameterName.equals("CollParameterEnum") ? "" : "<data:CollParameterEnum />")
+            + (parameterName.equals("CollParameterDef") ? "" : "<data:CollParameterDef />")
+            + (parameterName.equals("CollParameterComp") ? "" : "<data:CollParameterComp />")
+            + (parameterName.equals("CollParameterETTwoPrim") ? "" : "<data:CollParameterETTwoPrim />")
+            + "<data:" + parameterName + ">" + parameterXmlValue + "</data:" + parameterName + ">"
+            + POSTAMBLE,
+        "UARTByteNineParam", null);
+    assertNotNull(parameters);
+    assertEquals(9, parameters.size());
+    Parameter parameter = parameters.get(parameterName);
+    assertNotNull(parameter);
+    return parameter;
   }
 
   private Map<String, Parameter> deserialize(final String input, final String actionName, final String bindingTypeName)
       throws DeserializerException {
-    return deserialize(input,
-        bindingTypeName == null ?
-            edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
-            edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
-                new FullQualifiedName(NAMESPACE, bindingTypeName),
-                false));
+    return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
+        .actionParameters(new ByteArrayInputStream(input.getBytes()),
+            bindingTypeName == null ?
+                edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
+                edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
+                    new FullQualifiedName(NAMESPACE, bindingTypeName),
+                    false))
+        .getActionParameters();
   }
 
   private void expectException(final String input, final String actionName, final String bindingTypeName,


[06/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/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 c5c842c..9b9de1d 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
@@ -50,8 +50,8 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
@@ -72,13 +72,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 
 public class ODataJsonDeserializer implements ODataDeserializer {
 
-  private static final String AN_IO_EXCEPTION_OCCURRED_MSG = "An IOException occurred";
-  private static final String DUPLICATE_JSON_PROPERTY_DETECTED_MSG = "Duplicate json property detected";
-  private static final String AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG = "A JsonParseException occurred";
   private static final String ODATA_ANNOTATION_MARKER = "@";
   private static final String ODATA_CONTROL_INFORMATION_PREFIX = "@odata.";
-  private static final EdmPrimitiveType EDM_INT64 = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64);
-  private static final EdmPrimitiveType EDM_DECIMAL = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal);
+
   private final boolean isIEEE754Compatible;
 
   public ODataJsonDeserializer(final ContentType contentType) {
@@ -89,33 +85,21 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   public DeserializerResult entityCollection(final InputStream stream, final EdmEntityType edmEntityType)
       throws DeserializerException {
     try {
-      final ObjectNode tree = parseJsonTree(stream);
-
-      return DeserializerResultImpl.with().entityCollection(consumeEntitySetNode(edmEntityType, tree, null))
+      return DeserializerResultImpl.with().entityCollection(
+          consumeEntityCollectionNode(edmEntityType, parseJsonTree(stream), null))
           .build();
-    } catch (JsonParseException e) {
-      throw new DeserializerException(AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG, e,
-          DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
-    } catch (JsonMappingException e) {
-      throw new DeserializerException(DUPLICATE_JSON_PROPERTY_DETECTED_MSG, e,
-          DeserializerException.MessageKeys.DUPLICATE_JSON_PROPERTY);
-    } catch (IOException e) {
-      throw new DeserializerException(AN_IO_EXCEPTION_OCCURRED_MSG, e, DeserializerException.MessageKeys.IO_EXCEPTION);
+    } catch (final IOException e) {
+      throw wrapParseException(e);
     }
   }
 
-  private EntityCollection consumeEntitySetNode(final EdmEntityType edmEntityType, final ObjectNode tree,
+  private EntityCollection consumeEntityCollectionNode(final EdmEntityType edmEntityType, ObjectNode tree,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     EntityCollection entitySet = new EntityCollection();
 
     // Consume entities
     JsonNode jsonNode = tree.get(Constants.VALUE);
     if (jsonNode != null) {
-      if (!jsonNode.isArray()) {
-        throw new DeserializerException("The content of the value tag must be an Array but is not. ",
-            DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
-      }
-
       entitySet.getEntities().addAll(consumeEntitySetArray(edmEntityType, jsonNode, expandBuilder));
       tree.remove(Constants.VALUE);
     } else {
@@ -145,16 +129,20 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   private List<Entity> consumeEntitySetArray(final EdmEntityType edmEntityType, final JsonNode jsonNode,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
-    List<Entity> entities = new ArrayList<Entity>();
-    for (JsonNode arrayElement : jsonNode) {
-      if (arrayElement.isArray() || arrayElement.isValueNode()) {
-        throw new DeserializerException("Nested Arrays and primitive values are not allowed for an entity value.",
-            DeserializerException.MessageKeys.INVALID_ENTITY);
+    if (jsonNode.isArray()) {
+      List<Entity> entities = new ArrayList<Entity>();
+      for (JsonNode arrayElement : jsonNode) {
+        if (arrayElement.isArray() || arrayElement.isValueNode()) {
+          throw new DeserializerException("Nested Arrays and primitive values are not allowed for an entity value.",
+              DeserializerException.MessageKeys.INVALID_ENTITY);
+        }
+        entities.add(consumeEntityNode(edmEntityType, (ObjectNode) arrayElement, expandBuilder));
       }
-
-      entities.add(consumeEntityNode(edmEntityType, (ObjectNode) arrayElement, expandBuilder));
+      return entities;
+    } else {
+      throw new DeserializerException("The content of the value tag must be an Array but is not.",
+          DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
     }
-    return entities;
   }
 
   @Override
@@ -167,17 +155,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       return DeserializerResultImpl.with().entity(consumeEntityNode(edmEntityType, tree, expandBuilder))
           .expandOption(expandBuilder.build())
           .build();
-
-    } catch (JsonParseException e) {
-      throw new DeserializerException(AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG, e,
-          DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
-    } catch (JsonMappingException e) {
-      throw new DeserializerException(DUPLICATE_JSON_PROPERTY_DETECTED_MSG, e,
-          DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
-    } catch (IOException e) {
-      throw new DeserializerException(AN_IO_EXCEPTION_OCCURRED_MSG, e, DeserializerException.MessageKeys.IO_EXCEPTION);
+    } catch (final IOException e) {
+      throw wrapParseException(e);
     }
-
   }
 
   private Entity consumeEntityNode(final EdmEntityType edmEntityType, final ObjectNode tree,
@@ -224,15 +204,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       assertJsonNodeIsEmpty(tree);
       return DeserializerResultImpl.with().actionParameters(parameters).build();
 
-    } catch (final JsonParseException e) {
-      throw new DeserializerException(AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG, e,
-          DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
-    } catch (final JsonMappingException e) {
-      throw new DeserializerException(DUPLICATE_JSON_PROPERTY_DETECTED_MSG, e,
-          DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
     } catch (final IOException e) {
-      throw new DeserializerException(AN_IO_EXCEPTION_OCCURRED_MSG, e,
-          DeserializerException.MessageKeys.IO_EXCEPTION);
+      throw wrapParseException(e);
     }
   }
 
@@ -264,17 +237,15 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       case DEFINITION:
       case ENUM:
       case COMPLEX:
+      case ENTITY:
         Parameter parameter = createParameter(node.get(paramName), paramName, edmParameter);
         parameters.put(paramName, parameter);
         node.remove(paramName);
         break;
-      case ENTITY:
-        throw new DeserializerException("Entity parameters are not allowed",
-            DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE);
       default:
-        throw new DeserializerException("Invalid type kind " + edmParameter.getType().getKind().toString()
-            + " for action parameter: " + paramName, DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE,
-            paramName);
+        throw new DeserializerException(
+            "Invalid type kind " + edmParameter.getType().getKind() + " for action parameter: " + paramName,
+            DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE, paramName);
       }
     }
     return parameters;
@@ -286,7 +257,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     parameter.setName(paramName);
     if (node == null || node.isNull()) {
       if (!edmParameter.isNullable()) {
-        throw new DeserializerException("Non-nullable parameter not present or null",
+        throw new DeserializerException("Non-nullable parameter not present or null: " + paramName,
             MessageKeys.INVALID_NULL_PARAMETER, paramName);
       }
       if (edmParameter.isCollection()) {
@@ -294,24 +265,34 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             MessageKeys.INVALID_NULL_PARAMETER, paramName);
       }
       parameter.setValue(ValueType.PRIMITIVE, null);
+    } else if (edmParameter.getType().getKind() == EdmTypeKind.ENTITY) {
+      if (edmParameter.isCollection()) {
+        EntityCollection entityCollection = new EntityCollection();
+        entityCollection.getEntities().addAll(
+            consumeEntitySetArray((EdmEntityType) edmParameter.getType(), node, null));
+        parameter.setValue(ValueType.COLLECTION_ENTITY, entityCollection);
+      } else {
+        final Entity entity = consumeEntityNode((EdmEntityType) edmParameter.getType(), (ObjectNode) node, null);
+        parameter.setValue(ValueType.ENTITY, entity);
+      }
     } else {
-      Property consumePropertyNode =
+      final Property property =
           consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
-              edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter
-                  .getScale(), true, edmParameter.getMapping(), node);
-      parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue());
+              edmParameter.isNullable(), edmParameter.getMaxLength(),
+              edmParameter.getPrecision(), edmParameter.getScale(), true, edmParameter.getMapping(), node);
+      parameter.setValue(property.getValueType(), property.getValue());
     }
     return parameter;
   }
 
   /**
-   * Consume all remaining fields of Json ObjectNode and try to map found values
-   * to according Entity fields and omit to be ignored OData fields (e.g. control information).
+   * Consumes all remaining fields of Json ObjectNode and tries to map found values
+   * to according Entity fields and omits OData fields to be ignored (e.g., control information).
    *
    * @param edmEntityType edm entity type which for which the json node is consumed
    * @param node json node which is consumed
    * @param entity entity instance which is filled
-   * @throws DeserializerException if an exception during consummation occurs
+   * @throws DeserializerException if an exception during consumation occurs
    */
   private void consumeRemainingJsonNodeFields(final EdmEntityType edmEntityType, final ObjectNode node,
       final Entity entity) throws DeserializerException {
@@ -420,7 +401,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   private Link consumeBindingLink(final String key, final JsonNode jsonNode, final EdmEntityType edmEntityType)
       throws DeserializerException {
-    String[] splitKey = key.split("@");
+    String[] splitKey = key.split(ODATA_ANNOTATION_MARKER);
     String navigationPropertyName = splitKey[0];
     EdmNavigationProperty edmNavigationProperty = edmEntityType.getNavigationProperty(navigationPropertyName);
     if (edmNavigationProperty == null) {
@@ -488,23 +469,16 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       throws DeserializerException {
     switch (type.getKind()) {
     case PRIMITIVE:
-      Object value = readPrimitiveValue(name, type, isNullable, maxLength, precision, scale, isUnicode, mapping,
-          jsonNode);
-      property.setValue(ValueType.PRIMITIVE, value);
-      break;
     case DEFINITION:
-      value = readTypeDefinitionValue(name, type, isNullable, mapping, jsonNode);
-      property.setValue(ValueType.PRIMITIVE, value);
-      break;
     case ENUM:
-      value = readEnumValue(name, type, isNullable, maxLength, precision, scale, isUnicode, mapping,
-          jsonNode);
-      property.setValue(ValueType.ENUM, value);
+      Object value = readPrimitiveValue(name, (EdmPrimitiveType) type,
+          isNullable, maxLength, precision, scale, isUnicode, mapping, jsonNode);
+      property.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE,
+          value);
       break;
     case COMPLEX:
       value = readComplexNode(name, type, isNullable, jsonNode);
       property.setValue(ValueType.COMPLEX, value);
-
       break;
     default:
       throw new DeserializerException("Invalid Type Kind for a property found: " + type.getKind(),
@@ -553,30 +527,18 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     Iterator<JsonNode> iterator = jsonNode.iterator();
     switch (type.getKind()) {
     case PRIMITIVE:
-      while (iterator.hasNext()) {
-        JsonNode arrayElement = iterator.next();
-        Object value = readPrimitiveValue(name, type, isNullable, maxLength, precision, scale, isUnicode, mapping,
-            arrayElement);
-        valueArray.add(value);
-      }
-      property.setValue(ValueType.COLLECTION_PRIMITIVE, valueArray);
-      break;
     case DEFINITION:
-      while (iterator.hasNext()) {
-        JsonNode arrayElement = iterator.next();
-        Object value = readTypeDefinitionValue(name, type, isNullable, mapping, arrayElement);
-        valueArray.add(value);
-      }
-      property.setValue(ValueType.COLLECTION_PRIMITIVE, valueArray);
-      break;
     case ENUM:
       while (iterator.hasNext()) {
         JsonNode arrayElement = iterator.next();
-        Object value = readEnumValue(name, type, isNullable, maxLength, precision, scale, isUnicode, mapping,
-            arrayElement);
+        Object value = readPrimitiveValue(name, (EdmPrimitiveType) type,
+            isNullable, maxLength, precision, scale, isUnicode, mapping, arrayElement);
         valueArray.add(value);
       }
-      property.setValue(ValueType.COLLECTION_ENUM, valueArray);
+      property.setValue(type.getKind() == EdmTypeKind.ENUM ?
+              ValueType.COLLECTION_ENUM :
+              ValueType.COLLECTION_PRIMITIVE,
+          valueArray);
       break;
     case COMPLEX:
       while (iterator.hasNext()) {
@@ -626,22 +588,20 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     return complexValue;
   }
 
-  private Object readTypeDefinitionValue(final String name, final EdmType type,
-      final boolean isNullable, final EdmMapping mapping, final JsonNode jsonNode) throws DeserializerException {
+  private Object readPrimitiveValue(final String name, final EdmPrimitiveType type,
+      final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
+      final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode) throws DeserializerException {
     checkForValueNode(name, jsonNode);
     if (isValidNull(name, isNullable, jsonNode)) {
       return null;
     }
+    checkJsonTypeBasedOnPrimitiveType(name, type, jsonNode);
+    Class<?> javaClass = getJavaClassForPrimitiveType(mapping, type);
     try {
-      EdmTypeDefinition edmTypeDefinition = (EdmTypeDefinition) type;
-      checkJsonTypeBasedOnPrimitiveType(name, edmTypeDefinition.getUnderlyingType().getName(),
-          jsonNode);
-      Class<?> javaClass = getJavaClassForPrimitiveType(mapping, edmTypeDefinition.getUnderlyingType());
-      return edmTypeDefinition.valueOfString(jsonNode.asText(), isNullable,
-          edmTypeDefinition.getMaxLength(),
-          edmTypeDefinition.getPrecision(), edmTypeDefinition.getScale(), edmTypeDefinition.isUnicode(),
+      return type.valueOfString(jsonNode.asText(),
+          isNullable, maxLength, precision, scale, isUnicode,
           javaClass);
-    } catch (EdmPrimitiveTypeException e) {
+    } catch (final EdmPrimitiveTypeException e) {
       throw new DeserializerException(
           "Invalid value: " + jsonNode.asText() + " for property: " + name, e,
           DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name);
@@ -657,72 +617,23 @@ public class ODataJsonDeserializer implements ODataDeserializer {
         throw new DeserializerException("Property: " + name + " must not be null.",
             DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, name);
       }
-
     }
     return false;
   }
 
-  private Object readEnumValue(final String name, final EdmType type,
-      final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
-      final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode) throws DeserializerException {
-    checkForValueNode(name, jsonNode);
-    if (isValidNull(name, isNullable, jsonNode)) {
-      return null;
-    }
-    try {
-      EdmEnumType edmEnumType = (EdmEnumType) type;
-      // Enum values must be strings
-      if (!jsonNode.isTextual()) {
-        throw new DeserializerException("Invalid json type: " + jsonNode.getNodeType() + " for enum property: " + name,
-            DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name);
-      }
-
-      Class<?> javaClass = getJavaClassForPrimitiveType(mapping, edmEnumType.getUnderlyingType());
-      return edmEnumType.valueOfString(jsonNode.asText(),
-          isNullable, maxLength, precision, scale, isUnicode, javaClass);
-    } catch (EdmPrimitiveTypeException e) {
-      throw new DeserializerException(
-          "Invalid value: " + jsonNode.asText() + " for property: " + name, e,
-          DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name);
-    }
-  }
-
-  private Object readPrimitiveValue(final String name, final EdmType type,
-      final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
-      final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode) throws DeserializerException {
-    checkForValueNode(name, jsonNode);
-    if (isValidNull(name, isNullable, jsonNode)) {
-      return null;
-    }
-    try {
-      EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) type;
-      checkJsonTypeBasedOnPrimitiveType(name, edmPrimitiveType.getName(), jsonNode);
-      Class<?> javaClass = getJavaClassForPrimitiveType(mapping, edmPrimitiveType);
-      String jsonNodeAsText = jsonNode.asText();
-
-      if (isIEEE754Compatible
-          && (edmPrimitiveType.equals(EDM_INT64) || edmPrimitiveType.equals(EDM_DECIMAL))
-              && jsonNodeAsText.length() == 0) {
-        throw new DeserializerException("IEEE754Compatible values must not be of length 0",
-            MessageKeys.INVALID_NULL_PROPERTY, name);
-      }
-
-      return edmPrimitiveType.valueOfString(jsonNodeAsText, isNullable, maxLength, precision, scale, isUnicode,
-          javaClass);
-    } catch (EdmPrimitiveTypeException e) {
-      throw new DeserializerException(
-          "Invalid value: " + jsonNode.asText() + " for property: " + name, e,
-          DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name);
-    }
-  }
-
   /**
-   * This method either returns the primitive types default class or the manually mapped class if present.
+   * Returns the primitive type's default class or the manually mapped class if present.
    * @param mapping
    * @param edmPrimitiveType
    * @return the java class to be used during deserialization
    */
-  private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType edmPrimitiveType) {
+  private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) {
+    final EdmPrimitiveType edmPrimitiveType =
+        type.getKind() == EdmTypeKind.ENUM ?
+            ((EdmEnumType) type).getUnderlyingType() :
+                type.getKind() == EdmTypeKind.DEFINITION ?
+                    ((EdmTypeDefinition) type).getUnderlyingType() :
+                    type;
     return mapping == null || mapping.getMappedJavaClass() == null ?
         edmPrimitiveType.getDefaultType() :
         mapping.getMappedJavaClass();
@@ -743,9 +654,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   /**
-   * Validate that node is empty (<code>node.size == 0</code>) and if not throw
-   * an <code>DeserializerException</code>.
-   *
+   * Validates that node is empty (<code>node.size() == 0</code>).
    * @param node node to be checked
    * @throws DeserializerException if node is not empty
    */
@@ -757,90 +666,64 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final String edmPrimitiveTypeName,
-      final JsonNode jsonNode)
-      throws DeserializerException {
-
-    EdmPrimitiveTypeKind primKind;
-    try {
-      primKind = EdmPrimitiveTypeKind.valueOf(edmPrimitiveTypeName);
-    } catch (IllegalArgumentException e) {
-      throw new DeserializerException("Unknown Primitive Type: " + edmPrimitiveTypeName, e,
-          DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, edmPrimitiveTypeName, propertyName);
+  private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType,
+      final JsonNode jsonNode) throws DeserializerException {
+    boolean valid = true;
+    if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) {
+      checkJsonTypeBasedOnPrimitiveType(propertyName,
+          ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode);
+    } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) {
+      // Enum values must be strings.
+      valid = jsonNode.isTextual();
+    } else {
+      final String name = edmPrimitiveType.getName();
+      EdmPrimitiveTypeKind primKind;
+      try {
+        primKind = EdmPrimitiveTypeKind.valueOf(name);
+      } catch (final IllegalArgumentException e) {
+        throw new DeserializerException("Unknown Primitive Type: " + name, e,
+            DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName);
+      }
+      valid = matchTextualCase(jsonNode, primKind)
+          || matchNumberCase(jsonNode, primKind)
+          || matchBooleanCase(jsonNode, primKind)
+          || matchIEEENumberCase(jsonNode, primKind);
     }
-
-    boolean valid = matchTextualCase(jsonNode, primKind);
-    valid |= matchNumberCase(jsonNode, primKind);
-    valid |= matchBooleanCase(jsonNode, primKind);
-    valid |= matchIEEENumberCase(jsonNode, primKind);
-
     if (!valid) {
-      throw new DeserializerException("Invalid json type: " + jsonNode.getNodeType() + " for edm " + primKind
-          + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName);
+      throw new DeserializerException(
+          "Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName,
+          DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName);
     }
   }
 
-  private boolean matchIEEENumberCase(JsonNode node, EdmPrimitiveTypeKind primKind) {
-    switch (primKind) {
-    case Int64:
-    case Decimal:
-      // Numbers (either numbers or string)
-      if (isIEEE754Compatible) {
-        return node.isTextual();
-      } else {
-        return node.isNumber();
-      }
-    default:
-      return false;
-    }
+  private boolean matchIEEENumberCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
+    return (isIEEE754Compatible ? node.isTextual() : node.isNumber())
+        && (primKind == EdmPrimitiveTypeKind.Int64 || primKind == EdmPrimitiveTypeKind.Decimal);
   }
 
-  private boolean matchBooleanCase(JsonNode node, EdmPrimitiveTypeKind primKind) {
-    if (node.isBoolean()) {
-      switch (primKind) {
-      case Boolean:
-        return true;
-      default:
-        return false;
-      }
-    }
-    return false;
+  private boolean matchBooleanCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
+    return node.isBoolean() && primKind == EdmPrimitiveTypeKind.Boolean;
   }
 
-  private boolean matchNumberCase(JsonNode node, EdmPrimitiveTypeKind primKind) {
-    if (node.isNumber()) {
-      switch (primKind) {
-      // Numbers (must be numbers)
-      case Int16:
-      case Int32:
-      case Byte:
-      case SByte:
-      case Single:
-      case Double:
-        return true;
-      default:
-        return false;
-      }
-    }
-    return false;
+  private boolean matchNumberCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
+    return node.isNumber() &&
+      (primKind == EdmPrimitiveTypeKind.Int16
+      || primKind == EdmPrimitiveTypeKind.Int32
+      || primKind == EdmPrimitiveTypeKind.Byte
+      || primKind == EdmPrimitiveTypeKind.SByte
+      || primKind == EdmPrimitiveTypeKind.Single
+      || primKind == EdmPrimitiveTypeKind.Double);
   }
 
-  private boolean matchTextualCase(JsonNode node, EdmPrimitiveTypeKind primKind) {
-    if (node.isTextual()) {
-      switch (primKind) {
-      case String:
-      case Binary:
-      case Date:
-      case DateTimeOffset:
-      case Duration:
-      case Guid:
-      case TimeOfDay:
-        return true;
-      default:
-        return false;
-      }
-    }
-    return false;
+  private boolean matchTextualCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) {
+    return node.isTextual() &&
+        (primKind == EdmPrimitiveTypeKind.String
+        || primKind == EdmPrimitiveTypeKind.Binary
+        || primKind == EdmPrimitiveTypeKind.Date
+        || primKind == EdmPrimitiveTypeKind.DateTimeOffset
+        || primKind == EdmPrimitiveTypeKind.Duration
+        || primKind == EdmPrimitiveTypeKind.Guid
+        || primKind == EdmPrimitiveTypeKind.TimeOfDay);
   }
 
   @Override
@@ -866,14 +749,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             tree);
       }
       return DeserializerResultImpl.with().property(property).build();
-    } catch (JsonParseException e) {
-      throw new DeserializerException(AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG, e,
-          DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
-    } catch (JsonMappingException e) {
-      throw new DeserializerException(DUPLICATE_JSON_PROPERTY_DETECTED_MSG, e,
-          DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
-    } catch (IOException e) {
-      throw new DeserializerException(AN_IO_EXCEPTION_OCCURRED_MSG, e, DeserializerException.MessageKeys.IO_EXCEPTION);
+    } catch (final IOException e) {
+      throw wrapParseException(e);
     }
   }
 
@@ -906,18 +783,24 @@ public class ODataJsonDeserializer implements ODataDeserializer {
         throw new DeserializerException("Missing entity reference", DeserializerException.MessageKeys.UNKNOWN_CONTENT);
       }
       return DeserializerResultImpl.with().entityReferences(parsedValues).build();
-    } catch (JsonParseException e) {
-      throw new DeserializerException(AN_JSON_PARSE_EXCEPTION_OCCURRED_MSG, e,
+    } catch (final IOException e) {
+      throw wrapParseException(e);
+    } catch (final URISyntaxException e) {
+      throw new DeserializerException("failed to read @odata.id", e,
+          DeserializerException.MessageKeys.UNKNOWN_CONTENT);
+    }
+  }
+
+  private DeserializerException wrapParseException(final IOException e) {
+    if (e instanceof JsonParseException) {
+      return new DeserializerException("A JsonParseException occurred.", e,
           DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
-    } catch (JsonMappingException e) {
-      throw new DeserializerException(DUPLICATE_JSON_PROPERTY_DETECTED_MSG, e,
+    } else if (e instanceof JsonMappingException) {
+      return new DeserializerException("Duplicate json property detected.", e,
           DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
-    } catch (IOException e) {
-      throw new DeserializerException(AN_IO_EXCEPTION_OCCURRED_MSG, e,
+    } else {
+      return new DeserializerException("An IOException occurred.", e,
           DeserializerException.MessageKeys.IO_EXCEPTION);
-    } catch (URISyntaxException e) {
-      throw new DeserializerException("failed to read @odata.id", e,
-          DeserializerException.MessageKeys.UNKNOWN_CONTENT);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
index a762f5c..776868b 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializer.java
@@ -61,6 +61,7 @@ import org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
+import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys;
 import org.apache.olingo.server.core.deserializer.DeserializerResultImpl;
 
 import com.fasterxml.aalto.stax.InputFactoryImpl;
@@ -69,11 +70,9 @@ public class ODataXmlDeserializer implements ODataDeserializer {
 
   private static final XMLInputFactory FACTORY = new InputFactoryImpl();
   private static final String ATOM = "a";
-  private static final String NS_ATOM = "http://www.w3.org/2005/Atom";  
-  private static final QName REF_ELEMENT = new QName("http://docs.oasis-open.org/odata/ns/metadata", "ref");
-  private static final QName PARAMETERS_ELEMENT = 
-      new QName("http://docs.oasis-open.org/odata/ns/metadata", "parameters");
-  private static final QName ID_ATTR = new QName(NS_ATOM, ATOM);
+  private static final QName REF_ELEMENT = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_ENTRY_REF);
+  private static final QName PARAMETERS_ELEMENT = new QName(Constants.NS_METADATA, "parameters");
+  private static final QName ID_ATTR = new QName(Constants.NS_ATOM, ATOM);
 
   private final QName propertiesQName = new QName(Constants.NS_METADATA, Constants.PROPERTIES);
   private final QName propertyValueQName = new QName(Constants.NS_METADATA, Constants.VALUE);
@@ -83,16 +82,7 @@ public class ODataXmlDeserializer implements ODataDeserializer {
   private final QName entryRefQName = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_ENTRY_REF);
   private final QName etagQName = new QName(Constants.NS_METADATA, Constants.ATOM_ATTR_ETAG); 
   private final QName countQName = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_COUNT);
-  
-//  private void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
-//    writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
-//    writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
-//    writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA);
-//    writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES);
-//    writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
-//    writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
-//  }
-  
+
   protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
     return FACTORY.createXMLEventReader(input);
   }
@@ -715,12 +705,12 @@ public class ODataXmlDeserializer implements ODataDeserializer {
   public DeserializerResult actionParameters(InputStream stream, EdmAction edmAction) 
       throws DeserializerException {
     Map<String, Parameter> parameters = new LinkedHashMap<String, Parameter>();
-    if(edmAction.getParameterNames() == null || edmAction.getParameterNames().isEmpty()
-        || (edmAction.isBound() && edmAction.getParameterNames().size() == 1)) {
+    if (edmAction.getParameterNames() == null || edmAction.getParameterNames().isEmpty()
+        || edmAction.isBound() && edmAction.getParameterNames().size() == 1) {
       return DeserializerResultImpl.with().actionParameters(parameters)
           .build();
     }
-        
+
     try {             
       final XMLEventReader reader = getReader(stream);
       while (reader.hasNext()) {
@@ -729,14 +719,26 @@ public class ODataXmlDeserializer implements ODataDeserializer {
           consumeParameters(edmAction, reader, event.asStartElement(), parameters);
         }        
       }
-      // NULL fill for missing parameters
-      Parameter nullParameter = new Parameter();
-      nullParameter.setValue(ValueType.PRIMITIVE, null);
-      for (String param:edmAction.getParameterNames()) {
-        if (parameters.get(param) == null) {
-          parameters.put(param, nullParameter);
+      // EDM checks.
+      for (final String param : edmAction.getParameterNames()) {
+        Parameter parameter = parameters.get(param);
+        if (parameter == null) {
+          final EdmParameter edmParameter = edmAction.getParameter(param);
+          if (!edmParameter.isNullable()) {
+            throw new DeserializerException("Non-nullable parameter not present or null: " + param,
+                MessageKeys.INVALID_NULL_PARAMETER, param);
+          }
+          if (edmParameter.isCollection()) {
+            throw new DeserializerException("Collection must not be null for parameter: " + param,
+                MessageKeys.INVALID_NULL_PARAMETER, param);
+          }
+          // NULL fill for missing parameters.
+          parameter = new Parameter();
+          parameter.setName(param);
+          parameter.setValue(ValueType.PRIMITIVE, null);
+          parameters.put(param, parameter);
         }
-      }      
+      }
       return DeserializerResultImpl.with().actionParameters(parameters)
           .build();
     } catch (XMLStreamException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
index 4e1ba56..27ba073 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
@@ -72,16 +72,16 @@ import org.apache.olingo.server.core.serializer.utils.ExpandSelectHelper;
 
 public class ODataXmlSerializer extends AbstractODataSerializer {
 
-  private static final String DATA = "d";
   private static final String CONTEXT = "context";
   /** The default character set is UTF-8. */
   public static final String DEFAULT_CHARSET = "UTF-8";
   private static final String ATOM = "a";
-  private static final String NS_ATOM = "http://www.w3.org/2005/Atom";
+  private static final String NS_ATOM = Constants.NS_ATOM;
   private static final String METADATA = "m";
-  private static final String NS_METADATA = "http://docs.oasis-open.org/odata/ns/metadata";
-  private static final String NS_DATA = "http://docs.oasis-open.org/odata/ns/data";
-  private static final String NS_SCHEMA = "http://docs.oasis-open.org/odata/ns/scheme";
+  private static final String NS_METADATA = Constants.NS_METADATA;
+  private static final String DATA = "d";
+  private static final String NS_DATA = Constants.NS_DATASERVICES;
+  private static final String NS_SCHEMA = Constants.NS_SCHEME;
 
   @Override
   public SerializerResult serviceDocument(final ServiceMetadata metadata, final String serviceRoot)
@@ -235,7 +235,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
           ContextURLBuilder.create(contextURL).toASCIIString());
       writeMetadataETag(metadata, writer);
 
-      if (options != null) {
+      if (options != null && options.getId() != null) {
         writer.writeStartElement(ATOM, "id", NS_ATOM);
         writer.writeCharacters(options.getId());
         writer.writeEndElement();
@@ -364,16 +364,20 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       writer.writeAttribute(METADATA, NS_METADATA, "etag", entity.getETag());
     }
 
-    writer.writeStartElement(NS_ATOM, "id");
-    writer.writeCharacters(entity.getId().toASCIIString());
-    writer.writeEndElement();
+    if (entity.getId() != null) {
+      writer.writeStartElement(NS_ATOM, "id");
+      writer.writeCharacters(entity.getId().toASCIIString());
+      writer.writeEndElement();
+    }
 
     writerAuthorInfo(entity.getTitle(), writer);
 
-    writer.writeStartElement(NS_ATOM, "link");
-    writer.writeAttribute("rel", "edit");
-    writer.writeAttribute("href", entity.getId().toASCIIString());
-    writer.writeEndElement();
+    if (entity.getId() != null) {
+      writer.writeStartElement(NS_ATOM, "link");
+      writer.writeAttribute("rel", "edit");
+      writer.writeAttribute("href", entity.getId().toASCIIString());
+      writer.writeEndElement();
+    }
 
     if (entityType.hasStream()) {
       writer.writeStartElement(NS_ATOM, "content");
@@ -551,12 +555,14 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     Link link = linked.getNavigationLink(navigationPropertyName);
     if (link == null) {
       link = new Link();
-      link.setRel("http://docs.oasis-open.org/odata/ns/related/" + navigationPropertyName);
+      link.setRel(Constants.NS_NAVIGATION_LINK_REL + navigationPropertyName);
       link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
       link.setTitle(navigationPropertyName);
       EntityCollection target = new EntityCollection();
       link.setInlineEntitySet(target);
-      link.setHref(linked.getId().toASCIIString() + "/" + navigationPropertyName);
+      if (linked.getId() != null) {
+        link.setHref(linked.getId().toASCIIString() + "/" + navigationPropertyName);
+      }
     }
     return link;
   }
@@ -575,7 +581,9 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
     if (link.getTitle() != null) {
       writer.writeAttribute("title", link.getTitle());
     }
-    writer.writeAttribute("href", link.getHref());
+    if (link.getHref() != null) {
+      writer.writeAttribute("href", link.getHref());
+    }
     if (close) {
       writer.writeEndElement();
     }
@@ -606,11 +614,11 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
       SerializerException {
     writer.writeStartElement(DATA, edmProperty.getName(), NS_DATA);
     if (property == null || property.isNull()) {
-      if (edmProperty.isNullable() == Boolean.FALSE) {
+      if (edmProperty.isNullable()) {
+        writer.writeAttribute(METADATA, NS_METADATA, "null", "true");
+      } else {
         throw new SerializerException("Non-nullable property not present!",
             SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
-      } else {
-        writer.writeAttribute(METADATA, NS_METADATA, "null", "true");
       }
     } else {
       writePropertyValue(metadata, edmProperty, property, selectedPaths, writer);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
index 72c34b2..2adf7c2 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/ActionData.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.server.tecsvc.data;
 
 import java.math.BigDecimal;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -31,11 +32,13 @@ import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
 
 public class ActionData {
@@ -101,57 +104,45 @@ public class ActionData {
       throws DataProviderException {
     if ("UARTCTTwoPrimParam".equals(name)) {
       Parameter paramInt16 = parameters.get("ParameterInt16");
-      final Short number = paramInt16 == null ? (short) 32767 : (Short) paramInt16.asPrimitive();
-      return createCTTwoPrimComplexProperty(number, "UARTCTTwoPrimParam string value");
+      final Short number = paramInt16 == null || paramInt16.isNull() ?
+          (short) 32767 :
+          (Short) paramInt16.asPrimitive();
+      return createCTTwoPrimComplexProperty(name, number, "UARTCTTwoPrimParam string value");
     }
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
-  private static Property createCTTwoPrimComplexProperty(final Short number, final String text) {
-    ComplexValue compValue = new ComplexValue();
-    Property propInt = new Property();
-    propInt.setName("PropertyInt16");
-    propInt.setValue(ValueType.PRIMITIVE, number);
-    compValue.getValue().add(propInt);
-    Property propString = new Property();
-    propString.setName("PropertyString");
-    propString.setValue(ValueType.PRIMITIVE, text);
-    compValue.getValue().add(propString);
-
-    Property complexProp = new Property();
-    complexProp.setValue(ValueType.COMPLEX, compValue);
-    return complexProp;
+  private static Property createCTTwoPrimComplexProperty(final String name, final Short number, final String text) {
+    return DataCreator.createComplex(name,
+        DataCreator.createPrimitive("PropertyInt16", number),
+        DataCreator.createPrimitive("PropertyString", text));
   }
 
   protected static Property complexCollectionAction(final String name, final Map<String, Parameter> parameters)
       throws DataProviderException {
     if ("UARTCollCTTwoPrimParam".equals(name)) {
       List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
-      complexCollection.add(createCTTwoPrimComplexProperty((short) 16, "Test123").asComplex());
-      complexCollection.add(createCTTwoPrimComplexProperty((short) 17, "Test456").asComplex());
-      complexCollection.add(createCTTwoPrimComplexProperty((short) 18, "Test678").asComplex());
-
-      Parameter paramInt16 = parameters.get("ParameterInt16");
-      if (paramInt16 != null) {
-        Short number = (Short) paramInt16.asPrimitive();
-        if (number < 0) {
-          complexCollection.clear();
-        } else if (number >= 0 && number < complexCollection.size()) {
-          complexCollection = complexCollection.subList(0, number);
-        }
-        Property complexCollProperty = new Property();
-        complexCollProperty.setValue(ValueType.COLLECTION_COMPLEX, complexCollection);
-        return complexCollProperty;
+      final Parameter paramInt16 = parameters.get("ParameterInt16");
+      final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive();
+      if (number >= 1) {
+        complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 16, "Test123").asComplex());
       }
+      if (number >= 2) {
+        complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 17, "Test456").asComplex());
+      }
+      if (number >= 3) {
+        complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 18, "Test678").asComplex());
+      }
+      return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
     }
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
   protected static EntityActionResult entityAction(final String name, final Map<String, Parameter> parameters,
-      final Map<String, EntityCollection> data) throws DataProviderException {
+      final Map<String, EntityCollection> data, final OData oData, final Edm edm) throws DataProviderException {
     if ("UARTETTwoKeyTwoPrimParam".equals(name)) {
       Parameter parameter = parameters.get("ParameterInt16");
-      final Short number = parameter == null ? 0 : (Short) parameter.asPrimitive();
+      final Short number = parameter == null || parameter.isNull() ? 0 : (Short) parameter.asPrimitive();
 
       EntityCollection entityCollection = data.get("ESTwoKeyTwoPrim");
       for (Entity entity : entityCollection.getEntities()) {
@@ -180,7 +171,8 @@ public class ActionData {
             }
           }
         } while (!freeKey);
-        return new EntityActionResult().setEntity(createAllPrimEntity(key, "UARTETAllPrimParam string value", date))
+        return new EntityActionResult().setEntity(
+            createAllPrimEntity(key, "UARTETAllPrimParam string value", date, oData, edm))
             .setCreated(true);
       } else {
         return new EntityActionResult().setEntity(entityCollection.getEntities().get(0));
@@ -189,8 +181,9 @@ public class ActionData {
     throw new DataProviderException("Action " + name + " is not yet implemented.");
   }
 
-  private static Entity createAllPrimEntity(final Short key, final String val, final Calendar date) {
-    return new Entity().addProperty(DataCreator.createPrimitive("PropertyInt16", key))
+  private static Entity createAllPrimEntity(final Short key, final String val, final Calendar date,
+      final OData oData, final Edm edm) throws DataProviderException {
+    Entity entity = new Entity().addProperty(DataCreator.createPrimitive("PropertyInt16", key))
         .addProperty(DataCreator.createPrimitive("PropertyString", val))
         .addProperty(DataCreator.createPrimitive("PropertyBoolean", false))
         .addProperty(DataCreator.createPrimitive("PropertyByte", null))
@@ -206,28 +199,31 @@ public class ActionData {
         .addProperty(DataCreator.createPrimitive("PropertyDuration", null))
         .addProperty(DataCreator.createPrimitive("PropertyGuid", null))
         .addProperty(DataCreator.createPrimitive("PropertyTimeOfDay", null));
+    setEntityId(entity, "ESAllPrim", oData, edm);
+    return entity;
   }
 
-  protected static EntityCollection entityCollectionAction(final String name, final Map<String, Parameter> parameters)
-      throws DataProviderException {
+  protected static EntityCollection entityCollectionAction(final String name, final Map<String, Parameter> parameters,
+      final OData oData, final Edm edm) throws DataProviderException {
     if ("UARTCollETKeyNavParam".equals(name)) {
-      Parameter paramInt16 = parameters.get("ParameterInt16");
-      final Short number = paramInt16 == null ? 0 : (Short) paramInt16.asPrimitive();
       EntityCollection collection = new EntityCollection();
+      Parameter paramInt16 = parameters.get("ParameterInt16");
+      final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive();
       if (number > 0) {
         for (short i = 1; i <= number; i++) {
-          collection.getEntities().add(createETKeyNavEntity(i));
+          collection.getEntities().add(createETKeyNavEntity(i, oData, edm));
         }
       }
       return collection;
     } else if ("UARTCollETAllPrimParam".equals(name)) {
-      Parameter paramTimeOfDay = parameters.get("ParameterTimeOfDay");
       EntityCollection collection = new EntityCollection();
-      if (paramTimeOfDay != null) {
+      Parameter paramTimeOfDay = parameters.get("ParameterTimeOfDay");
+      if (paramTimeOfDay != null && !paramTimeOfDay.isNull()) {
         Calendar timeOfDay = (Calendar) paramTimeOfDay.asPrimitive();
         int count = timeOfDay.get(Calendar.HOUR_OF_DAY);
         for (short i = 1; i <= count; i++) {
-          collection.getEntities().add(createAllPrimEntity(i, "UARTCollETAllPrimParam int16 value: " + i, null));
+          collection.getEntities().add(
+              createAllPrimEntity(i, "UARTCollETAllPrimParam int16 value: " + i, null, oData, edm));
         }
       }
       return collection;
@@ -236,8 +232,9 @@ public class ActionData {
   }
 
   @SuppressWarnings("unchecked")
-  private static Entity createETKeyNavEntity(final Short number) {
-    return new Entity()
+  private static Entity createETKeyNavEntity(final Short number, final OData oData, final Edm edm)
+      throws DataProviderException {
+    Entity entity = new Entity()
         .addProperty(DataCreator.createPrimitive("PropertyInt16", number))
         .addProperty(DataCreator.createPrimitive("PropertyString", "UARTCollETKeyNavParam int16 value: " + number))
         .addProperty(DataCreator.createComplex("PropertyCompNav", 
@@ -253,6 +250,18 @@ public class ActionData {
             DataCreator.createPrimitive("PropertyString", ""),
             DataCreator.createComplex("PropertyCompNav", 
                 DataCreator.createPrimitive("PropertyInt16", (short) 0))));
+    setEntityId(entity, "ESKeyNav", oData, edm);
+    return entity;
+  }
+
+  private static void setEntityId(Entity entity, final String entitySetName, final OData oData, final Edm edm)
+      throws DataProviderException {
+    try {
+      entity.setId(URI.create(oData.createUriHelper().buildCanonicalURL(
+          edm.getEntityContainer().getEntitySet(entitySetName), entity)));
+    } catch (final SerializerException e) {
+      throw new DataProviderException("Unable to set entity ID!", e);
+    }
   }
 
   protected static Property createKeyNavAllPrimComplexValue(final String name) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index 1d3ef71..f9e2ee2 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -77,9 +77,12 @@ public class DataProvider {
   }
 
   public EntityCollection readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
-    final EntityCollection entityCollection = data.get(edmEntitySet.getName());
-
-    return (entityCollection == null) ? createEntityCollection(edmEntitySet) : entityCollection;
+    EntityCollection entityCollection = data.get(edmEntitySet.getName());
+    if (entityCollection == null) {
+      entityCollection = new EntityCollection();
+      data.put(edmEntitySet.getName(), entityCollection);
+    }
+    return entityCollection;
   }
 
   public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
@@ -146,7 +149,7 @@ public class DataProvider {
     final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
     EntityCollection entitySet = readAll(edmEntitySet);
     final List<Entity> entities = entitySet.getEntities();
-    final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
+    final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntityType);
     Entity newEntity = new Entity();
     newEntity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
     for (final String keyName : edmEntityType.getKeyPredicateNames()) {
@@ -163,14 +166,6 @@ public class DataProvider {
 
     return newEntity;
   }
-  
-  private EntityCollection createEntityCollection(final EdmEntitySet edmEntitySet) {
-    if(data.get(edmEntitySet.getName()) == null ) {
-      data.put(edmEntitySet.getName(), new EntityCollection());
-    }
-    
-    return data.get(edmEntitySet.getName());
-  }
 
   private Map<String, Object> findFreeComposedKey(final List<Entity> entities, final EdmEntityType entityType)
       throws DataProviderException {
@@ -545,12 +540,12 @@ public class DataProvider {
 
   public EntityActionResult processActionEntity(final String name, final Map<String, Parameter> actionParameters)
       throws DataProviderException {
-    return ActionData.entityAction(name, actionParameters, data);
+    return ActionData.entityAction(name, actionParameters, data, odata, edm);
   }
 
   public EntityCollection processActionEntityCollection(final String name,
       final Map<String, Parameter> actionParameters) throws DataProviderException {
-    return ActionData.entityCollectionAction(name, actionParameters);
+    return ActionData.entityCollectionAction(name, actionParameters, odata, edm);
   }
   
   public void createReference(final Entity entity, final EdmNavigationProperty navigationProperty, final URI entityId, 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/ActionDataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/ActionDataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/ActionDataProviderTest.java
index 199f0f1..3cb1b09 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/ActionDataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/ActionDataProviderTest.java
@@ -161,7 +161,7 @@ public class ActionDataProviderTest {
     paramInt16.setValue(ValueType.PRIMITIVE, new Short((short) 32767));
     final Map<String, Parameter> parameters = Collections.singletonMap("ParameterInt16", paramInt16);
 
-    EntityActionResult result = ActionData.entityAction("UARTETTwoKeyTwoPrimParam", parameters, data);
+    EntityActionResult result = ActionData.entityAction("UARTETTwoKeyTwoPrimParam", parameters, data, oData, edm);
     assertNotNull(result);
     assertFalse(result.isCreated());
     assertEquals((short) 32767, result.getEntity().getProperty("PropertyInt16").asPrimitive());
@@ -175,7 +175,7 @@ public class ActionDataProviderTest {
     final Map<String, Parameter> parameters = Collections.singletonMap("ParameterInt16", paramInt16);
 
     try {
-      ActionData.entityAction("UARTETTwoKeyTwoPrimParam", parameters, data);
+      ActionData.entityAction("UARTETTwoKeyTwoPrimParam", parameters, data, oData, edm);
       fail("Expected a DataProviderException but wasn't thrown");
     } catch (DataProviderException e) {
       assertEquals("Entity not found with key: 12345", e.getMessage());
@@ -186,7 +186,7 @@ public class ActionDataProviderTest {
   @Test
   public void actionUARTETAllPrimParamWithoutParam() throws Exception {
     final EntityActionResult result = ActionData.entityAction("UARTETAllPrimParam",
-        Collections.<String, Parameter> emptyMap(), data);
+        Collections.<String, Parameter> emptyMap(), data, oData, edm);
     assertNotNull(result);
     assertFalse(result.isCreated());
     assertEquals(Short.MAX_VALUE, result.getEntity().getProperty("PropertyInt16").asPrimitive());
@@ -199,7 +199,7 @@ public class ActionDataProviderTest {
     paramDate.setValue(ValueType.PRIMITIVE, null);
     final Map<String, Parameter> parameters = Collections.singletonMap("ParameterDate", paramDate);
 
-    EntityActionResult result = ActionData.entityAction("UARTETAllPrimParam", parameters, data);
+    EntityActionResult result = ActionData.entityAction("UARTETAllPrimParam", parameters, data, oData, edm);
     assertNotNull(result);
     assertTrue(result.isCreated());
     assertEquals((short) 1, result.getEntity().getProperty("PropertyInt16").asPrimitive());
@@ -212,7 +212,7 @@ public class ActionDataProviderTest {
     paramInt16.setValue(ValueType.PRIMITIVE, Short.valueOf((short) 5));
     final Map<String, Parameter> parameters = Collections.singletonMap("ParameterInt16", paramInt16);
 
-    EntityCollection result = ActionData.entityCollectionAction("UARTCollETKeyNavParam", parameters);
+    EntityCollection result = ActionData.entityCollectionAction("UARTCollETKeyNavParam", parameters, oData, edm);
     assertNotNull(result);
     assertEquals(5, result.getEntities().size());
   }
@@ -224,7 +224,7 @@ public class ActionDataProviderTest {
     paramTimeOfDay.setValue(ValueType.PRIMITIVE, getTime(5, 0, 0));
     final Map<String, Parameter> parameters = Collections.singletonMap("ParameterTimeOfDay", paramTimeOfDay);
 
-    EntityCollection result = ActionData.entityCollectionAction("UARTCollETAllPrimParam", parameters);
+    EntityCollection result = ActionData.entityCollectionAction("UARTCollETAllPrimParam", parameters, oData, edm);
     assertNotNull(result);
     assertEquals(5, result.getEntities().size());
   }
@@ -232,7 +232,7 @@ public class ActionDataProviderTest {
   @Test
   public void actionUARTCollETAllPrimParamNoParam() throws Exception {
     final EntityCollection result = ActionData.entityCollectionAction("UARTCollETAllPrimParam",
-        Collections.<String, Parameter> emptyMap());
+        Collections.<String, Parameter> emptyMap(), oData, edm);
     assertNotNull(result);
     assertEquals(0, result.getEntities().size());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/AbstractODataDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/AbstractODataDeserializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/AbstractODataDeserializerTest.java
new file mode 100644
index 0000000..c90ad6d
--- /dev/null
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/AbstractODataDeserializerTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.deserializer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+
+public class AbstractODataDeserializerTest {
+
+  protected static final String NAMESPACE = "Namespace1_Alias";
+  protected static final Edm edm = OData.newInstance()
+      .createServiceMetadata(new EdmTechProvider(), Collections.<EdmxReference> emptyList())
+      .getEdm();
+
+  protected InputStream getFileAsStream(final String filename) throws IOException {
+    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
+    if (in == null) {
+      throw new IOException("Requested file '" + filename + "' was not found.");
+    }
+    return in;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
deleted file mode 100644
index 5cc025d..0000000
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/AbstractODataDeserializerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.deserializer.json;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
-
-public class AbstractODataDeserializerTest {
-  protected static final ContentType CONTENT_TYPE_JSON = ContentType.JSON;
-  protected static final ContentType CONTENT_TYPE_JSON_IEEE754Compatible = 
-      ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true");
-  
-  protected static final Edm edm = OData.newInstance().createServiceMetadata(
-      new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
-
-  protected InputStream getFileAsStream(final String filename) throws IOException {
-    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
-    if (in == null) {
-      throw new IOException("Requested file '" + filename + "' was not found.");
-    }
-    return in;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
index 7bae022..8b87a12 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
@@ -21,25 +21,24 @@ package org.apache.olingo.server.core.deserializer.json;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
+import java.io.IOException;
 
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.OData;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.junit.Test;
 
 public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTest {
+
   @Test
   public void esAllPrimExpandedToOne() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json");
-    Entity entity = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType).getEntity();
+    final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json");
+
     Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimOne");
     assertNotNull(navigationLink);
 
@@ -51,16 +50,12 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
 
   @Test
   public void esAllPrimExpandedToOneWithODataAnnotations() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json");
-    OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
+    deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json");
   }
 
   @Test
   public void esAllPrimExpandedToMany() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json");
-    Entity entity = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType).getEntity();
+    final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json");
 
     Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimMany");
     assertNotNull(navigationLink);
@@ -74,61 +69,46 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
 
   @Test
   public void esAllPrimExpandedToManyWithODataAnnotations() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json");
-    OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
+    deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json");
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void esAllPrimExpandedToOneWithCustomAnnotations() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json");
     try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
+      deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json");
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
       assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
     }
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void esAllPrimExpandedToManyWithCustomAnnotations() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json");
     try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
+      deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json");
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
       assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
     }
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void expandedToOneInvalidNullValue() throws Exception {
-    String entityString =
+    ODataJsonDeserializerEntityTest.expectException(
         "{\"PropertyInt16\":32767,"
             + "\"NavPropertyETTwoPrimOne\":null"
-            + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+            + "}",
+        "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
   @Test
   public void expandedToOneValidNullValue() throws Exception {
-    String entityString =
+    final Entity entity = ODataJsonDeserializerEntityTest.deserialize(
         "{\"PropertyInt16\":32767,"
             + "\"NavPropertyETAllPrimOne\":null"
-            + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoPrim"));
-    final Entity entity = OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType)
-        .getEntity();
+            + "}",
+        "ETTwoPrim");
 
     assertEquals(1, entity.getNavigationLinks().size());
     final Link link = entity.getNavigationLinks().get(0);
@@ -138,51 +118,38 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
     assertNull(link.getInlineEntitySet());
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void expandedToOneInvalidStringValue() throws Exception {
-    String entityString =
+    ODataJsonDeserializerEntityTest.expectException(
         "{\"PropertyInt16\":32767,"
             + "\"NavPropertyETTwoPrimOne\":\"First Resource - positive values\""
-            + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+            + "}",
+        "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void expandedToManyInvalidNullValue() throws Exception {
-    String entityString =
+    ODataJsonDeserializerEntityTest.expectException(
         "{\"PropertyInt16\":32767,"
             + "\"NavPropertyETTwoPrimMany\":null"
-            + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+            + "}",
+        "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_NULL_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void expandedToManyInvalidStringValue() throws Exception {
-    String entityString =
+    ODataJsonDeserializerEntityTest.expectException(
         "{\"PropertyInt16\":32767,"
             + "\"NavPropertyETTwoPrimMany\":\"First Resource - positive values\""
-            + "}";
-    InputStream stream = new ByteArrayInputStream(entityString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entity(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+            + "}",
+        "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY);
+  }
+
+  private Entity deserialize(final String resourceName) throws IOException, DeserializerException {
+    return ODataJsonDeserializerEntityTest.deserialize(getFileAsStream(resourceName),
+        "ETAllPrim", ContentType.JSON);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
index 49b476d..4b2c6c3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.server.core.deserializer.json;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
@@ -30,22 +31,18 @@ import java.util.List;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
 import org.junit.Test;
 
 public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserializerTest {
 
   @Test
   public void esAllPrim() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("ESAllPrim.json");
-    EntityCollection entitySet =
-        OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType)
-            .getEntityCollection();
-
+    final EntityCollection entitySet = deserialize(getFileAsStream("ESAllPrim.json"), "ETAllPrim");
     assertNotNull(entitySet);
     assertEquals(3, entitySet.getEntities().size());
 
@@ -75,12 +72,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
 
   @Test
   public void eSCompCollComp() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
-    InputStream stream = getFileAsStream("ESCompCollComp.json");
-    EntityCollection entitySet =
-        OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType)
-            .getEntityCollection();
-
+    final EntityCollection entitySet = deserialize(getFileAsStream("ESCompCollComp.json"), "ETCompCollComp");
     assertNotNull(entitySet);
     assertEquals(2, entitySet.getEntities().size());
 
@@ -89,172 +81,115 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
 
   @Test
   public void esAllPrimODataAnnotationsAreIgnored() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("ESAllPrimWithODataAnnotations.json");
-    OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
+    deserialize(getFileAsStream("ESAllPrimWithODataAnnotations.json"), "ETAllPrim");
   }
 
   @Test
   public void emptyETAllPrim() throws Exception {
     String entityCollectionString = "{\"value\" : []}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    EntityCollection entityCollection =
-        OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType)
-            .getEntityCollection();
+    final EntityCollection entityCollection = deserialize(entityCollectionString, "ETAllPrim");
     assertNotNull(entityCollection.getEntities());
     assertTrue(entityCollection.getEntities().isEmpty());
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void esAllPrimCustomAnnotationsLeadToNotImplemented() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("ESAllPrimWithCustomAnnotations.json");
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
-    }
+    expectException(getFileAsStream("ESAllPrimWithCustomAnnotations.json"), "ETAllPrim",
+        DeserializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void esAllPrimDoubleKeysLeadToException() throws Exception {
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    InputStream stream = getFileAsStream("ESAllPrimWithDoubleKey.json");
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.DUPLICATE_JSON_PROPERTY, e.getMessageKey());
-      throw e;
-    }
+    expectException(getFileAsStream("ESAllPrimWithDoubleKey.json"), "ETAllPrim",
+        DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongValueTagJsonValueNull() throws Exception {
-    String entityCollectionString = "{\"value\" : null}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : null}", "ETAllPrim",
+        DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongValueTagJsonValueNumber() throws Exception {
-    String entityCollectionString = "{\"value\" : 1234}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : 1234}", "ETAllPrim",
+        DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongValueTagJsonValueObject() throws Exception {
-    String entityCollectionString = "{\"value\" : {}}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : {}}", "ETAllPrim",
+        DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void valueTagMissing() throws Exception {
-    String entityCollectionString = "{}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.VALUE_ARRAY_NOT_PRESENT, e.getMessageKey());
-      throw e;
-    }
+    expectException("{}", "ETAllPrim",
+        DeserializerException.MessageKeys.VALUE_ARRAY_NOT_PRESENT);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongValueInValueArrayNumber() throws Exception {
-    String entityCollectionString = "{\"value\" : [1234,123]}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_ENTITY, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : [1234,123]}", "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_ENTITY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void wrongValueInValueArrayNestedArray() throws Exception {
-    String entityCollectionString = "{\"value\" : [[],[]]}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.INVALID_ENTITY, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : [[],[]]}", "ETAllPrim",
+        DeserializerException.MessageKeys.INVALID_ENTITY);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void invalidJsonSyntax() throws Exception {
-    String entityCollectionString = "{\"value\" : }";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\" : }", "ETAllPrim",
+        DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void emptyInput() throws Exception {
-    OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(
-        new ByteArrayInputStream(new byte[] {}),
-        edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+    expectException("", "ETAllPrim", DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void unknownContentInCollection() throws Exception {
-    String entityCollectionString = "{\"value\" : [],"
-        + "\"unknown\":null"
-        + "}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.UNKNOWN_CONTENT, e.getMessageKey());
-      throw e;
-    }
+    expectException("{\"value\":[],\"unknown\":null}", "ETAllPrim",
+        DeserializerException.MessageKeys.UNKNOWN_CONTENT);
   }
 
-  @Test(expected = DeserializerException.class)
+  @Test
   public void customAnnotationNotSupportedYet() throws Exception {
-    String entityCollectionString = "{\"value\" : [],"
-        + "\"@custom.annotation\":null"
-        + "}";
-    InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
-    EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
+    expectException("{\"value\": [], \"@custom.annotation\": null}", "ETAllPrim",
+        DeserializerException.MessageKeys.NOT_IMPLEMENTED);
+  }
+
+  private EntityCollection deserialize(final InputStream stream, final String entityTypeName)
+      throws DeserializerException {
+    return OData.newInstance().createDeserializer(ContentType.JSON)
+        .entityCollection(stream, edm.getEntityType(new FullQualifiedName(NAMESPACE, entityTypeName)))
+        .getEntityCollection();
+  }
+
+  private EntityCollection deserialize(final String input, final String entityTypeName)
+      throws DeserializerException {
+    return OData.newInstance().createDeserializer(ContentType.JSON)
+        .entityCollection(new ByteArrayInputStream(input.getBytes()),
+            edm.getEntityType(new FullQualifiedName(NAMESPACE, entityTypeName)))
+        .getEntityCollection();
+  }
+
+  private void expectException(final InputStream stream, final String entityTypeName,
+      final DeserializerException.MessageKeys messageKey) {
     try {
-      OData.newInstance().createDeserializer(CONTENT_TYPE_JSON).entityCollection(stream, edmEntityType);
-    } catch (DeserializerException e) {
-      assertEquals(DeserializerException.MessageKeys.NOT_IMPLEMENTED, e.getMessageKey());
-      throw e;
+      deserialize(stream, entityTypeName);
+      fail("Expected exception not thrown.");
+    } catch (final DeserializerException e) {
+      assertEquals(messageKey, e.getMessageKey());
     }
   }
+
+  private void expectException(final String entityCollectionString, final String entityTypeName,
+    final DeserializerException.MessageKeys messageKey) {
+    expectException(new ByteArrayInputStream(entityCollectionString.getBytes()), entityTypeName, messageKey);
+  }
 }


[09/11] olingo-odata4 git commit: [OLINGO-789] server support for action parameters of all types

Posted by mi...@apache.org.
[OLINGO-789] server support for action parameters of all types

Signed-off-by: Michael Bolz <mi...@sap.com>


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

Branch: refs/heads/olingo786
Commit: d6db341db734266536d5177dcb749eae0683c2c7
Parents: b9403cd
Author: Klaus Straubinger <kl...@sap.com>
Authored: Thu Oct 1 10:20:44 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Oct 1 12:11:33 2015 +0200

----------------------------------------------------------------------
 .../client/AbstractParamTecSvcITCase.java       |  18 +
 .../fit/tecsvc/client/AbstractTecSvcITCase.java |  28 +-
 .../fit/tecsvc/client/ActionImportITCase.java   |  11 +-
 .../fit/tecsvc/client/AsyncSupportITCase.java   |  24 +-
 .../fit/tecsvc/client/DeepInsertITCase.java     | 886 +++++++++--------
 .../fit/tecsvc/client/DeepInsertXmlITCase.java  | 950 -------------------
 .../ExpandWithSystemQueryOptionsITCase.java     |  12 +-
 .../commons/api/edm/EdmNavigationProperty.java  |   2 +-
 .../olingo/commons/api/edm/EdmParameter.java    |   2 +-
 .../olingo/commons/api/edm/EdmProperty.java     |   4 +-
 .../olingo/commons/api/edm/EdmReturnType.java   |   2 +-
 .../apache/olingo/server/core/ODataImpl.java    |   7 +-
 .../json/ODataJsonDeserializer.java             | 389 +++-----
 .../deserializer/xml/ODataXmlDeserializer.java  |  52 +-
 .../core/serializer/xml/ODataXmlSerializer.java |  46 +-
 .../olingo/server/tecsvc/data/ActionData.java   | 101 +-
 .../olingo/server/tecsvc/data/DataProvider.java |  23 +-
 .../tecsvc/data/ActionDataProviderTest.java     |  14 +-
 .../AbstractODataDeserializerTest.java          |  44 +
 .../json/AbstractODataDeserializerTest.java     |  46 -
 .../json/ODataDeserializerDeepInsertTest.java   | 125 +--
 .../ODataDeserializerEntityCollectionTest.java  | 205 ++--
 ...ataJsonDeserializerActionParametersTest.java | 350 +++----
 .../json/ODataJsonDeserializerEntityTest.java   | 678 ++++---------
 ...DataXMLDeserializerActionParametersTest.java | 350 +++----
 .../xml/ODataXmlDeserializerTest.java           | 211 ++--
 .../core/uri/antlr/TestUriParserImpl.java       |  11 +-
 27 files changed, 1549 insertions(+), 3042 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
index 2d45d79..d6e35a3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractParamTecSvcITCase.java
@@ -18,6 +18,11 @@
  */
 package org.apache.olingo.fit.tecsvc.client;
 
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Arrays;
 import java.util.List;
 
@@ -45,4 +50,17 @@ public abstract class AbstractParamTecSvcITCase extends AbstractTecSvcITCase {
   protected ContentType getContentType() {
     return contentType;
   }
+
+  protected void assertContentType(final String content) {
+    assertThat(content, startsWith(contentType.toContentTypeString()));
+  }
+
+  protected boolean isJson() {
+    return ContentType.JSON.isCompatible(contentType);
+  }
+
+  protected void assertShortOrInt(final int value, final Object n) {
+    assertTrue(n instanceof Number);
+    assertEquals(value, ((Number) n).intValue());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractTecSvcITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractTecSvcITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractTecSvcITCase.java
index 1333644..c74f345 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractTecSvcITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AbstractTecSvcITCase.java
@@ -18,11 +18,6 @@
  */
 package org.apache.olingo.fit.tecsvc.client;
 
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
 import java.util.Collection;
 
 import org.apache.olingo.client.api.EdmEnabledODataClient;
@@ -61,22 +56,7 @@ public abstract class AbstractTecSvcITCase extends AbstractBaseTestITCase {
     }
   }
 
-  protected void assertShortOrInt(final int value, final Object n) {
-    assertTrue(n instanceof Number);
-    assertEquals(value, ((Number) n).intValue());
-  }
-
-  protected void assertContentType(final String content) {
-    assertThat(content, containsString(getContentType().toContentTypeString()));
-  }
-
-  protected ContentType getContentType() {
-    return ContentType.APPLICATION_JSON;
-  }
-
-  protected boolean isJson() {
-    return ContentType.JSON.isCompatible(getContentType());
-  }
+  protected abstract ContentType getContentType();
 
   @Override
   protected ODataClient getClient() {
@@ -85,12 +65,8 @@ public abstract class AbstractTecSvcITCase extends AbstractBaseTestITCase {
     return odata;
   }
 
-  protected EdmEnabledODataClient getClient(final String serviceRoot) {
-    return ODataClientFactory.getEdmEnabledClient(serviceRoot, getContentType());
-  }
-
   protected EdmEnabledODataClient getEdmEnabledClient() {
-    return getClient(SERVICE_URI);
+    return ODataClientFactory.getEdmEnabledClient(SERVICE_URI, getContentType());
   }
 
   protected ClientObjectFactory getFactory() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
index b7671cb..c21671b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ActionImportITCase.java
@@ -21,6 +21,7 @@ package org.apache.olingo.fit.tecsvc.client;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 import java.math.BigDecimal;
 import java.net.URI;
@@ -42,13 +43,12 @@ import org.apache.olingo.client.api.domain.ClientInvokeResult;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
 import org.junit.Test;
 
-public class ActionImportITCase extends AbstractTecSvcITCase {
+public class ActionImportITCase extends AbstractParamTecSvcITCase {
 
   @Test
   public void noReturnTypeAction() throws Exception {
@@ -293,6 +293,8 @@ public class ActionImportITCase extends AbstractTecSvcITCase {
 
   private <T extends ClientInvokeResult> ODataInvokeResponse<T> callAction(final String name,
       final Class<T> resultRef, final Map<String, ClientValue> parameters, final boolean returnMinimal) {
+    assumeTrue("The client would send wrongly formatted parameters in XML.",
+        parameters == null || parameters.isEmpty() || isJson());  // TODO: XML case
     final URI actionURI = getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment(name).build();
     ODataInvokeRequest<T> request = getClient().getInvokeRequestFactory()
         .getActionInvokeRequest(actionURI, resultRef, parameters);
@@ -309,9 +311,4 @@ public class ActionImportITCase extends AbstractTecSvcITCase {
     }
     return response;
   }
-
-  @Override
-  protected ContentType getContentType() {
-    return ContentType.APPLICATION_JSON;
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
index f447bbc..f6893d1 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
@@ -48,13 +48,12 @@ import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.PreferenceName;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.junit.Test;
 
-public final class AsyncSupportITCase extends AbstractTecSvcITCase {
+public final class AsyncSupportITCase extends AbstractParamTecSvcITCase {
 
   private static final String ES_ALL_PRIM = "ESAllPrim";
   private static final String NAV_PROPERTY_ET_TWO_PRIM_ONE = "NavPropertyETTwoPrimOne";
@@ -70,7 +69,7 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
 
     final ODataRetrieveResponse<ClientEntity> response = client.getRetrieveRequestFactory()
         .getEntityRequest(uri).execute();
-    assertEquals(32767, response.getBody().getProperty("PropertyInt16").getPrimitiveValue().toValue());
+    assertShortOrInt(32767, response.getBody().getProperty("PropertyInt16").getPrimitiveValue().toValue());
     assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
 
     // first async request
@@ -98,9 +97,8 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
     assertNotNull(first.getODataResponse());
     ODataResponse firstResponse = first.getODataResponse();
     assertEquals(HttpStatusCode.OK.getStatusCode(), firstResponse.getStatusCode());
-    ResWrap<Entity> entity = client.getDeserializer(ContentType.APPLICATION_JSON)
-        .toEntity(firstResponse.getRawResponse());
-    assertEquals(32767, entity.getPayload().getProperty("PropertyInt16").asPrimitive());
+    ResWrap<Entity> entity = client.getDeserializer(getContentType()).toEntity(firstResponse.getRawResponse());
+    assertShortOrInt(32767, entity.getPayload().getProperty("PropertyInt16").asPrimitive());
     assertEquals("First Resource - positive values", entity.getPayload().getProperty("PropertyString").asPrimitive());
   }
 
@@ -144,12 +142,12 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
     assertEquals(HttpStatusCode.OK.getStatusCode(), firstResponse.getStatusCode());
     assertEquals(2, firstResponse.getHeaderNames().size());
     assertEquals("4.0", firstResponse.getHeader(HttpHeader.ODATA_VERSION).iterator().next());
-    ResWrap<EntityCollection> firWrap = client.getDeserializer(ContentType.APPLICATION_JSON)
+    ResWrap<EntityCollection> firWrap = client.getDeserializer(getContentType())
         .toEntitySet(firstResponse.getRawResponse());
     EntityCollection firstResponseEntitySet = firWrap.getPayload();
     assertEquals(3, firstResponseEntitySet.getEntities().size());
     Entity firstResponseEntity = firstResponseEntitySet.getEntities().get(0);
-    assertEquals(32767, firstResponseEntity.getProperty("PropertyInt16").asPrimitive());
+    assertShortOrInt(32767, firstResponseEntity.getProperty("PropertyInt16").asPrimitive());
     assertEquals("First Resource - positive values", firstResponseEntity.getProperty("PropertyString").asPrimitive());
   }
 
@@ -190,7 +188,7 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
     assertNotNull(createdEntity);
     final ClientProperty property1 = createdEntity.getProperty("PropertyInt64");
     assertNotNull(property1);
-    assertEquals(42, property1.getPrimitiveValue().toValue());
+    assertShortOrInt(42, property1.getPrimitiveValue().toValue());
     final ClientProperty property2 = createdEntity.getProperty("PropertyDecimal");
     assertNotNull(property2);
     assertNull(property2.getPrimitiveValue());
@@ -220,7 +218,7 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
     assertEquals("4.0", firstResponse.getHeader(HttpHeader.ODATA_VERSION).iterator().next());
 
     final ClientEntity entity = firstResponse.getBody();
-    assertEquals(32767, entity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
+    assertShortOrInt(32767, entity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
     assertEquals("First Resource - positive values",
         entity.getProperty("PropertyString").getPrimitiveValue().toValue());
   }
@@ -266,11 +264,11 @@ public final class AsyncSupportITCase extends AbstractTecSvcITCase {
     return client.getRetrieveRequestFactory().getEntityRequest(uri);
   }
 
-  private void checkEntityAvailableWith(ClientEntitySet entitySet, String property, Object value) {
+  private void checkEntityAvailableWith(ClientEntitySet entitySet, String property, int value) {
     for (ClientEntity entity : entitySet.getEntities()) {
-      ClientProperty ep = entity.getProperty("PropertyInt16");
+      ClientProperty ep = entity.getProperty(property);
       if (ep != null) {
-        assertEquals(value, ep.getPrimitiveValue().toValue());
+        assertShortOrInt(value, ep.getPrimitiveValue().toValue());
         return;
       }
     }


[03/11] olingo-odata4 git commit: [OLINGO-780] The URI Parser validates if a function is composable or not

Posted by mi...@apache.org.
[OLINGO-780] The URI Parser validates if a function is composable or not


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

Branch: refs/heads/olingo786
Commit: b9403cd39433ba6d66054c92d02974e3187f401f
Parents: b7dcae8
Author: Christia Holzer <c....@sap.com>
Authored: Wed Sep 30 11:22:29 2015 +0200
Committer: Christia Holzer <c....@sap.com>
Committed: Wed Sep 30 15:04:24 2015 +0200

----------------------------------------------------------------------
 .../uri/validator/UriValidationException.java   |  4 +-
 .../server/core/uri/validator/UriValidator.java | 36 ++++++++++-
 .../server-core-exceptions-i18n.properties      |  1 +
 .../tecsvc/provider/FunctionProvider.java       |  2 +-
 .../olingo/server/core/ODataHandlerTest.java    | 24 ++++---
 .../core/uri/antlr/TestFullResourcePath.java    | 66 ++++++++++++++++++++
 6 files changed, 120 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
index 5760e88..d883b0c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
@@ -52,7 +52,9 @@ public class UriValidationException extends ODataLibraryException {
     /** parameter: unallowed kind before $value */
     UNALLOWED_KIND_BEFORE_VALUE,
     /** parameter: unallowed kind before $count */
-    UNALLOWED_KIND_BEFORE_COUNT;
+    UNALLOWED_KIND_BEFORE_COUNT, 
+    /** parameter: unallowed resource path */
+    UNALLOWED_RESOURCE_PATH;
 
     @Override
     public String getKey() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
index 8693f1e..feb52ec 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
@@ -222,7 +222,14 @@ public class UriValidator {
 
   private RowIndexForUriType rowIndexForResourceKind(final UriInfo uriInfo) throws UriValidationException {
     RowIndexForUriType idx;
-
+    
+    final int nonComposableFunctionIndex = getIndexOfLastNonComposableFunction(uriInfo);
+    if(nonComposableFunctionIndex != -1 && (uriInfo.getUriResourceParts().size() - 1) > nonComposableFunctionIndex) {
+      throw new UriValidationException("Non composable functions followed by further resource parts are not allowed", 
+          UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH, 
+          uriInfo.getUriResourceParts().get(nonComposableFunctionIndex + 1).getSegmentValue());
+    }
+    
     int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1;
     UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
 
@@ -241,7 +248,11 @@ public class UriValidator {
       idx = rowIndexForEntitySet(lastPathSegment);
       break;
     case function:
-      idx = rowIndexForFunction(lastPathSegment);
+      if(nonComposableFunctionIndex == -1) {
+        idx = rowIndexForFunction(lastPathSegment);
+      } else {
+        idx = RowIndexForUriType.none;
+      }
       break;
     case primitiveProperty:
       idx = rowIndexForPrimitiveProperty(lastPathSegment);
@@ -266,6 +277,21 @@ public class UriValidator {
     return idx;
   }
 
+  private int getIndexOfLastNonComposableFunction(final UriInfo uriInfo) {
+    for(int i = 0; i < uriInfo.getUriResourceParts().size(); i++) {
+      final UriResource resourcePath = uriInfo.getUriResourceParts().get(i);
+      
+      if(resourcePath instanceof UriResourceFunction) {
+        final UriResourceFunction resourceFuntion = (UriResourceFunction) resourcePath;
+        if(!resourceFuntion.getFunction().isComposable()) {
+          return i;
+        }
+      }
+    }
+    
+    return -1;
+  }
+
   private RowIndexForUriType rowIndexForValue(final UriInfo uriInfo) throws UriValidationException {
     RowIndexForUriType idx;
     int secondLastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 2;
@@ -327,6 +353,12 @@ public class UriValidator {
     RowIndexForUriType idx;
     UriResourceFunction urf = (UriResourceFunction) lastPathSegment;
     EdmReturnType rt = urf.getFunction().getReturnType();
+
+    if(!urf.getFunction().isComposable()) {
+      return RowIndexForUriType.none;
+    }
+    
+    
     switch (rt.getType().getKind()) {
     case ENTITY:
       idx = rt.isCollection() && urf.getKeyPredicates().isEmpty() ?

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
index f7c2894..de14eb0 100644
--- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
+++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
@@ -81,6 +81,7 @@ UriValidationException.LAST_SEGMENT_NOT_TYPED=The last segment '%1$s' is not typ
 UriValidationException.SECOND_LAST_SEGMENT_NOT_TYPED=The second last segment '%1$s' is not typed.
 UriValidationException.UNALLOWED_KIND_BEFORE_VALUE=The kind '%1$s' is not allowed before '$value'.
 UriValidationException.UNALLOWED_KIND_BEFORE_COUNT=The kind '%1$s' is not allowed before '$count'.
+UriValidationException.UNALLOWED_RESOURCE_PATH=The resource part '%1$s' is not allowed.
 
 ContentNegotiatorException.UNSUPPORTED_ACCEPT_TYPES=The content-type range '%1$s' is not supported as value of the Accept header.
 ContentNegotiatorException.UNSUPPORTED_CONTENT_TYPE=The content type '%1$s' is not supported.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
index df4cfbd..a83abab 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java
@@ -574,7 +574,7 @@ public class FunctionProvider {
               .setParameters(Arrays.asList(
                   new CsdlParameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
                       .setCollection(true).setNullable(false)))
-              .setComposable(true)
+              .setComposable(false)
               .setReturnType(
                   new CsdlReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true)
                       .setNullable(false))

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 76b7b50..d4b87d4 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -318,17 +318,16 @@ public class ODataHandlerTest {
     dispatch(HttpMethod.GET, "FICRTString()", primitiveProcessor);
     verify(primitiveProcessor).readPrimitive(
         any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
-
+    
+    // FINRTInt16 is not composable so /$value is not allowed
     final String valueUri = "FINRTInt16()/$value";
     final PrimitiveValueProcessor primitiveValueProcessor = mock(PrimitiveValueProcessor.class);
-    dispatch(HttpMethod.GET, valueUri, primitiveValueProcessor);
-    verify(primitiveValueProcessor).readPrimitiveValue(
-        any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
-    dispatchMethodNotAllowed(HttpMethod.POST, valueUri, primitiveValueProcessor);
-    dispatchMethodNotAllowed(HttpMethod.PATCH, valueUri, primitiveValueProcessor);
-    dispatchMethodNotAllowed(HttpMethod.PUT, valueUri, primitiveValueProcessor);
-    dispatchMethodNotAllowed(HttpMethod.DELETE, valueUri, primitiveValueProcessor);
-
+    dispatchMethodWithError(HttpMethod.GET, valueUri, primitiveValueProcessor, HttpStatusCode.BAD_REQUEST);
+    dispatchMethodWithError(HttpMethod.POST, valueUri, primitiveValueProcessor, HttpStatusCode.BAD_REQUEST);
+    dispatchMethodWithError(HttpMethod.PATCH, valueUri, primitiveValueProcessor, HttpStatusCode.BAD_REQUEST);
+    dispatchMethodWithError(HttpMethod.PUT, valueUri, primitiveValueProcessor, HttpStatusCode.BAD_REQUEST);
+    dispatchMethodWithError(HttpMethod.DELETE, valueUri, primitiveValueProcessor, HttpStatusCode.BAD_REQUEST);
+    
     final String primitiveCollectionUri = "FICRTCollString()";
     PrimitiveCollectionProcessor primitiveCollectionProcessor = mock(PrimitiveCollectionProcessor.class);
     dispatch(HttpMethod.GET, primitiveCollectionUri, primitiveCollectionProcessor);
@@ -759,4 +758,11 @@ public class ODataHandlerTest {
     assertEquals(HttpStatusCode.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatusCode());
     assertNotNull(response.getContent());
   }
+  
+  private void dispatchMethodWithError(final HttpMethod method, final String path, final Processor processor, 
+      final HttpStatusCode statusCode) {
+    final ODataResponse response = dispatch(method, path, processor);
+    assertEquals(statusCode.getStatusCode(), response.getStatusCode());
+    assertNotNull(response.getContent());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9403cd3/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 9c859db..5c06e2c 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1145,6 +1145,72 @@ public class TestFullResourcePath {
   }
   
   @Test
+  public void runNonComposableFunctions() throws Exception {
+    testUri.run("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollETMixPrimCollCompTwoParam")
+      .isFunction("UFCRTCollETMixPrimCollCompTwoParam")
+      .isParameter(0, "ParameterInt16", "1")
+      .isParameter(1, "ParameterString", "'1'");
+    
+    testUri.run("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')(0)")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isFunctionImport("FICRTCollETMixPrimCollCompTwoParam")
+      .isFunction("UFCRTCollETMixPrimCollCompTwoParam")
+      .isParameter(0, "ParameterInt16", "1")
+      .isParameter(1, "ParameterString", "'1'");
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')(0)/PropertyInt16")
+      .isExValidation(UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$skip=1")
+      .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$top=1")
+    .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", 
+        "$filter=PropertyInt16 eq 1")
+    .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$skip=1")
+    .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$count=true")
+    .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$skiptoken=5")
+    .isExValidation(UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED);
+    
+    // $search is currently not implemented. Please change this exception if the implementation is done.
+    testUri.runEx("FICRTCollETMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='1')", "$search=test")
+      .isExSemantic(MessageKeys.NOT_IMPLEMENTED);
+    
+    testUri.run("ESBaseTwoKeyNav/olingo.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isEntitySet("ESBaseTwoKeyNav")
+      .at(1)
+      .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey");
+    
+    testUri.run("ESBaseTwoKeyNav/olingo.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()" 
+        + "(PropertyInt16=1,PropertyString='1')")
+      .isKind(UriInfoKind.resource)
+      .goPath().first()
+      .isEntitySet("ESBaseTwoKeyNav")
+      .at(1)
+      .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey")
+      .isKeyPredicate(0, "PropertyInt16", "1")
+      .isKeyPredicate(1, "PropertyString", "'1'");
+    
+    testUri.runEx("ESBaseTwoKeyNav/olingo.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()" 
+          + "(PropertyInt16=1,PropertyString='1')/NavPropertyETBaseTwoKeyNavOne")
+      .isExValidation(UriValidationException.MessageKeys.UNALLOWED_RESOURCE_PATH);
+  }
+  
+  @Test
   public void runEsNameCast() throws Exception {
     testUri.run("ESTwoPrim/olingo.odata.test1.ETBase")
     .isKind(UriInfoKind.resource).goPath()


[11/11] olingo-odata4 git commit: [OLINGO-786] Merge branch 'master' into olingo786

Posted by mi...@apache.org.
[OLINGO-786] Merge branch 'master' into olingo786


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

Branch: refs/heads/olingo786
Commit: 507236dd8c453dcb5be189ff670c4f707378f003
Parents: 3ec5a16 b736c43
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Oct 5 07:57:29 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Oct 5 07:57:29 2015 +0200

----------------------------------------------------------------------
 .../client/AbstractParamTecSvcITCase.java       |  18 +
 .../fit/tecsvc/client/AbstractTecSvcITCase.java |  28 +-
 .../fit/tecsvc/client/ActionImportITCase.java   |  37 +-
 .../fit/tecsvc/client/AsyncSupportITCase.java   |  24 +-
 .../fit/tecsvc/client/DeepInsertITCase.java     | 886 +++++++++--------
 .../fit/tecsvc/client/DeepInsertXmlITCase.java  | 950 -------------------
 .../ExpandWithSystemQueryOptionsITCase.java     |  12 +-
 .../commons/api/edm/EdmNavigationProperty.java  |   2 +-
 .../olingo/commons/api/edm/EdmParameter.java    |   2 +-
 .../olingo/commons/api/edm/EdmProperty.java     |   4 +-
 .../olingo/commons/api/edm/EdmReturnType.java   |   2 +-
 .../apache/olingo/server/core/ODataImpl.java    |   7 +-
 .../json/ODataJsonDeserializer.java             | 389 +++-----
 .../deserializer/xml/ODataXmlDeserializer.java  | 119 ++-
 .../core/serializer/xml/ODataXmlSerializer.java |  46 +-
 .../core/uri/parser/UriParseTreeVisitor.java    | 280 +++---
 .../uri/validator/UriValidationException.java   |   4 +-
 .../server/core/uri/validator/UriValidator.java |  59 +-
 .../server-core-exceptions-i18n.properties      |   1 +
 .../olingo/server/tecsvc/data/ActionData.java   | 116 ++-
 .../olingo/server/tecsvc/data/DataProvider.java |  23 +-
 .../processor/TechnicalEntityProcessor.java     |   9 +-
 .../server/tecsvc/provider/ActionProvider.java  |  99 +-
 .../tecsvc/provider/ContainerProvider.java      |   7 +
 .../tecsvc/provider/FunctionProvider.java       |   2 +-
 .../server/tecsvc/provider/SchemaProvider.java  |   1 +
 .../tecsvc/data/ActionDataProviderTest.java     |  14 +-
 .../olingo/server/core/ODataHandlerTest.java    |  24 +-
 .../server/core/PreconditionsValidatorTest.java |   2 +-
 .../AbstractODataDeserializerTest.java          |  44 +
 .../json/AbstractODataDeserializerTest.java     |  46 -
 .../json/ODataDeserializerDeepInsertTest.java   | 125 +--
 .../ODataDeserializerEntityCollectionTest.java  | 205 ++--
 ...ataJsonDeserializerActionParametersTest.java | 328 ++++---
 .../json/ODataJsonDeserializerEntityTest.java   | 678 ++++---------
 ...DataXMLDeserializerActionParametersTest.java | 353 +++----
 .../xml/ODataXmlDeserializerTest.java           | 211 ++--
 .../core/uri/antlr/TestFullResourcePath.java    | 193 +++-
 .../core/uri/antlr/TestUriParserImpl.java       |  11 +-
 39 files changed, 2099 insertions(+), 3262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/507236dd/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java
----------------------------------------------------------------------