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 2013/12/18 10:12:20 UTC

[22/37] [OLINGO-82] Renamed the project folder name to odata2-jpa-processor

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
new file mode 100644
index 0000000..4192c2b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmModelTest extends JPAEdmTestModelView {
+
+  private JPAEdmModel objJPAEdmModel;
+
+  @Before
+  public void setUp() {
+    objJPAEdmModel = new JPAEdmModel(getJPAMetaModel(), "salesorderprocessing");
+    try {
+      objJPAEdmModel.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+
+  @Test
+  public void testGetEdmSchemaView() {
+    assertNotNull(objJPAEdmModel.getEdmSchemaView());
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objJPAEdmModel.getBuilder());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  private class JPAEdmMetaModel extends JPAMetaModelMock {
+    Set<EmbeddableType<?>> embeddableSet;
+
+    public JPAEdmMetaModel() {
+      embeddableSet = new HashSet<EmbeddableType<?>>();
+    }
+
+    @Override
+    public Set<EmbeddableType<?>> getEmbeddables() {
+      embeddableSet.add(new JPAEdmEmbeddable<String>());
+      return embeddableSet;
+    }
+
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String> {
+
+    Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private void setValuesToSet() {
+      attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+      attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+    }
+
+    @Override
+    public Set<Attribute<? super String, ?>> getAttributes() {
+      setValuesToSet();
+      return attributeSet;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) java.lang.String.class;
+    }
+
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+    @Override
+    public PersistentAttributeType getPersistentAttributeType() {
+      return PersistentAttributeType.BASIC;
+    }
+
+    Class<String> clazz;
+    java.lang.String attributeName;
+
+    public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+      this.clazz = javaType;
+      this.attributeName = name;
+
+    }
+
+    @Override
+    public Class<String> getJavaType() {
+      return clazz;
+    }
+
+    @Override
+    public java.lang.String getName() {
+      return this.attributeName;
+    }
+
+    @Override
+    public boolean isId() {
+      return false;
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
new file mode 100644
index 0000000..8912bf8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Type;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmNavigationPropertyTest extends JPAEdmTestModelView {
+
+  private static JPAEdmNavigationProperty objNavigationProperty;
+  private static JPAEdmNavigationPropertyTest navPropView;
+
+  @BeforeClass
+  public static void setup() {
+    JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+    navPropView = new JPAEdmNavigationPropertyTest();
+    objNavigationProperty = new JPAEdmNavigationProperty(localView,
+        localView, 1);
+    try {
+      objNavigationProperty.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  @Override
+  public EntityType<?> getJPAEntityType() {
+    return new JPAEdmEntityType();
+  }
+
+  private Attribute<?, ?> getJPAAttributeLocal() {
+    AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+    return attr;
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return getJPAAttributeLocal();
+  }
+
+  @Override
+  public Association getEdmAssociation() {
+
+    Association association = new Association();
+    association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+    association.setEnd1(new AssociationEnd().setType(
+        new FullQualifiedName("salesorderprocessing", "String"))
+        .setRole("SalesOrderHeader"));
+    association.setEnd2(new AssociationEnd()
+        .setType(
+            new FullQualifiedName("salesorderprocessing",
+                "SalesOrderItem")).setRole("SalesOrderItem"));
+    return association;
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objNavigationProperty.getBuilder());
+
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objNavigationProperty.getBuilder();
+    JPAEdmBuilder builder2 = objNavigationProperty.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetEdmNavigationProperty() {
+    if (objNavigationProperty == null || objNavigationProperty.getEdmNavigationProperty() == null) {
+      JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+      navPropView = new JPAEdmNavigationPropertyTest();
+      objNavigationProperty = new JPAEdmNavigationProperty(localView,
+          localView, 1);
+      try {
+        objNavigationProperty.getBuilder().build();
+      } catch (ODataJPAModelException e) {
+        fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+      } catch (ODataJPARuntimeException e) {
+        fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+      }
+    }
+    assertEquals(
+        objNavigationProperty.getEdmNavigationProperty().getName(),
+        "StringDetails");
+  }
+
+  @Test
+  public void testGetConsistentEdmNavigationProperties() {
+    assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
+        .size() > 0);
+  }
+
+  @Test
+  public void testAddJPAEdmNavigationPropertyView() {
+    JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+    navPropView = new JPAEdmNavigationPropertyTest();
+    objNavigationProperty = new JPAEdmNavigationProperty(localView,
+        localView, 1);
+    try {
+      objNavigationProperty.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    objNavigationProperty.addJPAEdmNavigationPropertyView(navPropView);
+    assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
+        .size() > 1);
+  }
+
+  @Override
+  public boolean isConsistent() {
+    return true;
+  }
+
+  @Test
+  public void testBuildNavigationProperty() {
+
+    try {
+      objNavigationProperty.getBuilder().build();
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    assertEquals(objNavigationProperty.getEdmNavigationProperty()
+        .getFromRole(), "SalesOrderItem");
+    assertEquals(objNavigationProperty.getEdmNavigationProperty()
+        .getToRole(), "SalesOrderHeader");
+
+  }
+
+  @SuppressWarnings("hiding")
+  private class AttributeMock<Object, String> extends
+      JPAPluralAttributeMock {
+
+    @Override
+    public boolean isCollection() {
+      return true;
+    }
+
+    @Override
+    public Type<java.lang.String> getElementType() {
+      return new ElementType();
+    }
+  }
+
+  private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+    @Override
+    public String getName() {
+      return "SalesOrderHeader";
+    }
+  }
+
+  private class ElementType implements Type<String> {
+
+    @Override
+    public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+      return PersistenceType.BASIC;
+    }
+
+    @Override
+    public Class<String> getJavaType() {
+      return String.class;
+    }
+
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
new file mode 100644
index 0000000..633459f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.metamodel.Type;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Test;
+
+public class JPAEdmPropertyTest extends JPAEdmTestModelView {
+
+  private JPAEdmPropertyTest objJPAEdmPropertyTest;
+  private JPAEdmProperty objJPAEdmProperty;
+
+  private static PersistentAttributeType ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
+
+  public void setUp() {
+    ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
+    objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+    objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
+    try {
+      objJPAEdmProperty.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+
+  }
+
+  @Test
+  public void testGetBuilder() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getBuilder());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    setUp();
+    JPAEdmBuilder builder1 = objJPAEdmProperty.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmProperty.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetPropertyList() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getEdmPropertyList());
+    assertTrue(objJPAEdmProperty.getEdmPropertyList().size() > 0);
+  }
+
+  @Test
+  public void testGetJPAEdmKeyView() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getJPAEdmKeyView());
+  }
+
+  @Test
+  public void testGetSimpleProperty() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getEdmSimpleProperty());
+  }
+
+  @Test
+  public void testGetJPAAttribute() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getJPAAttribute());
+  }
+
+  @Test
+  public void testGetEdmComplexProperty() {
+
+    // builder for complex type
+    ATTRIBUTE_TYPE = PersistentAttributeType.EMBEDDED;
+    objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+    objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest, objJPAEdmPropertyTest);
+    try {
+      objJPAEdmProperty.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+
+    assertNotNull(objJPAEdmProperty.getEdmComplexProperty());
+  }
+
+  @Test
+  public void testGetJPAEdmNavigationPropertyView() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    setUp();
+    assertNotNull(objJPAEdmProperty.isConsistent());
+  }
+
+  @Test
+  public void testClean() {
+    setUp();
+    objJPAEdmProperty.clean();
+    assertFalse(objJPAEdmProperty.isConsistent());
+  }
+
+  @Test
+  public void testBuildManyToOne() {
+    ATTRIBUTE_TYPE = PersistentAttributeType.MANY_TO_ONE;
+    objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+    objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
+    try {
+      objJPAEdmProperty.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+
+    assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView().getEdmNavigationProperty());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  @Override
+  public List<String> getNonKeyComplexTypeList() {
+    return new ArrayList<String>();
+  }
+
+  @Override
+  public Schema getEdmSchema() {
+    Schema schema = new Schema();
+    schema.setNamespace(getpUnitName());
+    return schema;
+  }
+
+  @Override
+  public org.apache.olingo.odata2.api.edm.provider.ComplexType searchEdmComplexType(final String arg0) {
+    org.apache.olingo.odata2.api.edm.provider.ComplexType complexType =
+        new org.apache.olingo.odata2.api.edm.provider.ComplexType();
+    complexType.setName("ComplexTypeA");
+    return complexType;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public EntityType<?> getJPAEntityType() {
+    return new JPAEdmEntityType<String>();
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  @Override
+  public org.apache.olingo.odata2.api.edm.provider.EntityType getEdmEntityType() {
+    org.apache.olingo.odata2.api.edm.provider.EntityType entityType =
+        new org.apache.olingo.odata2.api.edm.provider.EntityType();
+    entityType.setName("SalesOrderHeader");
+
+    return entityType;
+  }
+
+  @Override
+  public Association getEdmAssociation() {
+    Association association = new Association();
+    association
+        .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
+    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));
+
+    return association;
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @Override
+  public JPAEdmAssociationView getJPAEdmAssociationView() {
+    return this;
+  }
+
+  @Override
+  public EmbeddableType<?> getJPAEmbeddableType() {
+    return new JPAEdmEmbeddable<java.lang.String>();
+  }
+
+  @Override
+  public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+    return this;
+  }
+
+  private class JPAEdmMetaModel extends JPAMetaModelMock {
+    Set<EntityType<?>> entities;
+    Set<EmbeddableType<?>> embeddableSet;
+
+    public JPAEdmMetaModel() {
+      entities = new HashSet<EntityType<?>>();
+      embeddableSet = new HashSet<EmbeddableType<?>>();
+    }
+
+    @Override
+    public Set<EntityType<?>> getEntities() {
+      entities.add(new JPAEdmEntityType());
+      return entities;
+    }
+
+    @Override
+    public Set<EmbeddableType<?>> getEmbeddables() {
+      embeddableSet.add(new JPAEdmEmbeddable<String>());
+      return embeddableSet;
+    }
+
+    private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+      @Override
+      public String getName() {
+        return "SalesOrderHeader";
+      }
+    }
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
+    Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private void setValuesToSet() {
+      if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
+        attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+        attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+      } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.EMBEDDED)) {
+        attributeSet.add(new JPAEdmAttribute(JPAEdmEmbeddable.class, ComplexType.ComplexTypeA.clazz.getName()));
+      } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.MANY_TO_ONE)) {
+        attributeSet.add(new JPAEdmPluralAttribute());
+      }
+    }
+
+    @Override
+    public Set<Attribute<? super String, ?>> getAttributes() {
+      setValuesToSet();
+      return attributeSet;
+    }
+
+    private class JPAEdmPluralAttribute extends JPAPluralAttributeMock {
+      @Override
+      public java.lang.String getName() {
+        return "salesorderheaderdetails";
+      }
+
+      @Override
+      public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+        return ATTRIBUTE_TYPE;
+      }
+
+      @Override
+      public boolean isCollection() {
+        return true;
+      }
+
+      @Override
+      public Type<java.lang.String> getElementType() {
+        return new Type<java.lang.String>() {
+
+          @Override
+          public Class<java.lang.String> getJavaType() {
+            return java.lang.String.class;
+          }
+
+          @Override
+          public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+            return null;
+          }
+
+        };
+      }
+    }
+
+    private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+      @Override
+      public PersistentAttributeType getPersistentAttributeType() {
+        return ATTRIBUTE_TYPE;
+      }
+
+      Class<String> clazz;
+      java.lang.String attributeName;
+
+      public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+        this.clazz = javaType;
+        this.attributeName = name;
+
+      }
+
+      @Override
+      public Class<String> getJavaType() {
+        return clazz;
+      }
+
+      @Override
+      public java.lang.String getName() {
+        return this.attributeName;
+      }
+
+      @Override
+      public boolean isId() {
+        return true;
+      }
+    }
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAEdmEmbeddable<String> extends JPAEmbeddableTypeMock<String> {
+
+    Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private void setValuesToSet() {
+      attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+      attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+    }
+
+    @Override
+    public Set<Attribute<? super String, ?>> getAttributes() {
+      setValuesToSet();
+      return attributeSet;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      Class<?> clazz = null;
+      if (ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
+        clazz = (Class<java.lang.String>) SimpleType.SimpleTypeA.clazz;
+      } else {
+        clazz = (Class<?>) ComplexType.ComplexTypeA.clazz;
+      }
+      return (Class<String>) clazz;
+    }
+
+    private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+      @Override
+      public PersistentAttributeType getPersistentAttributeType() {
+        return ATTRIBUTE_TYPE;
+      }
+
+      Class<String> clazz;
+      java.lang.String attributeName;
+
+      public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+        this.clazz = javaType;
+        this.attributeName = name;
+
+      }
+
+      @Override
+      public Class<String> getJavaType() {
+        return clazz;
+      }
+
+      @Override
+      public java.lang.String getName() {
+        return this.attributeName;
+      }
+
+      @Override
+      public boolean isId() {
+        return true;
+      }
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
new file mode 100644
index 0000000..6c8c5eb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+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.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView.RoleType;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmReferentialConstraintRoleTest extends JPAEdmTestModelView {
+
+  private static JPAEdmReferentialConstraintRole objJPAEdmReferentialConstraintRole = null;
+  private static JPAEdmReferentialConstraintRoleTest objJPAEdmReferentialConstraintRoleTest = null;
+
+  @Before
+  public void setUp() {
+    objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
+
+    objJPAEdmReferentialConstraintRole =
+        new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, objJPAEdmReferentialConstraintRoleTest,
+            objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
+
+    try {
+      objJPAEdmReferentialConstraintRole.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+
+  @Test
+  public void testIsExists() {
+    assertTrue(objJPAEdmReferentialConstraintRole.isExists());// Default
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objJPAEdmReferentialConstraintRole.getBuilder());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmReferentialConstraintRole.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmReferentialConstraintRole.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetRoleTypePrincipal() {
+    assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.PRINCIPAL);
+  }
+
+  @Test
+  public void testGetRoleTypeDependent() {
+    objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
+    objJPAEdmReferentialConstraintRole =
+        new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, objJPAEdmReferentialConstraintRoleTest,
+            objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
+
+    try {
+      objJPAEdmReferentialConstraintRole.getBuilder().build();
+      objJPAEdmReferentialConstraintRole.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.DEPENDENT);
+  }
+
+  @Test
+  public void testGetEdmReferentialConstraintRole() {
+    try {
+      objJPAEdmReferentialConstraintRole.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    assertNotNull(objJPAEdmReferentialConstraintRole.getEdmReferentialConstraintRole());
+  }
+
+  @Test
+  public void testGetJPAColumnName() {
+    assertNull(objJPAEdmReferentialConstraintRole.getJPAColumnName());
+  }
+
+  @Test
+  public void testGetEdmEntityTypeName() {
+    assertNull(objJPAEdmReferentialConstraintRole.getEdmEntityTypeName());
+  }
+
+  @Test
+  public void testGetEdmAssociationName() {
+    assertNull(objJPAEdmReferentialConstraintRole.getEdmAssociationName());
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return getJPAAttributeLocal();
+  }
+
+  @Override
+  public Association getEdmAssociation() {
+    Association association = new Association();
+    association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+    association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
+        "SalesOrderHeader"));
+    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
+        .setRole("SalesOrderItem"));
+    return association;
+  }
+
+  @Override
+  public EntityType searchEdmEntityType(final String arg0) {
+
+    EntityType entityType = new EntityType();
+
+    JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
+    mapping.setJPAColumnName("SOID");
+
+    List<Property> propList = new ArrayList<Property>();
+
+    Property property = new Property() {};
+    property.setMapping((Mapping) mapping);
+    property.setName("SOID");
+    propList.add(property);
+
+    entityType.setProperties(propList);
+
+    return entityType;
+  }
+
+  private Attribute<?, ?> getJPAAttributeLocal() {
+    AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+    return attr;
+  }
+
+  @SuppressWarnings("hiding")
+  private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+    @Override
+    public Member getJavaMember() {
+      return new JavaMemberMock();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) java.lang.String.class;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public ManagedType<Object> getDeclaringType() {
+      return (ManagedType<Object>) getManagedTypeLocal();
+    }
+
+    private ManagedType<?> getManagedTypeLocal() {
+      ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
+      return managedTypeMock;
+    }
+  }
+
+  @SuppressWarnings("hiding")
+  private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) java.lang.String.class;
+    }
+  }
+
+  private class JavaMemberMock extends JPAJavaMemberMock {
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+      JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+      EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
+      EasyMock.expect(joinColumn.name()).andReturn("SOID");
+
+      EasyMock.replay(joinColumn);
+      return (T) joinColumn;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
new file mode 100644
index 0000000..84b7ad4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmReferentialConstraintTest extends JPAEdmTestModelView {
+
+  private static JPAEdmReferentialConstraint objJPAEdmReferentialConstraint = null;
+  private static JPAEdmReferentialConstraintTest objJPAEdmReferentialConstraintTest = null;
+
+  @Before
+  public void setUp() {
+    objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
+    objJPAEdmReferentialConstraint =
+        new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
+            objJPAEdmReferentialConstraintTest);
+    try {
+      objJPAEdmReferentialConstraint.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objJPAEdmReferentialConstraint.getBuilder());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmReferentialConstraint.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmReferentialConstraint.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetEdmReferentialConstraint() {
+    assertNotNull(objJPAEdmReferentialConstraint.getEdmReferentialConstraint());
+  }
+
+  @Test
+  public void testIsExistsTrue() {
+    objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
+    objJPAEdmReferentialConstraint =
+        new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
+            objJPAEdmReferentialConstraintTest);
+    try {
+      objJPAEdmReferentialConstraint.getBuilder().build();
+      objJPAEdmReferentialConstraint.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    assertTrue(objJPAEdmReferentialConstraint.isExists());
+  }
+
+  @Test
+  public void testGetRelationShipName() {
+    assertEquals("Assoc_SalesOrderHeader_SalesOrderItem", objJPAEdmReferentialConstraint.getEdmRelationShipName());
+  }
+
+  @Override
+  public Association getEdmAssociation() {
+    Association association = new Association();
+    association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+    association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
+        "SalesOrderHeader"));
+    association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
+        .setRole("SalesOrderItem"));
+    return association;
+  }
+
+  private Attribute<?, ?> getJPAAttributeLocal() {
+    AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+    return attr;
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return getJPAAttributeLocal();
+  }
+
+  @SuppressWarnings("hiding")
+  private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+    @Override
+    public Member getJavaMember() {
+      return new JavaMemberMock();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) java.lang.String.class;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public ManagedType<Object> getDeclaringType() {
+      return (ManagedType<Object>) getManagedTypeLocal();
+    }
+
+    private ManagedType<?> getManagedTypeLocal() {
+      ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
+      return managedTypeMock;
+    }
+  }
+
+  @SuppressWarnings("hiding")
+  private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) java.lang.String.class;
+    }
+  }
+
+  private class JavaMemberMock extends JPAJavaMemberMock {
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+      JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+      EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
+      EasyMock.expect(joinColumn.name()).andReturn("SOID");
+
+      EasyMock.replay(joinColumn);
+      return (T) joinColumn;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
new file mode 100644
index 0000000..9d6848a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmSchemaTest extends JPAEdmTestModelView {
+  private JPAEdmSchemaTest objJPAEdmSchemaTest;
+  private JPAEdmSchema objJPAEdmSchema;
+
+  @Before
+  public void setUp() {
+    objJPAEdmSchemaTest = new JPAEdmSchemaTest();
+    objJPAEdmSchema = new JPAEdmSchema(objJPAEdmSchemaTest);
+    // building schema is not required as downstream structure already tested
+
+  }
+
+  @Test
+  public void testClean() {
+    assertTrue(objJPAEdmSchema.isConsistent());
+    objJPAEdmSchema.clean();
+    assertFalse(objJPAEdmSchema.isConsistent());
+  }
+
+  @Test
+  public void testGetEdmSchema() {
+    assertNull(objJPAEdmSchema.getEdmSchema());
+  }
+
+  @Test
+  public void testGetJPAEdmEntityContainerView() {
+    assertNull(objJPAEdmSchema.getJPAEdmEntityContainerView());
+  }
+
+  @Test
+  public void testGetJPAEdmComplexTypeView() {
+    assertNull(objJPAEdmSchema.getJPAEdmComplexTypeView());
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objJPAEdmSchema.getBuilder());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmSchema.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmSchema.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetJPAEdmAssociationView() {
+    assertNull(objJPAEdmSchema.getJPAEdmAssociationView());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmSchema.isConsistent());
+    objJPAEdmSchema.clean();
+    assertFalse(objJPAEdmSchema.isConsistent());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAMetaModelMock();
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
new file mode 100644
index 0000000..cf96ac7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+
+public class JPAEdmTestModelView implements JPAEdmAssociationEndView, JPAEdmAssociationSetView, JPAEdmAssociationView,
+    JPAEdmBaseView, JPAEdmComplexPropertyView, JPAEdmComplexTypeView, JPAEdmEntityContainerView, JPAEdmEntitySetView,
+    JPAEdmEntityTypeView, JPAEdmKeyView, JPAEdmModelView, JPAEdmNavigationPropertyView, JPAEdmPropertyView,
+    JPAEdmReferentialConstraintView, JPAEdmSchemaView {
+
+  protected JPAEdmMappingModelAccess mappingModelAccess;
+
+  @Override
+  public Schema getEdmSchema() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmAssociationView getJPAEdmAssociationView() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return null;
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmKeyView getJPAEdmKeyView() {
+    return null;
+  }
+
+  @Override
+  public List<Property> getEdmPropertyList() {
+    return null;
+  }
+
+  @Override
+  public SimpleProperty getEdmSimpleProperty() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmSchemaView getEdmSchemaView() {
+    return null;
+  }
+
+  @Override
+  public Key getEdmKey() {
+    return null;
+  }
+
+  @Override
+  public List<EntityType> getConsistentEdmEntityTypes() {
+    return null;
+  }
+
+  @Override
+  public EntityType getEdmEntityType() {
+    return null;
+  }
+
+  @Override
+  public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
+    return null;
+  }
+
+  @Override
+  public List<EntitySet> getConsistentEdmEntitySetList() {
+    return null;
+  }
+
+  @Override
+  public EntitySet getEdmEntitySet() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return null;
+  }
+
+  @Override
+  public List<EntityContainer> getConsistentEdmEntityContainerList() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmAssociationSetView getEdmAssociationSetView() {
+    return null;
+  }
+
+  @Override
+  public EntityContainer getEdmEntityContainer() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return null;
+  }
+
+  @Override
+  public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView arg0) {
+
+  }
+
+  @Override
+  public List<ComplexType> getConsistentEdmComplexTypes() {
+    return null;
+  }
+
+  @Override
+  public ComplexType getEdmComplexType() {
+    return null;
+  }
+
+  @Override
+  public EmbeddableType<?> getJPAEmbeddableType() {
+    return null;
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final String arg0) {
+    return null;
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
+    return null;
+  }
+
+  @Override
+  public ComplexProperty getEdmComplexProperty() {
+    return null;
+  }
+
+  @Override
+  public void clean() {
+
+  }
+
+  @Override
+  public JPAEdmBuilder getBuilder() {
+    return null;
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return null;
+  }
+
+  @Override
+  public String getpUnitName() {
+    return null;
+  }
+
+  @Override
+  public boolean isConsistent() {
+    return false;
+  }
+
+  @Override
+  public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView arg0) {
+
+  }
+
+  @Override
+  public ReferentialConstraint getEdmReferentialConstraint() {
+    return null;
+  }
+
+  @Override
+  public String getEdmRelationShipName() {
+    return null;
+  }
+
+  @Override
+  public boolean isExists() {
+    return false;
+  }
+
+  @Override
+  public EntityType searchEdmEntityType(final String arg0) {
+    return null;
+  }
+
+  @Override
+  public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+    return null;
+  }
+
+  @Override
+  public List<Association> getConsistentEdmAssociationList() {
+    return null;
+  }
+
+  @Override
+  public Association searchAssociation(final JPAEdmAssociationEndView arg0) {
+    return null;
+  }
+
+  @Override
+  public List<AssociationSet> getConsistentEdmAssociationSetList() {
+    return null;
+  }
+
+  @Override
+  public Association getEdmAssociation() {
+    return null;
+  }
+
+  @Override
+  public AssociationSet getEdmAssociationSet() {
+    return null;
+  }
+
+  @Override
+  public boolean compare(final AssociationEnd arg0, final AssociationEnd arg1) {
+    return false;
+  }
+
+  @Override
+  public AssociationEnd getEdmAssociationEnd1() {
+    return null;
+  }
+
+  @Override
+  public AssociationEnd getEdmAssociationEnd2() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView() {
+    return null;
+  }
+
+  @Override
+  public void addJPAEdmNavigationPropertyView(final JPAEdmNavigationPropertyView view) {
+
+  }
+
+  @Override
+  public List<NavigationProperty> getConsistentEdmNavigationProperties() {
+    return null;
+  }
+
+  @Override
+  public NavigationProperty getEdmNavigationProperty() {
+    return null;
+  }
+
+  @Override
+  public void expandEdmComplexType(final ComplexType complexType, final List<Property> expandedPropertyList,
+      final String embeddablePropertyName) {
+
+  }
+
+  @Override
+  public List<String> getNonKeyComplexTypeList() {
+    return null;
+  }
+
+  @Override
+  public void addNonKeyComplexName(final String complexTypeName) {}
+
+  @Override
+  public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
+    return null;
+  }
+
+  @Override
+  public void registerOperations(final Class<?> customClass, final String[] methodNames) {
+    // Do nothing
+  }
+
+  @Override
+  public HashMap<Class<?>, String[]> getRegisteredOperations() {
+    return null;
+  }
+
+  @Override
+  public JPAEdmExtension getJPAEdmExtension() {
+    return null;
+  }
+
+  @Override
+  public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
+      final JPAEdmAssociationEndView associationEndView) {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  @Override
+  public String getJoinColumnName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getJoinColumnReferenceColumnName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getMappedByName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getOwningPropertyName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public boolean isDefaultNamingSkipped() {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
new file mode 100644
index 0000000..d596e77
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
@@ -0,0 +1,570 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImportParameter;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.ReturnType;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model._JPACustomProcessorMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model._JPACustomProcessorNegativeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+@Deprecated
+public class _JPAEdmFunctionImportTest extends JPAEdmTestModelView {
+  private static final int METHOD_COUNT = 6;
+  private static int VARIANT = 0;
+  private JPAEdmFunctionImport jpaEdmfunctionImport;
+
+  @Before
+  public void setup() {
+    jpaEdmfunctionImport = new JPAEdmFunctionImport(this);
+  }
+
+  /**
+   * Test Case - Function Import Basic test - Positive Case
+   */
+  @Test
+  public void testFunctionImportBasic() {
+    VARIANT = 0;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+    for (FunctionImport functionImport : functionImportList) {
+      assertEquals(functionImport.getName(), "Method1");
+      assertNotNull(functionImport.getMapping());
+      Mapping mapping = new Mapping();
+      mapping.setInternalName("method1");
+
+      assertEquals(mapping.getInternalName(), functionImport.getMapping().getInternalName());
+
+      ReturnType returnType = functionImport.getReturnType();
+      assertNotNull(returnType);
+      assertEquals(EdmMultiplicity.MANY, returnType.getMultiplicity());
+
+      List<FunctionImportParameter> funcImpList = functionImport.getParameters();
+      assertEquals(2, funcImpList.size());
+      assertEquals("Param1", funcImpList.get(0).getName());
+      assertEquals(EdmSimpleTypeKind.String, funcImpList.get(0).getType());
+      assertEquals(Mode.IN.toString(), funcImpList.get(0).getMode());
+
+      assertEquals("Param3", funcImpList.get(1).getName());
+      assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
+      assertEquals(Mode.IN.toString(), funcImpList.get(1).getMode());
+
+    }
+
+  }
+
+  /**
+   * Test Case - Enable a method that does not exists
+   */
+  @Test
+  public void testFunctionImportNoSuchMethod() {
+    VARIANT = 1;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  /**
+   * Test Case - Enable all annotated methods in a class as function imports
+   */
+  @Test
+  public void testFunctionImportAllMethods() {
+    VARIANT = 2;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(METHOD_COUNT, functionImportList.size());
+
+  }
+
+  /**
+   * Test Case - Function Import with no names. Default name is Java method
+   * name.
+   */
+  @Test
+  public void testFunctionImportNoName() {
+    VARIANT = 3;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method3");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), EdmSimpleTypeKind.Int32.getFullQualifiedName().toString());
+  }
+
+  /**
+   * Test Case - Function Import with No return type defined - Negative case
+   */
+  @Test
+  public void testNoReturnType() {
+    VARIANT = 4;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  /**
+   * Test Case - Function Import with return type as Entity and Multiplicity
+   * as Many but no Entity set defined. --> Negative Case
+   */
+  @Test
+  public void testNoEntitySet() {
+    VARIANT = 5;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_ENTITYSET_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+  }
+
+  /**
+   * Test Case - Function Import with return type as Entity Type but method
+   * has returns void. --> Negative Case
+   */
+  @Test
+  public void testNoReturnTypeButAnnotated() {
+    VARIANT = 6;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+  }
+
+  /**
+   * Test Case - Function Import that returns an Entity Type with Multiplicity
+   * as ONE. -->Positive Case
+   */
+  @Test
+  public void testFunctionImportEntityTypeSingleReturn() {
+    VARIANT = 7;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method7");
+    assertNotNull(functionImport.getMapping());
+    JPAEdmMapping mapping = (JPAEdmMapping) functionImport.getMapping();
+    assertEquals(_JPACustomProcessorMock.class, mapping.getJPAType());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+  }
+
+  /**
+   * Test Case - Function Import that returns an Entity Type that is not found
+   * in JPA Model
+   */
+  @Test
+  public void testFunctionImportEntityTypeInvalid() {
+    VARIANT = 8;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that returns a complex Type
+   */
+  @Test
+  public void testFunctionImportComplexType() {
+    VARIANT = 9;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method9");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+
+  }
+
+  /**
+   * Test Case - Function Import that returns a complex Type with multiplicity
+   * Many
+   */
+  @Test
+  public void testFunctionImportComplexTypeMany() {
+    VARIANT = 10;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method10");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.MANY, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+
+  }
+
+  /**
+   * Test Case - Function Import that returns an Complex Type that is not
+   * found in JPA Model
+   */
+  @Test
+  public void testFunctionImportComplexTypeInvalid() {
+    VARIANT = 11;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that returns an scalar Type that is not valid
+   */
+  @Test
+  public void testFunctionImportScalarTypeInvalid() {
+    VARIANT = 12;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.TYPE_NOT_SUPPORTED.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that takes a parameter with no name
+   */
+  @Test
+  public void testFunctionImportParamNoName() {
+    VARIANT = 13;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_PARAM_NAME_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import test for facets
+   */
+  @Test
+  public void testFunctionImportParamFacets() {
+    VARIANT = 14;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    List<FunctionImportParameter> funcImpParamList = functionImportList.get(0).getParameters();
+    EdmFacets facets = funcImpParamList.get(0).getFacets();
+    assertNotNull(facets);
+    assertEquals(2, facets.getMaxLength().intValue());
+    assertEquals(true, facets.isNullable());
+
+    facets = funcImpParamList.get(1).getFacets();
+    assertNotNull(facets);
+    assertEquals(false, facets.isNullable());
+    assertEquals(10, facets.getPrecision().intValue());
+    assertEquals(2, facets.getScale().intValue());
+
+  }
+
+  /**
+   * Test Case - Function Import test for default facets
+   */
+  @Test
+  public void testFunctionImportParamFacetsDefault() {
+    VARIANT = 15;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    List<FunctionImportParameter> funcImpParamList = functionImportList.get(0).getParameters();
+    EdmFacets facets = funcImpParamList.get(0).getFacets();
+    assertNotNull(facets);
+    assertNull(facets.getMaxLength());
+    assertEquals(false, facets.isNullable());
+    assertNull(facets.getPrecision());
+    assertNull(facets.getScale());
+
+  }
+
+  /**
+   * Test Case - Function Import test for ReturnType.SCALAR but method returns
+   * void
+   */
+  @Test
+  public void testWrongReturnTypeScalar() {
+    VARIANT = 16;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import test for ReturnType.COMPLEX but method returns
+   * void
+   */
+  @Test
+  public void testWrongReturnTypeComplex() {
+    VARIANT = 17;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  @Test
+  public void testNoFunctionImport() {
+    VARIANT = 99;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmFunctionImport jpaEdmfunctionImport = new JPAEdmFunctionImport(this);
+
+    JPAEdmBuilder builder1 = jpaEdmfunctionImport.getBuilder();
+    JPAEdmBuilder builder2 = jpaEdmfunctionImport.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public HashMap<Class<?>, String[]> getRegisteredOperations() {
+
+    HashMap<Class<?>, String[]> customOperations = new HashMap<Class<?>, String[]>();
+
+    if (VARIANT == 0) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method1" });
+    } else if (VARIANT == 1) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "XYX" });
+    } else if (VARIANT == 2) {
+      customOperations.put(_JPACustomProcessorMock.class, null);
+    } else if (VARIANT == 3) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method3" });
+    } else if (VARIANT == 4) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method4" });
+    } else if (VARIANT == 5) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method5" });
+    } else if (VARIANT == 6) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method6" });
+    } else if (VARIANT == 7) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method7" });
+    } else if (VARIANT == 8) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method8" });
+    } else if (VARIANT == 9) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method9" });
+    } else if (VARIANT == 10) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method10" });
+    } else if (VARIANT == 11) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method11" });
+    } else if (VARIANT == 12) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method12" });
+    } else if (VARIANT == 13) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method13" });
+    } else if (VARIANT == 14) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method1" });
+    } else if (VARIANT == 15) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method3" });
+    } else if (VARIANT == 16) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method16" });
+    } else if (VARIANT == 17) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method17" });
+    } else {
+      return null;
+    }
+
+    return customOperations;
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+    return this;
+  }
+
+  @Override
+  public EntityType searchEdmEntityType(final String arg0) {
+    if (arg0.equals(_JPACustomProcessorMock.class.getSimpleName())) {
+      return new EntityType().setName(_JPACustomProcessorMock.edmName);
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final String arg0) {
+    if (arg0.equals(_JPACustomProcessorMock.class.getName())) {
+      return new ComplexType().setName(_JPACustomProcessorMock.edmName);
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public String getpUnitName() {
+    return ODataJPAContextMock.PERSISTENCE_UNIT_NAME;
+  }
+
+  private void build() {
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml b/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
new file mode 100644
index 0000000..d81cae9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<JPAEDMMappingModel
+	xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
+	<PersistenceUnit name="salesorderprocessing">
+		<EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
+		<JPAEntityTypes>
+			<JPAEntityType name="SalesOrderHeader">
+				<EDMEntityType>SalesOrder</EDMEntityType>
+				<EDMEntitySet>SalesOrders</EDMEntitySet>
+				<JPAAttributes>
+					<JPAAttribute name="soId"></JPAAttribute>
+					<JPAAttribute name="netAmount">NetAmount</JPAAttribute>
+					<JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
+				</JPAAttributes>
+				<JPARelationships>
+					<JPARelationship name="salesOrderItems">SalesOrderItemDetails</JPARelationship>
+					<JPARelationship name="notes">NoteDetails</JPARelationship>
+				</JPARelationships>
+			</JPAEntityType>
+			<JPAEntityType name="SalesOrderItem">
+				<EDMEntityType>SalesOrderItem</EDMEntityType>
+				<EDMEntitySet>SalesOrderItems</EDMEntitySet>
+				<JPAAttributes>
+					<JPAAttribute name="liId">ID</JPAAttribute>
+					<JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+				</JPAAttributes>
+				<JPARelationships>
+					<JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
+					<JPARelationship name="materials">MaterialDetails
+					</JPARelationship>
+				</JPARelationships>
+			</JPAEntityType>
+		</JPAEntityTypes>
+		<JPAEmbeddableTypes>
+			<JPAEmbeddableType name="SalesOrderItemKey">
+				<EDMComplexType>SalesOrderLineItemKey</EDMComplexType>
+					<JPAAttributes>
+						<JPAAttribute name="liId">ID</JPAAttribute>
+						<JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+					</JPAAttributes>
+			</JPAEmbeddableType>
+		</JPAEmbeddableTypes>
+	</PersistenceUnit>
+</JPAEDMMappingModel>

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/.gitignore b/odata2-jpa-processor/jpa-ref/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file