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/31 16:30:20 UTC

git commit: [OLINGO-62] final tests and implementation

Updated Branches:
  refs/heads/master 0756824d0 -> b886528b1


[OLINGO-62] final tests and implementation

Test coverage 99,4 percent


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/b886528b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/b886528b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/b886528b

Branch: refs/heads/master
Commit: b886528b13199717340bbe952a317f2a5f131c63
Parents: 0756824
Author: Christian Amend <ch...@apache.org>
Authored: Fri Jan 31 16:28:04 2014 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Fri Jan 31 16:29:04 2014 +0100

----------------------------------------------------------------------
 .../odata4/commons/core/edm/FunctionMapKey.java |  11 +-
 .../core/edm/provider/EdmEntityTypeImpl.java    |  43 +++---
 .../edm/provider/EdmKeyPropertyRefImpl.java     |  28 ++--
 .../core/edm/provider/EdmProviderImpl.java      |   8 +-
 .../edm/provider/EdmComplexTypeImplTest.java    |   7 +
 .../edm/provider/EdmEntityTypeImplTest.java     |  34 ++++-
 .../edm/provider/EdmKeyPropertyRefImplTest.java | 142 ++++++++++++++++++
 .../EdmProviderImplOverloadingTest.java         | 143 +++++++++++++++++--
 .../core/edm/provider/EdmProviderImplTest.java  |  29 ++++
 .../edm/provider/EdmTypeDefinitionImplTest.java |   1 +
 10 files changed, 387 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/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 e97f4c0..6ed112c 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
@@ -41,12 +41,10 @@ public class FunctionMapKey {
     }
     this.bindingParameterTypeName = bindingParameterTypeName;
     this.isBindingParameterCollection = isBindingParameterCollection;
+    this.parameterNames = new ArrayList<String>();
     if (parameterNames != null) {
-      this.parameterNames = new ArrayList<String>();
       this.parameterNames.addAll(parameterNames);
       Collections.sort(this.parameterNames);
-    } else {
-      this.parameterNames = null;
     }
   }
 
@@ -66,12 +64,12 @@ public class FunctionMapKey {
       hash = hash + "collectionNull";
     }
 
