You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/01/30 10:25:12 UTC

git commit: [OLINGO-62] Refactor overloading and more tests

Updated Branches:
  refs/heads/master fb833de3a -> dbd014631


[OLINGO-62] Refactor overloading and more tests


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

Branch: refs/heads/master
Commit: dbd014631120faef90844e970d6edba85360726a
Parents: fb833de
Author: Christian Amend <ch...@apache.org>
Authored: Thu Jan 30 10:24:05 2014 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Thu Jan 30 10:24:54 2014 +0100

----------------------------------------------------------------------
 .../odata4/commons/core/edm/ActionMapKey.java   |  34 +---
 .../olingo/odata4/commons/core/edm/EdmImpl.java |  75 ++++---
 .../odata4/commons/core/edm/FunctionMapKey.java |   5 +
 .../core/edm/provider/EdmProviderImpl.java      | 201 +++++++++++--------
 .../edm/provider/EdmStructuralTypeImpl.java     |   7 +-
 .../commons/core/edm/ActionMapKeyTest.java      |  79 +++++---
 .../commons/core/edm/EdmImplCachingTest.java    | 124 +++++++-----
 .../commons/core/edm/EdmImplCallCreateTest.java |  42 +++-
 .../edm/provider/EdmComplexTypeImplTest.java    |  16 ++
 .../EdmProviderImplOverloadingTest.java         |  83 ++++++++
 .../core/edm/provider/EdmProviderImplTest.java  |  99 +++++----
 11 files changed, 516 insertions(+), 249 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKey.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKey.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKey.java