-    if (parameterNames != null) {
+    if (!parameterNames.isEmpty()) {
       for (String name : parameterNames) {
         hash = hash + name;
       }
     } else {
-      hash = hash + "parameterNamesNull";
+      hash = hash + "parameterNamesEmpty";
     }
 
     return hash.hashCode();
@@ -95,8 +93,7 @@ public class FunctionMapKey {
                 .equals(other.isBindingParameterCollection))) {
           if (parameterNames == null && other.parameterNames == null) {
             return true;
-          } else if (parameterNames != null && other.parameterNames != null
-              && parameterNames.size() == other.parameterNames.size()) {
+          } else if (parameterNames.size() == other.parameterNames.size()) {
             for (String name : parameterNames) {
               if (!other.parameterNames.contains(name)) {
                 return false;

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
index 6024d04..038f851 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
@@ -44,17 +44,20 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit
     this.entityType = entityType;
     if (baseType == null) {
       entityBaseType = null;
-      if (entityType.getKey() == null && !entityType.isAbstract()) {
+      List<PropertyRef> key = entityType.getKey();
+      if (key == null && !entityType.isAbstract()) {
         throw new EdmException("Non-Abstract entity types must define a key.");
       }
-      for (PropertyRef ref : entityType.getKey()) {
-        EdmKeyPropertyRef edmKeyRef = new EdmKeyPropertyRefImpl(this, ref);
-        if (ref.getAlias() != null) {
-          keyPredicateNames.add(ref.getAlias());
-          keyPropertyRefs.put(ref.getAlias(), edmKeyRef);
-        } else {
-          keyPredicateNames.add(ref.getPropertyName());
-          keyPropertyRefs.put(ref.getPropertyName(), edmKeyRef);
+      if (key != null) {
+        for (PropertyRef ref : key) {
+          EdmKeyPropertyRef edmKeyRef = new EdmKeyPropertyRefImpl(this, ref);
+          if (ref.getAlias() != null) {
+            keyPredicateNames.add(ref.getAlias());
+            keyPropertyRefs.put(ref.getAlias(), edmKeyRef);
+          } else {
+            keyPredicateNames.add(ref.getPropertyName());
+            keyPropertyRefs.put(ref.getPropertyName(), edmKeyRef);
+          }
         }
       }
     } else {
@@ -75,32 +78,30 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit
 
   @Override
   public List<String> getKeyPredicateNames() {
-    if (baseType != null) {
+    if (keyPredicateNames.isEmpty() && baseType != null) {
       return entityBaseType.getKeyPredicateNames();
-    } else {
-      return keyPredicateNames;
     }
+    return keyPredicateNames;
   }
 
   @Override
   public List<EdmKeyPropertyRef> getKeyPropertyRefs() {
-    if (baseType != null) {
+    if (keyPropertyRefsList == null) {
+      keyPropertyRefsList = new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values());
+    }
+    if (keyPropertyRefsList.isEmpty() && entityBaseType != null) {
       return entityBaseType.getKeyPropertyRefs();
-    } else {
-      if (keyPropertyRefsList == null) {
-        keyPropertyRefsList = new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values());
-      }
-      return keyPropertyRefsList;
     }
+    return keyPropertyRefsList;
   }
 
   @Override
   public EdmKeyPropertyRef getKeyPropertyRef(final String keyPredicateName) {
-    if (baseType != null) {
+    EdmKeyPropertyRef edmKeyPropertyRef = keyPropertyRefs.get(keyPredicateName);
+    if (edmKeyPropertyRef == null && entityBaseType != null) {
       return entityBaseType.getKeyPropertyRef(keyPredicateName);
-    } else {
-      return keyPropertyRefs.get(keyPredicateName);
     }
+    return edmKeyPropertyRef;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
index 5798f06..8eb8ad4 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImpl.java
@@ -23,8 +23,6 @@ import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.EdmKeyPropertyRef;
 import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
 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;
 import org.apache.olingo.odata4.commons.api.edm.provider.PropertyRef;
 
 public class EdmKeyPropertyRefImpl implements EdmKeyPropertyRef {
@@ -63,22 +61,24 @@ public class EdmKeyPropertyRefImpl implements EdmKeyPropertyRef {
               + ref.getPropertyName());
         }
       } else {
+        if (ref.getPath() == null || ref.getPath().isEmpty()) {
+          throw new EdmException("Alias but no path specified for propertyRef");
+        }
         String[] splitPath = ref.getPath().split("/");
         EdmStructuralType structType = edmEntityType;
-        for (int i = 0; i < splitPath.length; i++) {
-          property = (EdmProperty) structType.getProperty(splitPath[i]);
+        for (int i = 0; i < splitPath.length - 1; i++) {
+          EdmProperty property = (EdmProperty) structType.getProperty(splitPath[i]);
           if (property == null) {
-            throw new EdmException("Invalid key property ref specified. Can´t find property with name: "
-                + splitPath[i]);
-          }
-          EdmType childType = property.getType();
-          if (childType.getKind() == EdmTypeKind.COMPLEX) {
-            structType = (EdmStructuralType) childType;
-          } else {
-            if (i + 1 != splitPath.length) {
-              throw new EdmException("Invalid path: " + ref.getPath() + " Must end after: " + splitPath[i]);
-            }
+            throw new EdmException("Invalid property ref specified. Can´t find property with name: "
+                + splitPath[i] + " at type: " + structType.getNamespace() + "." + structType.getName());
           }
+          structType = (EdmStructuralType) property.getType();
+        }
+        property = (EdmProperty) structType.getProperty(splitPath[splitPath.length - 1]);
+        if (property == null) {
+          throw new EdmException("Invalid property ref specified. Can´t find property with name: "
+              + splitPath[splitPath.length - 1] + " at type: " + structType.getNamespace() + "."
+              + structType.getName());
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/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 a12a4df..50d201d 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
@@ -170,6 +170,10 @@ public class EdmProviderImpl extends EdmImpl {
           return null;
         }
       }
+      List<String> parameterNamesCopy = parameterNames;
+      if (parameterNamesCopy == null) {
+        parameterNamesCopy = Collections.emptyList();
+      }
       EdmFunctionImpl functionImpl = null;
       for (Function function : functions) {
         if (function.isBound() == true) {
@@ -180,12 +184,12 @@ public class EdmProviderImpl extends EdmImpl {
           Parameter bindingParameter = providerParameters.get(0);
           if (bindingParameterTypeName.equals(bindingParameter.getType())
               && isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) {
-            if (parameterNames.size() == providerParameters.size() - 1) {
+            if (parameterNamesCopy.size() == providerParameters.size() - 1) {
               List<String> providerParameterNames = new ArrayList<String>();
               for (int i = 1; i < providerParameters.size(); i++) {
                 providerParameterNames.add(providerParameters.get(i).getName());
               }
-              if (parameterNames.containsAll(providerParameterNames)) {
+              if (parameterNamesCopy.containsAll(providerParameterNames)) {
                 functionImpl = new EdmFunctionImpl(this, functionName, function);
                 break;
               }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/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 47f3e33..fd34b5b 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
@@ -77,6 +77,13 @@ public class EdmComplexTypeImplTest {
   }
 
   @Test
+  public void noPropertiesAndNoNavPropertiesMustNotResultInException() {
+    EdmProviderImpl edm = mock(EdmProviderImpl.class);
+    ComplexType complexType = new ComplexType().setName("n");
+    new EdmComplexTypeImpl(edm, new FullQualifiedName("n", "n"), complexType);
+  }
+
+  @Test
   public void typeMustBeCompatibletoBasetype() {
     assertTrue(type.compatibleTo(baseType));
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImplTest.java
index 3a2b4d6..8db2775 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImplTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImplTest.java
@@ -32,6 +32,7 @@ import java.util.List;
 import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
 import org.apache.olingo.odata4.commons.api.edm.EdmElement;
 import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
 import org.apache.olingo.odata4.commons.api.edm.EdmKeyPropertyRef;
 import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
 import org.apache.olingo.odata4.commons.api.edm.provider.ComplexType;
@@ -51,7 +52,6 @@ public class EdmEntityTypeImplTest {
   private EdmEntityType typeWithBaseType;
   private EdmEntityType typeWithComplexKey;
 
-  // TODO: test with abstract types and keys
   @Before
   public void setupTypes() throws Exception {
     EdmProvider provider = mock(EdmProvider.class);
@@ -185,6 +185,7 @@ public class EdmEntityTypeImplTest {
     assertNotNull(keyPropertyRefs);
     assertEquals(1, keyPropertyRefs.size());
     assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName());
+    assertTrue(keyPropertyRefs == typeWithBaseType.getKeyPropertyRefs());
   }
 
   @Test
@@ -241,4 +242,35 @@ public class EdmEntityTypeImplTest {
     assertTrue(property == typeWithBaseType.getProperty("nav2"));
   }
 
+  @Test(expected = EdmException.class)
+  public void noKeyOnTypeWithoutBaseTypeMustResultInException() {
+    EdmProviderImpl edm = mock(EdmProviderImpl.class);
+    EntityType entityType = new EntityType().setName("n");
+    new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+  }
+
+  @Test
+  public void abstractTypeDoesNotNeedKey() {
+    EdmProviderImpl edm = mock(EdmProviderImpl.class);
+    EntityType entityType = new EntityType().setName("n").setAbstract(true);
+    new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+  }
+
+  @Test(expected = EdmException.class)
+  public void invalidBaseType() {
+    EdmProviderImpl edm = mock(EdmProviderImpl.class);
+    EntityType entityType = new EntityType().setName("n").setBaseType(new FullQualifiedName("wrong", "wrong"));
+    new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+  }
+
+  @Test
+  public void abstractTypeWithAbstractBaseTypeDoesNotNeedKey() throws Exception {
+    EdmProvider provider = mock(EdmProvider.class);
+    EdmProviderImpl edm = new EdmProviderImpl(provider);
+    FullQualifiedName baseName = new FullQualifiedName("n", "base");
+    when(provider.getEntityType(baseName)).thenReturn(new EntityType().setName("base").setAbstract(true));
+    EntityType entityType = new EntityType().setName("n").setAbstract(true).setBaseType(baseName);
+    new EdmEntityTypeImpl(edm, new FullQualifiedName("n", "n"), entityType);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImplTest.java
new file mode 100644
index 0000000..91ea8de
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmKeyPropertyRefImplTest.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
+import org.apache.olingo.odata4.commons.api.edm.EdmElement;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmKeyPropertyRef;
+import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.provider.PropertyRef;
+import org.junit.Test;
+
+public class EdmKeyPropertyRefImplTest {
+
+  @Test
+  public void noAlias() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id");
+    EdmEntityType etMock = mock(EdmEntityType.class);
+    EdmProperty keyPropertyMock = mock(EdmProperty.class);
+    when(etMock.getProperty("Id")).thenReturn(keyPropertyMock);
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
+    assertEquals("Id", ref.getKeyPropertyName());
+    assertNull(ref.getAlias());
+    assertNull(ref.getPath());
+
+    EdmProperty property = ref.getProperty();
+    assertNotNull(property);
+    assertTrue(property == keyPropertyMock);
+    assertTrue(property == ref.getProperty());
+  }
+
+  @Test
+  public void aliasForPropertyInComplexPropertyOneLevel() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/Id");
+    EdmEntityType etMock = mock(EdmEntityType.class);
+    EdmProperty keyPropertyMock = mock(EdmProperty.class);
+    EdmElement compMock = mock(EdmProperty.class);
+    EdmComplexType compTypeMock = mock(EdmComplexType.class);
+    when(compTypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+    when(compMock.getType()).thenReturn(compTypeMock);
+    when(etMock.getProperty("comp")).thenReturn(compMock);
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
+    assertEquals("alias", ref.getAlias());
+    assertEquals("comp/Id", ref.getPath());
+
+    EdmProperty property = ref.getProperty();
+    assertNotNull(property);
+    assertTrue(property == keyPropertyMock);
+  }
+
+  @Test(expected = EdmException.class)
+  public void aliasForPropertyInComplexPropertyButWrongPath() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/wrong");
+    EdmEntityType etMock = mock(EdmEntityType.class);
+    EdmProperty keyPropertyMock = mock(EdmProperty.class);
+    EdmElement compMock = mock(EdmProperty.class);
+    EdmComplexType compTypeMock = mock(EdmComplexType.class);
+    when(compTypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+    when(compMock.getType()).thenReturn(compTypeMock);
+    when(etMock.getProperty("comp")).thenReturn(compMock);
+    new EdmKeyPropertyRefImpl(etMock, providerRef).getProperty();
+  }
+
+  @Test(expected = EdmException.class)
+  public void aliasForPropertyInComplexPropertyButWrongPath2() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("wrong/Id");
+    EdmEntityType etMock = mock(EdmEntityType.class);
+    EdmProperty keyPropertyMock = mock(EdmProperty.class);
+    EdmElement compMock = mock(EdmProperty.class);
+    EdmComplexType compTypeMock = mock(EdmComplexType.class);
+    when(compTypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+    when(compMock.getType()).thenReturn(compTypeMock);
+    when(etMock.getProperty("comp")).thenReturn(compMock);
+    new EdmKeyPropertyRefImpl(etMock, providerRef).getProperty();
+  }
+
+  @Test
+  public void aliasForPropertyInComplexPropertyTwoLevels() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/comp2/Id");
+    EdmEntityType etMock = mock(EdmEntityType.class);
+    EdmProperty keyPropertyMock = mock(EdmProperty.class);
+    EdmElement compMock = mock(EdmProperty.class);
+    EdmComplexType compTypeMock = mock(EdmComplexType.class);
+    EdmElement comp2Mock = mock(EdmProperty.class);
+    EdmComplexType comp2TypeMock = mock(EdmComplexType.class);
+    when(comp2TypeMock.getProperty("Id")).thenReturn(keyPropertyMock);
+    when(comp2Mock.getType()).thenReturn(comp2TypeMock);
+    when(compTypeMock.getProperty("comp2")).thenReturn(comp2Mock);
+    when(compMock.getType()).thenReturn(compTypeMock);
+    when(etMock.getProperty("comp")).thenReturn(compMock);
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
+
+    EdmProperty property = ref.getProperty();
+    assertNotNull(property);
+    assertTrue(property == keyPropertyMock);
+  }
+
+  @Test(expected = EdmException.class)
+  public void oneKeyNoAliasButInvalidProperty() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id");
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
+    ref.getProperty();
+  }
+
+  @Test(expected = EdmException.class)
+  public void aliasButNoPath() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias");
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
+    ref.getProperty();
+  }
+
+  @Test(expected = EdmException.class)
+  public void aliasButEmptyPath() {
+    PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("");
+    EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
+    ref.getProperty();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/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
index 0ea82de..b652da2 100644
--- 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
@@ -19,8 +19,11 @@
 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.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;
 
@@ -29,6 +32,7 @@ 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.EdmException;
 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;
@@ -41,43 +45,154 @@ 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");
+  private final FullQualifiedName operationName1 = new FullQualifiedName("n", "o1");
+  private final FullQualifiedName operationType1 = new FullQualifiedName("n", "t1");
+  private final FullQualifiedName operationType2 = new FullQualifiedName("n", "t2");
+  private final FullQualifiedName wrongOperationName = new FullQualifiedName("wrong", "wrong");
+  private final FullQualifiedName badOperationName = new FullQualifiedName("bad", "bad");
 
   @Before
   public void setup() throws Exception {
     EdmProvider provider = mock(EdmProvider.class);
 
-    Action action = new Action().setName(FQN.getName());
     List<Action> actions = new ArrayList<Action>();
+    Action action = new Action().setName(operationName1.getName());
     actions.add(action);
-    when(provider.getActions(FQN)).thenReturn(actions);
+    List<Parameter> action1Parameters = new ArrayList<Parameter>();
+    action1Parameters.add(new Parameter().setType(operationType1).setCollection(false));
+    action =
+        new Action().setName(operationName1.getName()).setBound(true).setParameters(action1Parameters);
+    actions.add(action);
+    List<Parameter> action2Parameters = new ArrayList<Parameter>();
+    action2Parameters.add(new Parameter().setType(operationType1).setCollection(true));
+    action =
+        new Action().setName(operationName1.getName()).setBound(true).setParameters(action2Parameters);
+    actions.add(action);
+    when(provider.getActions(operationName1)).thenReturn(actions);
 
-    Function function = new Function().setName(FQN.getName()).setParameters(new ArrayList<Parameter>());
     List<Function> functions = new ArrayList<Function>();
+    Function function = new Function().setName(operationName1.getName());
+    functions.add(function);
+    List<Parameter> function1Parameters = new ArrayList<Parameter>();
+    function1Parameters.add(new Parameter().setType(operationType1).setName("a"));
+    function = new Function().setName(operationName1.getName()).setParameters(function1Parameters);
+    functions.add(function);
+    List<Parameter> function2Parameters = new ArrayList<Parameter>();
+    function2Parameters.add(new Parameter().setType(operationType1).setName("b"));
+    function = new Function().setName(operationName1.getName()).setParameters(function2Parameters);
     functions.add(function);
-    when(provider.getFunctions(FQN)).thenReturn(functions);
+    List<Parameter> function3Parameters = new ArrayList<Parameter>();
+    function3Parameters.add(new Parameter().setName("a").setType(operationType1));
+    function3Parameters.add(new Parameter().setName("b"));
+    function = new Function().setName(operationName1.getName()).setParameters(function3Parameters).setBound(true);
+    functions.add(function);
+    List<Parameter> function4Parameters = new ArrayList<Parameter>();
+    function4Parameters.add(new Parameter().setName("a").setType(operationType2));
+    function4Parameters.add(new Parameter().setName("b"));
+    function = new Function().setName(operationName1.getName()).setParameters(function4Parameters).setBound(true);
+    functions.add(function);
+    when(provider.getFunctions(operationName1)).thenReturn(functions);
+
+    List<Function> badFunctions = new ArrayList<Function>();
+    Function badFunction = new Function().setName(operationName1.getName()).setBound(true).setParameters(null);
+    badFunctions.add(badFunction);
+
+    when(provider.getFunctions(badOperationName)).thenReturn(badFunctions);
+
     edm = new EdmProviderImpl(provider);
   }
 
   @Test
   public void simpleActionGet() {
-    EdmAction action = edm.getAction(FQN, null, null);
+    EdmAction action = edm.getAction(operationName1, null, null);
     assertNotNull(action);
-    assertEquals(FQN.getNamespace(), action.getNamespace());
-    assertEquals(FQN.getName(), action.getName());
+    assertEquals(operationName1.getNamespace(), action.getNamespace());
+    assertEquals(operationName1.getName(), action.getName());
+
+    assertNull(edm.getAction(wrongOperationName, null, null));
+  }
+
+  @Test
+  public void boundActionOverloading() {
+    EdmAction action = edm.getAction(operationName1, operationType1, false);
+    assertNotNull(action);
+    assertEquals(operationName1.getNamespace(), action.getNamespace());
+    assertEquals(operationName1.getName(), action.getName());
+    assertTrue(action == edm.getAction(operationName1, operationType1, false));
+
+    EdmAction action2 = edm.getAction(operationName1, operationType1, true);
+    assertNotNull(action2);
+    assertEquals(operationName1.getNamespace(), action2.getNamespace());
+    assertEquals(operationName1.getName(), action2.getName());
+    assertTrue(action2 == edm.getAction(operationName1, operationType1, true));
 
-    assertNull(edm.getAction(WRONG_FQN, null, null));
+    assertNotSame(action, action2);
   }
 
   @Test
   public void simpleFunctionGet() {
-    EdmFunction function = edm.getFunction(FQN, null, null, new ArrayList<String>());
+    EdmFunction function = edm.getFunction(operationName1, null, null, null);
     assertNotNull(function);
-    assertEquals(FQN.getNamespace(), function.getNamespace());
-    assertEquals(FQN.getName(), function.getName());
+    assertEquals(operationName1.getNamespace(), function.getNamespace());
+    assertEquals(operationName1.getName(), function.getName());
+
+    EdmFunction function2 = edm.getFunction(operationName1, null, null, new ArrayList<String>());
+    assertNotNull(function2);
+    assertEquals(operationName1.getNamespace(), function2.getNamespace());
+    assertEquals(operationName1.getName(), function2.getName());
+
+    assertEquals(function, function2);
+
+    assertNull(edm.getFunction(wrongOperationName, null, null, new ArrayList<String>()));
+  }
+
+  @Test
+  public void functionOverloading() {
+    ArrayList<String> parameter1Names = new ArrayList<String>();
+    parameter1Names.add("a");
+    List<String> parameter2Names = new ArrayList<String>();
+    parameter2Names.add("b");
+    EdmFunction function = edm.getFunction(operationName1, null, null, new ArrayList<String>());
+    assertNotNull(function);
+    assertFalse(function.isBound());
+
+    EdmFunction function1 = edm.getFunction(operationName1, null, null, parameter1Names);
+    assertNotNull(function1);
+    assertFalse(function1.isBound());
+
+    assertFalse(function == function1);
+    assertNotSame(function, function1);
+
+    EdmFunction function2 = edm.getFunction(operationName1, null, null, parameter2Names);
+    assertNotNull(function2);
+    assertFalse(function2.isBound());
+
+    assertFalse(function1 == function2);
+    assertNotSame(function1, function2);
+
+    EdmFunction function3 = edm.getFunction(operationName1, operationType1, false, parameter2Names);
+    assertNotNull(function3);
+    assertTrue(function3.isBound());
+    EdmFunction function4 = edm.getFunction(operationName1, operationType2, false, parameter2Names);
+    assertNotNull(function4);
+    assertTrue(function4.isBound());
+
+    assertFalse(function3 == function4);
+    assertNotSame(function3, function4);
+
+    assertFalse(function1 == function3);
+    assertFalse(function1 == function4);
+    assertFalse(function2 == function3);
+    assertFalse(function2 == function4);
+    assertNotSame(function1, function3);
+    assertNotSame(function1, function4);
+    assertNotSame(function2, function3);
+    assertNotSame(function2, function4);
+  }
 
-    assertNull(edm.getFunction(WRONG_FQN, null, null, new ArrayList<String>()));
+  @Test(expected = EdmException.class)
+  public void noParametersAtBoundFunctionReslutsInException() {
+    edm.getFunction(badOperationName, operationType1, true, null);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/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 d5bcdfe..24fcbd2 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
@@ -84,6 +84,24 @@ public class EdmProviderImplTest {
   }
 
   @Test
+  public void nothingSpecifiedMustNotResultInExceptions() throws Exception {
+    EdmProvider localProvider = mock(EdmProvider.class);
+    when(localProvider.getActions(FQN)).thenReturn(null);
+    when(localProvider.getFunctions(FQN)).thenReturn(null);
+    Edm localEdm = new EdmProviderImpl(localProvider);
+    localEdm.getAction(FQN, null, null);
+    localEdm.getFunction(FQN, null, null, null);
+    localEdm.getAction(FQN, FQN, true);
+    localEdm.getFunction(FQN, FQN, true, null);
+    localEdm.getComplexType(FQN);
+    localEdm.getEntityContainer(FQN);
+    localEdm.getEntityType(FQN);
+    localEdm.getEnumType(FQN);
+    localEdm.getTypeDefinition(FQN);
+    localEdm.getServiceMetadata();
+  }
+
+  @Test
   public void convertExceptionsTest() throws Exception {
     EdmProvider localProvider = mock(EdmProvider.class);
     FullQualifiedName fqn = new FullQualifiedName("namespace", "name");
@@ -115,6 +133,17 @@ public class EdmProviderImplTest {
     } catch (EdmException e) {
       assertEquals("org.apache.olingo.odata4.commons.api.exception.ODataException: msg", e.getMessage());
     }
+    try {
+      localEdm.getAction(fqn, fqn, true);
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.odata4.commons.api.exception.ODataException: msg", e.getMessage());
+    }
+
+    try {
+      localEdm.getFunction(fqn, fqn, true, null);
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.odata4.commons.api.exception.ODataException: msg", e.getMessage());
+    }
   }
 
   private void callMethodAndExpectEdmException(final Edm localEdm, final String methodName) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b886528b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImplTest.java
index 906b416..62d31e9 100644
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImplTest.java
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImplTest.java
@@ -12,6 +12,7 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
 import org.apache.olingo.odata4.commons.api.edm.provider.TypeDefinition;
 import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
 import org.junit.Test;
+
 /*******************************************************************************
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file