index 03e5f17..c335694 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKey.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKey.java
@@ -18,6 +18,7 @@
  ******************************************************************************/
 package org.apache.olingo.odata4.commons.core.edm;
 
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
 
 public class ActionMapKey {
@@ -27,6 +28,10 @@ public class ActionMapKey {
 
   public ActionMapKey(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
       final Boolean isBindingParameterCollection) {
+    if (actionName == null || bindingParameterTypeName == null || isBindingParameterCollection == null) {
+      throw new EdmException(
+          "Action name, binding parameter type and binding parameter collection must not be null for bound actions");
+    }
     this.actionName = actionName;
     this.bindingParameterTypeName = bindingParameterTypeName;
     this.isBindingParameterCollection = isBindingParameterCollection;
@@ -34,20 +39,8 @@ public class ActionMapKey {
 
   @Override
   public int hashCode() {
-    String forHash = actionName.toString();
-
-    if (bindingParameterTypeName != null) {
-      forHash = forHash + bindingParameterTypeName.toString();
-    } else {
-      forHash = forHash + "TypeNull";
-    }
-
-    if (isBindingParameterCollection != null) {
-      forHash = forHash + isBindingParameterCollection.toString();
-    } else {
-      forHash = forHash + "CollectionNull";
-    }
-
+    String forHash =
+        actionName.toString() + bindingParameterTypeName.toString() + isBindingParameterCollection.toString();
     return forHash.hashCode();
   }
 
@@ -60,16 +53,9 @@ public class ActionMapKey {
       return false;
     }
     final ActionMapKey other = (ActionMapKey) obj;
-
-    if (actionName.equals(other.actionName)) {
-      if ((bindingParameterTypeName == null && other.bindingParameterTypeName == null)
-          || (bindingParameterTypeName != null && bindingParameterTypeName.equals(other.bindingParameterTypeName))) {
-        if ((isBindingParameterCollection == null && other.isBindingParameterCollection == null)
-            || (isBindingParameterCollection != null && isBindingParameterCollection
-                .equals(other.isBindingParameterCollection))) {
-          return true;
-        }
-      }
+    if (actionName.equals(other.actionName) && bindingParameterTypeName.equals(other.bindingParameterTypeName)
+        && isBindingParameterCollection.equals(other.isBindingParameterCollection)) {
+      return true;
     }
     return false;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/EdmImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/EdmImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/EdmImpl.java
index d647df4..b7d8ed8 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/EdmImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/EdmImpl.java
@@ -42,8 +42,10 @@ public abstract class EdmImpl implements Edm {
       new HashMap<FullQualifiedName, EdmTypeDefinition>();
   private final Map<FullQualifiedName, EdmEntityType> entityTypes = new HashMap<FullQualifiedName, EdmEntityType>();
   private final Map<FullQualifiedName, EdmComplexType> complexTypes = new HashMap<FullQualifiedName, EdmComplexType>();
-  private final Map<ActionMapKey, EdmAction> actions = new HashMap<ActionMapKey, EdmAction>();
-  private final Map<FunctionMapKey, EdmFunction> functions = new HashMap<FunctionMapKey, EdmFunction>();
+  private final Map<FullQualifiedName, EdmAction> unboundActions = new HashMap<FullQualifiedName, EdmAction>();
+  private final Map<FunctionMapKey, EdmFunction> unboundFunctions = new HashMap<FunctionMapKey, EdmFunction>();
+  private final Map<ActionMapKey, EdmAction> boundActions = new HashMap<ActionMapKey, EdmAction>();
+  private final Map<FunctionMapKey, EdmFunction> boundFunctions = new HashMap<FunctionMapKey, EdmFunction>();
   private EdmServiceMetadata serviceMetadata;
   private Map<String, String> aliasToNamespaceInfo;
 
@@ -119,16 +121,27 @@ public abstract class EdmImpl implements Edm {
   public EdmAction getAction(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
       final Boolean isBindingParameterCollection) {
     FullQualifiedName actionFqn = resolvePossibleAlias(actionName);
-    FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
-    ActionMapKey key = new ActionMapKey(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
-    EdmAction action = actions.get(key);
-    if (action == null) {
-      action = createAction(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
-      if (action != null) {
-        actions.put(key, action);
+    if (bindingParameterTypeName == null) {
+      EdmAction action = unboundActions.get(actionName);
+      if (action == null) {
+        action = createUnboundAction(actionFqn);
+        if (action != null) {
+          unboundActions.put(actionName, action);
+        }
+      }
+      return action;
+    } else {
+      FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
+      ActionMapKey key = new ActionMapKey(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
+      EdmAction action = boundActions.get(key);
+      if (action == null) {
+        action = createBoundAction(actionFqn, bindingParameterTypeFqn, isBindingParameterCollection);
+        if (action != null) {
+          boundActions.put(key, action);
+        }
       }
+      return action;
     }
-    return action;
   }
 
   @Override
@@ -136,18 +149,31 @@ public abstract class EdmImpl implements Edm {
       final FullQualifiedName bindingParameterTypeName,
       final Boolean isBindingParameterCollection, final List<String> parameterNames) {
     FullQualifiedName functionFqn = resolvePossibleAlias(functionName);
-    FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
-    FunctionMapKey key =
-        new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
-    EdmFunction function = functions.get(key);
-    if (function == null) {
-      function = createFunction(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection,
-          parameterNames);
-      if (function != null) {
-        functions.put(key, function);
+    if(bindingParameterTypeName == null){
+      FunctionMapKey key =
+          new FunctionMapKey(functionFqn, bindingParameterTypeName, isBindingParameterCollection, parameterNames);
+      EdmFunction function = unboundFunctions.get(key);
+      if (function == null) {
+        function = createUnboundFunction(functionFqn, parameterNames);
+        if (function != null) {
+          unboundFunctions.put(key, function);
+        }
       }
+      return function;
+    }else{
+      FullQualifiedName bindingParameterTypeFqn = resolvePossibleAlias(bindingParameterTypeName);
+      FunctionMapKey key =
+          new FunctionMapKey(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection, parameterNames);
+      EdmFunction function = boundFunctions.get(key);
+      if (function == null) {
+        function = createBoundFunction(functionFqn, bindingParameterTypeFqn, isBindingParameterCollection,
+            parameterNames);
+        if (function != null) {
+          boundFunctions.put(key, function);
+        }
+      }
+      return function;
     }
-    return function;
   }
 
   @Override
@@ -187,13 +213,16 @@ public abstract class EdmImpl implements Edm {
 
   protected abstract EdmComplexType createComplexType(FullQualifiedName complexTypeName);
 
-  protected abstract EdmAction createAction(FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
+  protected abstract EdmAction createUnboundAction(FullQualifiedName actionName);
+  
+  protected abstract EdmFunction createUnboundFunction(FullQualifiedName functionName, List<String> parameterNames);
+
+  protected abstract EdmAction createBoundAction(FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
       Boolean isBindingParameterCollection);
 
-  protected abstract EdmFunction createFunction(FullQualifiedName functionName,
+  protected abstract EdmFunction createBoundFunction(FullQualifiedName functionName,
       FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
       List<String> parameterNames);
 
   protected abstract EdmServiceMetadata createServiceMetadata();
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/FunctionMapKey.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/FunctionMapKey.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/FunctionMapKey.java
index e98d57c..e97f4c0 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/FunctionMapKey.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/FunctionMapKey.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
 
 public class FunctionMapKey {
@@ -34,6 +35,10 @@ public class FunctionMapKey {
   public FunctionMapKey(final FullQualifiedName functionName, final FullQualifiedName bindingParameterTypeName,
       final Boolean isBindingParameterCollection, final List<String> parameterNames) {
     this.functionName = functionName;
+    if (bindingParameterTypeName != null && isBindingParameterCollection == null) {
+      throw new EdmException(
+          "Indicator that the bindingparameter is a collection must not be null if its an bound function.");
+    }
     this.bindingParameterTypeName = bindingParameterTypeName;
     this.isBindingParameterCollection = isBindingParameterCollection;
     if (parameterNames != null) {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
index f6a82b8..6db932d 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.odata4.commons.core.edm.provider;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -49,6 +50,8 @@ import org.apache.olingo.odata4.commons.core.edm.EdmImpl;
 public class EdmProviderImpl extends EdmImpl {
 
   private final EdmProvider provider;
+  private final Map<FullQualifiedName, List<Action>> actionsMap = new HashMap<FullQualifiedName, List<Action>>();
+  private final Map<FullQualifiedName, List<Function>> functionsMap = new HashMap<FullQualifiedName, List<Function>>();
 
   public EdmProviderImpl(final EdmProvider provider) {
     this.provider = provider;
@@ -121,110 +124,76 @@ public class EdmProviderImpl extends EdmImpl {
   }
 
   @Override
-  public EdmAction createAction(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
-      final Boolean isBindingParameterCollection) {
-
+  public EdmAction createBoundAction(final FullQualifiedName actionName,
+      final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
     try {
-      List<Action> actions = provider.getActions(actionName);
-      if (actions != null) {
-        EdmActionImpl actionImpl = null;
-        if (bindingParameterTypeName == null) {
-          // Search for first unbound action
-          for (Action action : actions) {
-            if (action.isBound() == false) {
-              actionImpl = new EdmActionImpl(this, actionName, action);
-              break;
-            }
-          }
+      List<Action> actions = actionsMap.get(actionName);
+      if (actions == null) {
+        actions = provider.getActions(actionName);
+        if (actions != null) {
+          actionsMap.put(actionName, actions);
         } else {
-          // Search for bound action where binding parameter matches
-          boolean isCollection = false;
-          if (isBindingParameterCollection == null) {
-            isCollection = false;
-          } else {
-            isCollection = isBindingParameterCollection;
+          return null;
+        }
+      }
+      EdmActionImpl actionImpl = null;
+      // Search for bound action where binding parameter matches
+      for (Action action : actions) {
+        if (action.isBound() == true) {
+          List<Parameter> parameters = action.getParameters();
+          Parameter parameter = parameters.get(0);
+          if (bindingParameterTypeName.equals(parameter.getType())
+              && isBindingParameterCollection.booleanValue() == parameter.isCollection()) {
+            actionImpl = new EdmActionImpl(this, actionName, action);
+            break;
           }
-          for (Action action : actions) {
-            if (action.isBound() == true) {
-              List<Parameter> parameters = action.getParameters();
-              Parameter parameter = parameters.get(0);
-              if (bindingParameterTypeName.equals(parameter.getType()) && isCollection == parameter.isCollection()) {
-                actionImpl = new EdmActionImpl(this, actionName, action);
-                break;
-              }
 
-            }
-          }
         }
-
-        return actionImpl;
       }
-      return null;
+      return actionImpl;
     } catch (ODataException e) {
       throw new EdmException(e);
     }
   }
 
   @Override
-  public EdmFunction createFunction(final FullQualifiedName functionName,
+  public EdmFunction createBoundFunction(final FullQualifiedName functionName,
       final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
       final List<String> parameterNames) {
     try {
-      List<Function> functions = provider.getFunctions(functionName);
-      if (functions != null) {
-        EdmFunctionImpl functionImpl = null;
-        // TODO: Should we throw an edmexception when parameternames is null?
-        if (bindingParameterTypeName == null) {
-          // Search for matching unbound function
-          for (Function function : functions) {
-            if (function.isBound() == false) {
-              List<Parameter> parameters = function.getParameters();
-              // TODO add check for parameters == null;
-              if (parameterNames.size() == parameters.size()) {
-                List<String> functionParameterNames = new ArrayList<String>();
-                for (Parameter parameter : parameters) {
-                  functionParameterNames.add(parameter.getName());
-                }
-
-                if (parameterNames.containsAll(functionParameterNames)) {
-                  functionImpl = new EdmFunctionImpl(this, functionName, function);
-                  break;
-                }
-              }
-            }
-          }
+      List<Function> functions = functionsMap.get(functionName);
+      if (functions == null) {
+        functions = provider.getFunctions(functionName);
+        if (functions != null) {
+          functionsMap.put(functionName, functions);
         } else {
-          // Search for matching bound function
-          boolean isCollection = false;
-          if (isBindingParameterCollection == null) {
-            isCollection = false;
-          } else {
-            isCollection = isBindingParameterCollection;
+          return null;
+        }
+      }
+      EdmFunctionImpl functionImpl = null;
+      for (Function function : functions) {
+        if (function.isBound() == true) {
+          List<Parameter> parameters = function.getParameters();
+          if (parameters == null || parameters.size() == 0) {
+            throw new EdmException("No parameter specified for bound function: " + functionName);
           }
-          for (Function function : functions) {
-            if (function.isBound() == true) {
-              List<Parameter> parameters = function.getParameters();
-              Parameter bindingParameter = parameters.get(0);
-              if (bindingParameterTypeName.equals(bindingParameter.getType())
-                  && isCollection == bindingParameter.isCollection()) {
-                // bindingparameter type matches now only parameter names have to match
-                List<String> functionParameterNames = new ArrayList<String>();
-                for (int i = 1; i < parameters.size(); i++) {
-                  functionParameterNames.add(parameters.get(i).getName());
-                }
-
-                if (parameterNames.containsAll(functionParameterNames)) {
-                  functionImpl = new EdmFunctionImpl(this, functionName, function);
-                  break;
-                }
+          Parameter bindingParameter = parameters.get(0);
+          if (bindingParameterTypeName.equals(bindingParameter.getType())
+              && isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
+            if (parameterNames.size() == parameters.size()) {
+              List<String> functionParameterNames = new ArrayList<String>();
+              for (Parameter parameter : parameters) {
+                functionParameterNames.add(parameter.getName());
+              }
+              if (parameterNames.containsAll(functionParameterNames)) {
+                functionImpl = new EdmFunctionImpl(this, functionName, function);
+                break;
               }
             }
           }
         }
-
-        return functionImpl;
       }
-      return null;
+      return functionImpl;
     } catch (ODataException e) {
       throw new EdmException(e);
     }
@@ -251,4 +220,72 @@ public class EdmProviderImpl extends EdmImpl {
     return aliasToNamespaceInfos;
   }
 
+  @Override
+  protected EdmAction createUnboundAction(FullQualifiedName actionName) {
+    try {
+      List<Action> actions = actionsMap.get(actionName);
+      if (actions == null) {
+        actions = provider.getActions(actionName);
+        if (actions != null) {
+          actionsMap.put(actionName, actions);
+        } else {
+          return null;
+        }
+      }
+      EdmActionImpl actionImpl = null;
+      // Search for first unbound action
+      for (Action action : actions) {
+        if (action.isBound() == false) {
+          actionImpl = new EdmActionImpl(this, actionName, action);
+          break;
+        }
+      }
+      return actionImpl;
+    } catch (ODataException e) {
+      throw new EdmException(e);
+    }
+  }
+
+  @Override
+  protected EdmFunction createUnboundFunction(FullQualifiedName functionName, List<String> parameterNames) {
+    try {
+      List<Function> functions = functionsMap.get(functionName);
+      if (functions == null) {
+        functions = provider.getFunctions(functionName);
+        if (functions != null) {
+          functionsMap.put(functionName, functions);
+        } else {
+          return null;
+        }
+      }
+      List<String> parameterNamesCopy = parameterNames;
+      if (parameterNamesCopy == null) {
+        parameterNamesCopy = Collections.emptyList();
+      }
+      EdmFunctionImpl functionImpl = null;
+      for (Function function : functions) {
+        if (function.isBound() == false) {
+          List<Parameter> providerParameters = function.getParameters();
+          if (providerParameters == null) {
+            providerParameters = Collections.emptyList();
+          }
+          if (parameterNamesCopy.size() == providerParameters.size()) {
+            List<String> functionParameterNames = new ArrayList<String>();
+            for (Parameter parameter : providerParameters) {
+              functionParameterNames.add(parameter.getName());
+            }
+
+            if (parameterNamesCopy.containsAll(functionParameterNames)) {
+              functionImpl = new EdmFunctionImpl(this, functionName, function);
+              break;
+            }
+          }
+        }
+      }
+      return functionImpl;
+    } catch (ODataException e) {
+      throw new EdmException(e);
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
index e0a2465..0961a2f 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.olingo.odata4.commons.api.edm.EdmElement;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
 import org.apache.olingo.odata4.commons.api.edm.EdmType;
 import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
@@ -32,7 +33,6 @@ import org.apache.olingo.odata4.commons.api.edm.provider.NavigationProperty;
 import org.apache.olingo.odata4.commons.api.edm.provider.Property;
 import org.apache.olingo.odata4.commons.api.edm.provider.StructuralType;
 
-
 public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmStructuralType {
 
   private final Map<String, EdmElement> properties = new HashMap<String, EdmElement>();
@@ -107,12 +107,13 @@ public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmSt
     }
     return navigationPropertyNames;
   }
-  
 
   @Override
   public boolean compatibleTo(EdmType targetType) {
     EdmStructuralType sourceType = this;
-
+    if (targetType == null) {
+      throw new EdmException("Target type must not be null");
+    }
     while (sourceType.getName() != targetType.getName() ||
         sourceType.getNamespace() != targetType.getNamespace()) {
       sourceType = sourceType.getBaseType();

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
index 54dbb1d..a740db2 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
@@ -20,7 +20,9 @@ package org.apache.olingo.odata4.commons.core.edm;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
 
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
 import org.junit.Test;
 
@@ -30,55 +32,68 @@ public class ActionMapKeyTest {
   private final FullQualifiedName fqnType = new FullQualifiedName("namespace2", "name2");
 
   @Test
-  public void testEqualsMethod() {
-    ActionMapKey key1 = new ActionMapKey(fqn, null, null);
-    ActionMapKey someKey = new ActionMapKey(fqn, null, null);
-    assertEquals(key1, someKey);
+  public void invalidParametersTest() {
+    createAndCheckForEdmException(null, null, null);
+    createAndCheckForEdmException(fqn, null, null);
+    createAndCheckForEdmException(fqn, fqnType, null);
+    createAndCheckForEdmException(fqn, null, true);
+    createAndCheckForEdmException(null, fqnType, true);
+    createAndCheckForEdmException(null, fqnType, null);
+    createAndCheckForEdmException(null, null, true);
 
-    key1 = new ActionMapKey(fqn, null, new Boolean(true));
-    someKey = new ActionMapKey(fqn, null, true);
-    assertEquals(key1, someKey);
+  }
 
-    key1 = new ActionMapKey(fqn, fqnType, false);
-    someKey = new ActionMapKey(fqn, fqnType, false);
-    assertEquals(key1, someKey);
+  private void createAndCheckForEdmException(FullQualifiedName fqn, FullQualifiedName typeName, Boolean collection) {
+    try {
+      new ActionMapKey(fqn, typeName, collection);
+    } catch (EdmException e) {
+      return;
+    }
+    fail("EdmException expected for parameters: " + fqn + " " + typeName + " " + collection);
+  }
 
-    key1 = new ActionMapKey(fqn, fqnType, null);
-    someKey = new ActionMapKey(fqn, fqnType, null);
-    assertEquals(key1, someKey);
+  @Test
+  public void testEqualsMethod() {
+    ActionMapKey key;
+    ActionMapKey someKey;
 
-    key1 = new ActionMapKey(fqn, fqnType, true);
-    someKey = new ActionMapKey(fqn, fqnType, null);
-    assertNotSame(key1, someKey);
+    key = new ActionMapKey(fqn, fqnType, false);
+    someKey = new ActionMapKey(fqn, fqnType, false);
+    assertEquals(key, someKey);
 
-    key1 = new ActionMapKey(fqn, fqnType, true);
+    key = new ActionMapKey(fqn, fqnType, new Boolean(false));
     someKey = new ActionMapKey(fqn, fqnType, false);
-    assertNotSame(key1, someKey);
+    assertEquals(key, someKey);
 
-    key1 = new ActionMapKey(fqn, null, true);
+    key = new ActionMapKey(fqn, fqnType, true);
     someKey = new ActionMapKey(fqn, fqnType, false);
-    assertNotSame(key1, someKey);
+    assertNotSame(key, someKey);
 
-    key1 = new ActionMapKey(fqn, null, true);
-    someKey = new ActionMapKey(fqn, null, false);
-    assertNotSame(key1, someKey);
+    key = new ActionMapKey(fqn, fqnType, true);
+    someKey = new ActionMapKey(fqn, fqnType, new Boolean(false));
+    assertNotSame(key, someKey);
   }
 
   @Test
   public void testHashMethod() {
-    ActionMapKey key1 = new ActionMapKey(fqn, null, null);
-    ActionMapKey someKey = new ActionMapKey(fqn, null, null);
-    assertEquals(key1.hashCode(), someKey.hashCode());
+    ActionMapKey key;
+    ActionMapKey someKey;
 
-    key1 = new ActionMapKey(fqn, null, new Boolean(true));
-    someKey = new ActionMapKey(fqn, null, true);
-    assertEquals(key1.hashCode(), someKey.hashCode());
+    key = new ActionMapKey(fqn, fqnType, false);
+    someKey = new ActionMapKey(fqn, fqnType, false);
+    assertEquals(key.hashCode(), someKey.hashCode());
 
-    someKey = new ActionMapKey(fqn, fqnType, true);
-    assertNotSame(key1.hashCode(), someKey.hashCode());
+    key = new ActionMapKey(fqn, fqnType, new Boolean(false));
+    someKey = new ActionMapKey(fqn, fqnType, false);
+    assertEquals(key.hashCode(), someKey.hashCode());
 
+    key = new ActionMapKey(fqn, fqnType, true);
     someKey = new ActionMapKey(fqn, fqnType, false);
-    assertNotSame(key1.hashCode(), someKey.hashCode());
+    assertNotSame(key.hashCode(), someKey.hashCode());
+
+    key = new ActionMapKey(fqn, fqnType, true);
+    someKey = new ActionMapKey(fqn, fqnType, new Boolean(false));
+    assertNotSame(key.hashCode(), someKey.hashCode());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
index a117ac8..26dfc6e 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
@@ -21,7 +21,6 @@ package org.apache.olingo.odata4.commons.core.edm;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -142,7 +141,7 @@ public class EdmImplCachingTest {
   }
 
   @Test
-  public void cacheActionSimple() {
+  public void cacheUnboundAction() {
     EdmAction action = edm.getAction(NAME1, null, null);
     assertNotNull(action);
 
@@ -158,37 +157,24 @@ public class EdmImplCachingTest {
   }
 
   @Test
-  public void cacheActionComlex() {
-    EdmAction action = edm.getAction(NAME1, null, null);
+  public void cacheBoundAction() {
+    EdmAction action = edm.getAction(NAME1, NAME2, true);
     assertNotNull(action);
 
-    EdmAction cachedAction = edm.getAction(NAME1, null, true);
-    assertNull(cachedAction);
-
-    cachedAction = edm.getAction(NAME1, null, false);
-    assertNull(cachedAction);
-
-    cachedAction = edm.getAction(NAME1, NAME2, null);
-    assertNull(cachedAction);
-
-    cachedAction = edm.getAction(NAME1, NAME2, true);
-    assertNull(cachedAction);
-
-    cachedAction = edm.getAction(NAME1, NAME2, false);
-    assertNull(cachedAction);
+    EdmAction cachedAction = edm.getAction(NAME1, NAME2, true);
+    assertNotNull(cachedAction);
 
-    cachedAction = edm.getAction(NAME1, NAME1, null);
-    assertNull(cachedAction);
+    assertTrue(action == cachedAction);
+    assertEquals(action, cachedAction);
 
-    cachedAction = edm.getAction(NAME1, NAME1, true);
-    assertNull(cachedAction);
+    EdmAction action2 = edm.getAction(NAME2, NAME2, true);
+    assertNotNull(action2);
+    assertNotSame(action, action2);
 
-    cachedAction = edm.getAction(NAME1, NAME1, false);
-    assertNull(cachedAction);
   }
 
   @Test
-  public void cacheFunctionSimple() {
+  public void cacheUnboundFunctionNoParameters() {
     EdmFunction function = edm.getFunction(NAME1, null, null, null);
     assertNotNull(function);
 
@@ -205,35 +191,43 @@ public class EdmImplCachingTest {
   }
 
   @Test
-  public void cacheFunctionComplex() {
-    EdmFunction function = edm.getFunction(NAME1, null, null, null);
+  public void cacheBoundFunction() {
+    EdmFunction function = edm.getFunction(NAME1, NAME2, true, new ArrayList<String>());
     assertNotNull(function);
 
-    EdmFunction cachedfunction = edm.getFunction(NAME1, null, false, null);
-    assertNull(cachedfunction);
+    EdmFunction cachedfunction = edm.getFunction(NAME1, NAME2, true, new ArrayList<String>());
+    assertNotNull(cachedfunction);
 
-    cachedfunction = edm.getFunction(NAME1, null, true, null);
-    assertNull(cachedfunction);
+    assertTrue(function == cachedfunction);
+    assertEquals(function, cachedfunction);
 
-    cachedfunction = edm.getFunction(NAME1, null, new Boolean(true), null);
-    assertNull(cachedfunction);
+    EdmFunction function2 = edm.getFunction(NAME2, NAME2, true, new ArrayList<String>());
+    assertNotNull(function2);
 
-    cachedfunction = edm.getFunction(NAME1, NAME2, null, null);
-    assertNull(cachedfunction);
+    assertNotSame(function, function2);
+  }
 
-    cachedfunction = edm.getFunction(NAME1, NAME2, true, null);
-    assertNull(cachedfunction);
+  @Test
+  public void cacheUnboundFunctionWithParameters() {
+    ArrayList<String> parameters1 = new ArrayList<String>();
+    parameters1.add("A");
+    parameters1.add("B");
+    EdmFunction function = edm.getFunction(NAME1, NAME2, true, parameters1);
+    assertNotNull(function);
 
-    cachedfunction = edm.getFunction(NAME1, NAME2, false, null);
-    assertNull(cachedfunction);
+    ArrayList<String> parameters2 = new ArrayList<String>();
+    parameters2.add("B");
+    parameters2.add("A");
+    EdmFunction cachedfunction = edm.getFunction(NAME1, NAME2, true, parameters2);
+    assertNotNull(cachedfunction);
 
-    cachedfunction = edm.getFunction(NAME1, null, null, new ArrayList<String>());
-    assertNull(cachedfunction);
-  }
+    assertTrue(function == cachedfunction);
+    assertEquals(function, cachedfunction);
 
-  @Test
-  public void cacheFunctionComplexWithListContent() {
+    EdmFunction function2 = edm.getFunction(NAME2, NAME2, true, new ArrayList<String>());
+    assertNotNull(function2);
 
+    assertNotSame(function, function2);
   }
 
   @Test
@@ -312,9 +306,9 @@ public class EdmImplCachingTest {
     }
 
     @Override
-    public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+    public EdmAction createBoundAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
         final Boolean isBindingParameterCollection) {
-      if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null) {
+      if (NAME1.equals(fqn)) {
         EdmAction action = mock(EdmAction.class);
         when(action.getNamespace()).thenReturn(fqn.getNamespace());
         when(action.getName()).thenReturn(fqn.getName());
@@ -329,10 +323,10 @@ public class EdmImplCachingTest {
     }
 
     @Override
-    public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+    public EdmFunction createBoundFunction(final FullQualifiedName fqn,
+        final FullQualifiedName bindingParameterTypeName,
         final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
-      if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null
-          && bindingParameterNames == null) {
+      if (NAME1.equals(fqn)) {
         EdmFunction function = mock(EdmFunction.class);
         when(function.getNamespace()).thenReturn(fqn.getNamespace());
         when(function.getName()).thenReturn(fqn.getName());
@@ -355,5 +349,37 @@ public class EdmImplCachingTest {
     protected Map<String, String> createAliasToNamespaceInfo() {
       return new HashMap<String, String>();
     }
+
+    @Override
+    protected EdmAction createUnboundAction(FullQualifiedName fqn) {
+      if (NAME1.equals(fqn)) {
+        EdmAction action = mock(EdmAction.class);
+        when(action.getNamespace()).thenReturn(fqn.getNamespace());
+        when(action.getName()).thenReturn(fqn.getName());
+        return action;
+      } else if (NAME2.equals(fqn)) {
+        EdmAction action = mock(EdmAction.class);
+        when(action.getNamespace()).thenReturn(fqn.getNamespace());
+        when(action.getName()).thenReturn(fqn.getName());
+        return action;
+      }
+      return null;
+    }
+
+    @Override
+    protected EdmFunction createUnboundFunction(FullQualifiedName fqn, List<String> parameterNames) {
+      if (NAME1.equals(fqn)) {
+        EdmFunction function = mock(EdmFunction.class);
+        when(function.getNamespace()).thenReturn(fqn.getNamespace());
+        when(function.getName()).thenReturn(fqn.getName());
+        return function;
+      } else if (NAME2.equals(fqn)) {
+        EdmFunction function = mock(EdmFunction.class);
+        when(function.getNamespace()).thenReturn(fqn.getNamespace());
+        when(function.getName()).thenReturn(fqn.getName());
+        return function;
+      }
+      return null;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
index 533869e..46dd32e 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
@@ -20,10 +20,12 @@ package org.apache.olingo.odata4.commons.core.edm;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -108,6 +110,13 @@ public class EdmImplCallCreateTest {
     assertNotNull(action);
     assertEquals(FQN.getNamespace(), action.getNamespace());
     assertEquals(FQN.getName(), action.getName());
+    
+    EdmAction action2 = edm.getAction(FQN, FQN, true);
+    assertNotNull(action2);
+    assertEquals(FQN.getNamespace(), action2.getNamespace());
+    assertEquals(FQN.getName(), action2.getName());
+    
+    assertNotSame(action, action2);
 
     assertNull(edm.getAction(WRONG_FQN, null, null));
   }
@@ -118,6 +127,13 @@ public class EdmImplCallCreateTest {
     assertNotNull(function);
     assertEquals(FQN.getNamespace(), function.getNamespace());
     assertEquals(FQN.getName(), function.getName());
+    
+    EdmFunction function2 = edm.getFunction(FQN, FQN, true, new ArrayList<String>());
+    assertNotNull(function2);
+    assertEquals(FQN.getNamespace(), function2.getNamespace());
+    assertEquals(FQN.getName(), function2.getName());
+    
+    assertNotSame(function, function2);
 
     assertNull(edm.getFunction(WRONG_FQN, null, null, null));
   }
@@ -189,7 +205,7 @@ public class EdmImplCallCreateTest {
     }
 
     @Override
-    public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+    public EdmAction createBoundAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
         final Boolean isBindingParameterCollection) {
       if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
         EdmAction action = mock(EdmAction.class);
@@ -201,7 +217,7 @@ public class EdmImplCallCreateTest {
     }
 
     @Override
-    public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+    public EdmFunction createBoundFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
         final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
       if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
         EdmFunction function = mock(EdmFunction.class);
@@ -221,5 +237,27 @@ public class EdmImplCallCreateTest {
     protected Map<String, String> createAliasToNamespaceInfo() {
       return new HashMap<String, String>();
     }
+
+    @Override
+    protected EdmAction createUnboundAction(FullQualifiedName fqn) {
+      if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+        EdmAction action = mock(EdmAction.class);
+        when(action.getNamespace()).thenReturn(fqn.getNamespace());
+        when(action.getName()).thenReturn(fqn.getName());
+        return action;
+      }
+      return null;
+    }
+
+    @Override
+    protected EdmFunction createUnboundFunction(FullQualifiedName fqn, List<String> parameterNames) {
+      if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+        EdmFunction function = mock(EdmFunction.class);
+        when(function.getNamespace()).thenReturn(fqn.getNamespace());
+        when(function.getName()).thenReturn(fqn.getName());
+        return function;
+      }
+      return null;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImplTest.java
index 3892476..47f3e33 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImplTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImplTest.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.odata4.commons.core.edm.provider;
 
 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;
@@ -76,6 +77,21 @@ public class EdmComplexTypeImplTest {
   }
 
   @Test
+  public void typeMustBeCompatibletoBasetype() {
+    assertTrue(type.compatibleTo(baseType));
+  }
+
+  @Test
+  public void baseTypeMustNotBeCompatibleToType() {
+    assertFalse(baseType.compatibleTo(type));
+  }
+
+  @Test(expected = EdmException.class)
+  public void nullForCompatibleTypeMustResultInEdmException() {
+    assertFalse(type.compatibleTo(null));
+  }
+
+  @Test
   public void getBaseType() {
     assertNull(baseType.getBaseType());
     assertNotNull(type.getBaseType());

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplOverloadingTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplOverloadingTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplOverloadingTest.java
new file mode 100644
index 0000000..0ea82de
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplOverloadingTest.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.odata4.commons.core.edm.provider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.provider.Action;
+import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.Function;
+import org.apache.olingo.odata4.commons.api.edm.provider.Parameter;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EdmProviderImplOverloadingTest {
+
+  private Edm edm;
+  private final FullQualifiedName FQN = new FullQualifiedName("testNamespace", "testName");
+  private final FullQualifiedName WRONG_FQN = new FullQualifiedName("wrong", "wrong");
+
+  @Before
+  public void setup() throws Exception {
+    EdmProvider provider = mock(EdmProvider.class);
+
+    Action action = new Action().setName(FQN.getName());
+    List<Action> actions = new ArrayList<Action>();
+    actions.add(action);
+    when(provider.getActions(FQN)).thenReturn(actions);
+
+    Function function = new Function().setName(FQN.getName()).setParameters(new ArrayList<Parameter>());
+    List<Function> functions = new ArrayList<Function>();
+    functions.add(function);
+    when(provider.getFunctions(FQN)).thenReturn(functions);
+    edm = new EdmProviderImpl(provider);
+  }
+
+  @Test
+  public void simpleActionGet() {
+    EdmAction action = edm.getAction(FQN, null, null);
+    assertNotNull(action);
+    assertEquals(FQN.getNamespace(), action.getNamespace());
+    assertEquals(FQN.getName(), action.getName());
+
+    assertNull(edm.getAction(WRONG_FQN, null, null));
+  }
+
+  @Test
+  public void simpleFunctionGet() {
+    EdmFunction function = edm.getFunction(FQN, null, null, new ArrayList<String>());
+    assertNotNull(function);
+    assertEquals(FQN.getNamespace(), function.getNamespace());
+    assertEquals(FQN.getName(), function.getName());
+
+    assertNull(edm.getFunction(WRONG_FQN, null, null, new ArrayList<String>()));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/dbd01463/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplTest.java
index 362aea5..6bd6ed3 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImplTest.java
@@ -21,31 +21,32 @@ package org.apache.olingo.odata4.commons.core.edm.provider;
 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 static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.olingo.odata4.commons.api.edm.Edm;
-import org.apache.olingo.odata4.commons.api.edm.EdmAction;
 import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
 import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
 import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
-import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.odata4.commons.api.edm.provider.Action;
+import org.apache.olingo.odata4.commons.api.edm.provider.AliasInfo;
 import org.apache.olingo.odata4.commons.api.edm.provider.ComplexType;
 import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
 import org.apache.olingo.odata4.commons.api.edm.provider.EntityContainerInfo;
 import org.apache.olingo.odata4.commons.api.edm.provider.EntityType;
 import org.apache.olingo.odata4.commons.api.edm.provider.EnumType;
 import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
-import org.apache.olingo.odata4.commons.api.edm.provider.Function;
-import org.apache.olingo.odata4.commons.api.edm.provider.Parameter;
 import org.apache.olingo.odata4.commons.api.edm.provider.PropertyRef;
 import org.apache.olingo.odata4.commons.api.edm.provider.TypeDefinition;
+import org.apache.olingo.odata4.commons.api.exception.ODataException;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -75,20 +76,70 @@ public class EdmProviderImplTest {
     ComplexType complexType = new ComplexType().setName(FQN.getName());
     when(provider.getComplexType(FQN)).thenReturn(complexType);
 
-    Action action = new Action().setName(FQN.getName());
-    List<Action> actions = new ArrayList<Action>();
-    actions.add(action);
-    when(provider.getActions(FQN)).thenReturn(actions);
-
-    Function function = new Function().setName(FQN.getName()).setParameters(new ArrayList<Parameter>());
-    List<Function> functions = new ArrayList<Function>();
-    functions.add(function);
-    when(provider.getFunctions(FQN)).thenReturn(functions);
+    List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();
+    aliasInfos.add(new AliasInfo().setAlias("alias").setNamespace("namespace"));
+    when(provider.getAliasInfos()).thenReturn(aliasInfos);
 
     edm = new EdmProviderImpl(provider);
   }
 
   @Test
+  public void convertExceptionsTest() throws Exception{
+    EdmProvider localProvider = mock(EdmProvider.class);
+    FullQualifiedName fqn = new FullQualifiedName("namespace", "name");
+    when(localProvider.getEntityContainerInfo(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getEnumType(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getTypeDefinition(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getEntityType(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getComplexType(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getActions(fqn)).thenThrow(new ODataException("msg"));
+    when(localProvider.getFunctions(fqn)).thenThrow(new ODataException("msg"));
+    
+    Edm localEdm = new EdmProviderImpl(localProvider);
+
+    callMethodAndExpectEdmException(localEdm, "getEntityContainer");
+    callMethodAndExpectEdmException(localEdm, "getEnumType");
+    callMethodAndExpectEdmException(localEdm, "getTypeDefinition");
+    callMethodAndExpectEdmException(localEdm, "getEntityType");
+    callMethodAndExpectEdmException(localEdm, "getComplexType");
+    
+    //seperate because of signature
+    try {
+      localEdm.getAction(fqn, null, null);
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.odata4.commons.api.exception.ODataException: msg", e.getMessage());
+    }
+    
+    try {
+      localEdm.getFunction(fqn, null, null, null);
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.odata4.commons.api.exception.ODataException: msg", e.getMessage());
+    }
+  }
+  
+  private void callMethodAndExpectEdmException(Edm localEdm, String methodName) throws Exception {
+    Method method = localEdm.getClass().getMethod(methodName, FullQualifiedName.class);
+    try {
+      method.invoke(localEdm, new FullQualifiedName("namespace", "name"));
+    } catch (InvocationTargetException e) {
+      Throwable cause = e.getCause();
+      if(cause instanceof EdmException){
+        return;
+      }
+    }
+    fail("EdmException expected for method: " + methodName);
+  }
+
+  @Test(expected = EdmException.class)
+  public void convertExceptionsAliasTest() throws Exception{
+    EdmProvider localProvider = mock(EdmProvider.class);
+    when(localProvider.getAliasInfos()).thenThrow(new ODataException("msg"));
+    
+    Edm localEdm = new EdmProviderImpl(localProvider);
+    localEdm.getEntityContainer(null);
+  }
+
+  @Test
   public void getEntityContainer() {
     EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
     assertNotNull(entityContainer);
@@ -144,26 +195,6 @@ public class EdmProviderImplTest {
   }
 
   @Test
-  public void getAction() {
-    EdmAction action = edm.getAction(FQN, null, null);
-    assertNotNull(action);
-    assertEquals(FQN.getNamespace(), action.getNamespace());
-    assertEquals(FQN.getName(), action.getName());
-
-    assertNull(edm.getAction(WRONG_FQN, null, null));
-  }
-
-  @Test
-  public void getFunction() {
-    EdmFunction function = edm.getFunction(FQN, null, null, new ArrayList<String>());
-    assertNotNull(function);
-    assertEquals(FQN.getNamespace(), function.getNamespace());
-    assertEquals(FQN.getName(), function.getName());
-
-    assertNull(edm.getFunction(WRONG_FQN, null, null, new ArrayList<String>()));
-  }
-
-  @Test
   public void getServiceMetadata() {
     assertNotNull(edm.getServiceMetadata());
   }