You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by tb...@apache.org on 2013/12/19 16:31:40 UTC

[29/50] [abbrv] [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/JPAEdmAssociationSetTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
new file mode 100644
index 0000000..965d3d7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+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.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+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.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmAssociationSetTest extends JPAEdmTestModelView {
+
+  private JPAEdmAssociationSetTest objJPAEdmAssociationSetTest;
+  private JPAEdmAssociationSet objJPAEdmAssociationSet;
+
+  @Before
+  public void setUp() {
+    objJPAEdmAssociationSetTest = new JPAEdmAssociationSetTest();
+    objJPAEdmAssociationSet = new JPAEdmAssociationSet(objJPAEdmAssociationSetTest);
+    try {
+      objJPAEdmAssociationSet.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(objJPAEdmAssociationSet.getBuilder());
+  }
+
+  @Test
+  public void testGetConsistentEdmAssociationSetList() {
+    assertNotNull(objJPAEdmAssociationSet.getConsistentEdmAssociationSetList());
+  }
+
+  @Test
+  public void testGetEdmAssociationSet() {
+    assertNotNull(objJPAEdmAssociationSet.getEdmAssociationSet());
+  }
+
+  @Test
+  public void testGetEdmAssociation() {
+    assertNotNull(objJPAEdmAssociationSet.getEdmAssociation());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmAssociationSet.isConsistent());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmAssociationSet.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmAssociationSet.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmAssociationView getJPAEdmAssociationView() {
+    return this;
+  }
+
+  @Override
+  public AssociationSet getEdmAssociationSet() {
+    AssociationSet associationSet = new AssociationSet();
+    associationSet.setEnd1(new AssociationSetEnd());
+    associationSet.setEnd2(new AssociationSetEnd());
+
+    return associationSet;
+  }
+
+  @Override
+  public List<Association> getConsistentEdmAssociationList() {
+    return getEdmAssociationListLocal();
+  }
+
+  @Override
+  public List<AssociationSet> getConsistentEdmAssociationSetList() {
+
+    List<AssociationSet> associationSetList = new ArrayList<AssociationSet>();
+    associationSetList.add(getEdmAssociationSet());
+    associationSetList.add(getEdmAssociationSet());
+
+    return associationSetList;
+  }
+
+  @Override
+  public List<EntitySet> getConsistentEdmEntitySetList() {
+    return getEntitySetListLocal();
+  }
+
+  @Override
+  public boolean isConsistent() {
+    return true;
+  }
+
+  @Override
+  public Schema getEdmSchema() {
+    Schema schema = new Schema();
+    schema.setNamespace("salesordereprocessing");
+    return schema;
+  }
+
+  private List<EntitySet> getEntitySetListLocal() {
+    List<EntitySet> entitySetList = new ArrayList<EntitySet>();
+
+    EntitySet entitySet = new EntitySet();
+    entitySet.setName("SalesOrderHeader");
+    entitySet.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+    EntitySet entitySet2 = new EntitySet();
+    entitySet2.setName("SalesOrderItem");
+    entitySet2.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+    entitySetList.add(entitySet);
+    entitySetList.add(entitySet2);
+    return entitySetList;
+  }
+
+  private List<Association> getEdmAssociationListLocal() {
+    List<Association> associationList = new ArrayList<Association>();
+
+    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"));
+
+    associationList.add(association);
+    return associationList;
+  }
+
+}

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/JPAEdmAssociationTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
new file mode 100644
index 0000000..8c6d1f9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
@@ -0,0 +1,423 @@
+/*******************************************************************************
+
+ * 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.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+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.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+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.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmAssociationTest extends JPAEdmTestModelView {
+
+  private static JPAEdmAssociation objAssociation = null;
+  private static String ASSOCIATION_NAME = "SalesOrderHeader_String";
+  private static JPAEdmAssociationTest localView = null;
+  private static final String PUNIT_NAME = "salesorderprocessing";
+  private int variant;
+
+  @BeforeClass
+  public static void setup() {
+    localView = new JPAEdmAssociationTest();
+    objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+    try {
+      objAssociation.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 AssociationEnd getEdmAssociationEnd1() {
+    AssociationEnd associationEnd = new AssociationEnd();
+    associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
+    associationEnd.setRole("SalesOrderHeader");
+    associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+    return associationEnd;
+  }
+
+  @Override
+  public AssociationEnd getEdmAssociationEnd2() {
+    AssociationEnd associationEnd = new AssociationEnd();
+    associationEnd.setType(new FullQualifiedName("salesorderprocessing", "String"));
+    associationEnd.setRole("String");
+    associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+    return associationEnd;
+  }
+
+  @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 boolean isExists() {
+    return true;
+  }
+
+  @Override
+  public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+    JPAEdmReferentialConstraint refConstraintView = new JPAEdmReferentialConstraint(localView, localView, localView);
+    return refConstraintView;
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return getJPAAttributeLocal();
+  }
+
+  @Override
+  public String getpUnitName() {
+    return PUNIT_NAME;
+  }
+
+  @Override
+  public EntityType getEdmEntityType() {
+    EntityType entityType = new EntityType();
+    entityType.setName(SimpleTypeA.NAME);
+    return entityType;
+  }
+
+  // The inner class which gives us an replica of the jpa attribute
+  @SuppressWarnings("hiding")
+  private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<String> getJavaType() {
+      return (Class<String>) SimpleType.SimpleTypeA.clazz;
+    }
+
+    @Override
+    public PersistentAttributeType getPersistentAttributeType() {
+      if (variant == 1) {
+        return PersistentAttributeType.ONE_TO_MANY;
+      } else if (variant == 2) {
+        return PersistentAttributeType.ONE_TO_ONE;
+      } else if (variant == 2) {
+        return PersistentAttributeType.MANY_TO_ONE;
+      } else {
+        return PersistentAttributeType.MANY_TO_MANY;
+      }
+
+    }
+  }
+
+  private Attribute<?, ?> getJPAAttributeLocal() {
+    AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+    return attr;
+  }
+
+  @Test
+  public void testGetBuilder() {
+    assertNotNull(objAssociation.getBuilder());
+  }
+
+  @Test
+  public void testGetEdmAssociation() {
+    assertNotNull(objAssociation.getEdmAssociation());
+    assertEquals(objAssociation.getEdmAssociation().getName(), ASSOCIATION_NAME);
+  }
+
+  @Test
+  public void testGetConsistentEdmAssociationList() {
+    assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
+  }
+
+  @Override
+  public String getEdmRelationShipName() {
+    return "Association_SalesOrderHeader_String";
+  }
+
+  @Test
+  public void testSearchAssociation1() {
+    class TestAssociationEndView extends JPAEdmTestModelView {
+      @Override
+      public String getEdmRelationShipName() {
+        return "SalesOrderHeader_String1";
+      }
+
+      private Attribute<?, ?> getJPAAttributeLocal() {
+        AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+        return attr;
+      }
+
+      @Override
+      public Attribute<?, ?> getJPAAttribute() {
+        return getJPAAttributeLocal();
+      }
+
+      @Override
+      public String getJoinColumnName() {
+        return "SO_ID";
+      }
+
+      @Override
+      public String getJoinColumnReferenceColumnName() {
+        return "DEMO_ID";
+      }
+
+      @Override
+      public String getMappedByName() {
+        return "demo";
+      }
+
+      @Override
+      public String getOwningPropertyName() {
+        return "salesOrder";
+      }
+
+      @Override
+      public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
+        return 1;
+      }
+
+      @Override
+      public String getpUnitName() {
+        return "salesorderprocessing";
+      }
+
+      @Override
+      public EntityType getEdmEntityType() {
+        EntityType entityType = new EntityType();
+        entityType.setName("SalesOrderHeader");
+        return entityType;
+      }
+
+      @SuppressWarnings("hiding")
+      class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public Class<String> getJavaType() {
+          return (Class<String>) SimpleType.SimpleTypeA.clazz;
+        }
+
+        @Override
+        public PersistentAttributeType getPersistentAttributeType() {
+
+          return PersistentAttributeType.ONE_TO_MANY;
+
+        }
+
+        @Override
+        public Member getJavaMember() {
+          return new AnnotatedElementMock();
+        }
+
+        @Override
+        public java.lang.String getName() {
+          // TODO Auto-generated method stub
+          return super.getName();
+        }
+
+        class AnnotatedElementMock implements AnnotatedElement, Member {
+
+          @Override
+          public boolean isAnnotationPresent(final Class<? extends Annotation> annotationClass) {
+            return true;
+          }
+
+          @SuppressWarnings("unchecked")
+          @Override
+          public Annotation getAnnotation(@SuppressWarnings("rawtypes") final Class annotationClass) {
+            if (annotationClass.equals(JoinColumn.class)) {
+              JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+              EasyMock.expect(joinColumn.name()).andStubReturn("SO_ID");
+              EasyMock.expect(joinColumn.referencedColumnName()).andStubReturn("DEMO_ID");
+              EasyMock.replay(joinColumn);
+              return joinColumn;
+            } else {
+              OneToMany oneToMany = EasyMock.createMock(OneToMany.class);
+              EasyMock.expect(oneToMany.mappedBy()).andStubReturn("demo");
+              EasyMock.replay(oneToMany);
+              return oneToMany;
+            }
+          }
+
+          @Override
+          public Annotation[] getAnnotations() {
+            return null;
+          }
+
+          @Override
+          public Annotation[] getDeclaredAnnotations() {
+            return null;
+          }
+
+          @Override
+          public Class<?> getDeclaringClass() {
+            // TODO Auto-generated method stub
+            return null;
+          }
+
+          @Override
+          public java.lang.String getName() {
+            // TODO Auto-generated method stub
+            return null;
+          }
+
+          @Override
+          public int getModifiers() {
+            // TODO Auto-generated method stub
+            return 0;
+          }
+
+          @Override
+          public boolean isSynthetic() {
+            // TODO Auto-generated method stub
+            return false;
+          }
+
+        }
+
+      }
+    }
+    TestAssociationEndView objJPAEdmAssociationEndTest = new TestAssociationEndView();
+    JPAEdmAssociationEnd objJPAEdmAssociationEnd =
+        new JPAEdmAssociationEnd(objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
+    try {
+      objJPAEdmAssociationEnd.getBuilder().build();
+      Field field = objAssociation.getClass().getDeclaredField("associationEndMap");
+      field.setAccessible(true);
+      Map<String, JPAEdmAssociationEndView> associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
+      associationEndMap.put("SalesOrderHeader_String", objJPAEdmAssociationEnd);
+      field.set(objAssociation, associationEndMap);
+    } 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);
+    } catch (SecurityException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (NoSuchFieldException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (IllegalArgumentException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (IllegalAccessException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+
+    assertEquals("SalesOrderHeader_String", objAssociation.searchAssociation(objJPAEdmAssociationEnd).getName());
+
+  }
+
+  @Test
+  public void testAddJPAEdmAssociationView() {
+
+    class LocalJPAAssociationView extends JPAEdmTestModelView {
+      @Override
+      public AssociationEnd getEdmAssociationEnd1() {
+        AssociationEnd associationEnd = new AssociationEnd();
+        associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
+        associationEnd.setRole("SalesOrderHeader");
+        associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+        return associationEnd;
+      }
+
+      @Override
+      public AssociationEnd getEdmAssociationEnd2() {
+        AssociationEnd associationEnd = new AssociationEnd();
+        associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"));
+        associationEnd.setRole("SalesOrderItem");
+        associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+        return associationEnd;
+      }
+
+      @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", "SalesOrderItem")));
+
+        return association;
+      }
+    }
+    LocalJPAAssociationView assocViewObj = new LocalJPAAssociationView();
+    JPAEdmAssociation objLocalAssociation = new JPAEdmAssociation(assocViewObj, assocViewObj, assocViewObj, 1);
+    try {
+      objLocalAssociation.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);
+    }
+
+    objAssociation.addJPAEdmAssociationView(objLocalAssociation, localView);
+
+  }
+
+  @Test
+  public void testAddJPAEdmRefConstraintView() {
+
+    localView = new JPAEdmAssociationTest();
+    objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+    try {
+      objAssociation.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);
+    }
+
+    objAssociation.addJPAEdmRefConstraintView(localView);
+    assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
+  }
+
+  @Test
+  public void testGetJPAEdmReferentialConstraintView() {
+
+  }
+}

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/JPAEdmBaseViewImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
new file mode 100644
index 0000000..bdbf104
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+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 JPAEdmBaseViewImplTest extends JPAEdmTestModelView {
+
+  private JPAEdmBaseViewImplTest objJPAEdmBaseViewImplTest;
+  private JPAEdmBaseViewImpl objJPAEdmBaseViewImpl;
+
+  @Before
+  public void setUp() {
+    objJPAEdmBaseViewImplTest = new JPAEdmBaseViewImplTest();
+    objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(objJPAEdmBaseViewImplTest) {
+
+      @Override
+      public JPAEdmBuilder getBuilder() {
+        return null;
+      }
+    };
+
+    objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(getJPAMetaModel(), getpUnitName()) {
+
+      @Override
+      public JPAEdmBuilder getBuilder() {
+        return null;
+      }
+    };
+
+  }
+
+  @Test
+  public void testGetpUnitName() {
+    assertTrue(objJPAEdmBaseViewImpl.getpUnitName().equals("salesorderprocessing"));
+  }
+
+  @Test
+  public void testGetJPAMetaModel() {
+    assertNotNull(objJPAEdmBaseViewImpl.getJPAMetaModel());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmBaseViewImpl.isConsistent());
+  }
+
+  @Test
+  public void testClean() {
+    objJPAEdmBaseViewImpl.clean();
+    assertFalse(objJPAEdmBaseViewImpl.isConsistent());
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAMetaModelMock();
+  }
+
+}

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/JPAEdmComplexTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
new file mode 100644
index 0000000..2fabe8c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+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.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+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.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+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.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.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmComplexTypeTest extends JPAEdmTestModelView {
+
+  private static JPAEdmComplexType objComplexType = null;
+  private static JPAEdmComplexTypeTest localView = null;
+
+  @BeforeClass
+  public static void setup() {
+    localView = new JPAEdmComplexTypeTest();
+    objComplexType = new JPAEdmComplexType(localView);
+    try {
+      objComplexType.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);
+    }
+  }
+
+  @SuppressWarnings("rawtypes")
+  @Override
+  public EmbeddableType<?> getJPAEmbeddableType() {
+    @SuppressWarnings("hiding")
+    class JPAComplexAttribute<Long> extends JPAEmbeddableMock<Long> {
+
+      @SuppressWarnings("unchecked")
+      @Override
+      public Class<Long> getJavaType() {
+
+        return (Class<Long>) java.lang.Long.class;
+      }
+
+    }
+    return new JPAComplexAttribute();
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  @Test
+  public void testGetBuilder() {
+
+    assertNotNull(objComplexType.getBuilder());
+  }
+
+  @Test
+  public void testGetEdmComplexType() {
+    assertEquals(objComplexType.getEdmComplexType().getName(), "String");
+  }
+
+  @Test
+  public void testSearchComplexTypeString() {
+    assertNotNull(objComplexType.searchEdmComplexType("java.lang.String"));
+
+  }
+
+  @Test
+  public void testGetJPAEmbeddableType() {
+    assertTrue(objComplexType.getJPAEmbeddableType().getAttributes().size() > 0);
+
+  }
+
+  @Test
+  public void testGetConsistentEdmComplexTypes() {
+    assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 0);
+  }
+
+  @Test
+  public void testSearchComplexTypeFullQualifiedName() {
+    assertNotNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "String")));
+
+  }
+
+  @Test
+  public void testSearchComplexTypeFullQualifiedNameNegative() {
+    assertNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "lang.String")));
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objComplexType.getBuilder();
+    JPAEdmBuilder builder2 = objComplexType.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testAddCompleTypeView() {
+    localView = new JPAEdmComplexTypeTest();
+    objComplexType = new JPAEdmComplexType(localView);
+    try {
+      objComplexType.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);
+    }
+
+    objComplexType.addJPAEdmCompleTypeView(localView);
+    assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 1);
+  }
+
+  @Test
+  public void testExpandEdmComplexType() {
+    ComplexType complexType = new ComplexType();
+    List<Property> properties = new ArrayList<Property>();
+    JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
+    mapping1.setJPAColumnName("LINEITEMID");
+    ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
+    JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
+    mapping2.setJPAColumnName("LINEITEMNAME");
+    ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
+    properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
+    properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
+    complexType.setProperties(properties);
+    List<Property> expandedList = null;
+    try {
+      objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey");
+    } catch (ClassCastException e) {
+      assertTrue(false);
+    }
+    assertTrue(true);
+
+  }
+
+  @Test
+  public void testComplexTypeCreation() {
+    try {
+      objComplexType.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(objComplexType.pUnitName, "salesorderprocessing");
+  }
+
+  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/JPAEdmEntityContainerTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
new file mode 100644
index 0000000..4e9355b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * 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.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+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.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.JPAEntityTypeMock;
+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 JPAEdmEntityContainerTest extends JPAEdmTestModelView {
+
+  private JPAEdmEntityContainer objJPAEdmEntityContainer;
+  private JPAEdmEntityContainerTest objJPAEdmEntityContainerTest;
+
+  @Before
+  public void setUp() {
+    objJPAEdmEntityContainerTest = new JPAEdmEntityContainerTest();
+    objJPAEdmEntityContainer = new JPAEdmEntityContainer(objJPAEdmEntityContainerTest);
+    try {
+      objJPAEdmEntityContainer.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(objJPAEdmEntityContainer.getBuilder());
+  }
+
+  @Test
+  public void testGetEdmEntityContainer() {
+    assertNotNull(objJPAEdmEntityContainer.getEdmEntityContainer());
+    assertTrue(objJPAEdmEntityContainer.getEdmEntityContainer().getEntitySets().size() > 0);
+  }
+
+  @Test
+  public void testGetConsistentEdmEntityContainerList() {
+    assertNotNull(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList());
+    assertTrue(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList().size() > 0);
+
+  }
+
+  @Test
+  public void testGetJPAEdmEntitySetView() {
+    assertNotNull(objJPAEdmEntityContainer.getJPAEdmEntitySetView());
+    assertEquals("salesorderprocessing", objJPAEdmEntityContainer.getJPAEdmEntitySetView().getpUnitName());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmEntityContainer.isConsistent());
+    objJPAEdmEntityContainer.clean();
+    assertFalse(objJPAEdmEntityContainer.isConsistent());
+  }
+
+  @Test
+  public void testGetEdmAssociationSetView() {
+    assertNotNull(objJPAEdmEntityContainer.getEdmAssociationSetView());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmEntityContainer.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmEntityContainer.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  @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 Schema getEdmSchema() {
+    Schema schema = new Schema();
+    schema.setNamespace("salesordereprocessing");
+    return schema;
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @Override
+  public JPAEdmAssociationView getJPAEdmAssociationView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmBuilder getBuilder() {
+    return new JPAEdmBuilder() {
+
+      @Override
+      public void build() {
+        // Nothing to do?
+      }
+    };
+  }
+
+  private class JPAEdmMetaModel extends JPAMetaModelMock {
+    Set<EntityType<?>> entities;
+
+    public JPAEdmMetaModel() {
+      entities = new HashSet<EntityType<?>>();
+    }
+
+    @Override
+    public Set<EntityType<?>> getEntities() {
+      entities.add(new JPAEdmEntityType());
+      return entities;
+    }
+
+    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() {
+      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;
+    }
+
+    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 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/JPAEdmEntitySetTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
new file mode 100644
index 0000000..74c203e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+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.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.JPAEdmKeyView;
+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.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmEntitySetTest extends JPAEdmTestModelView {
+
+  private static JPAEdmEntitySet objJPAEdmEntitySet;
+  private static JPAEdmEntitySetTest objJPAEdmEntitySetTest;
+
+  @Before
+  public void setUp() {
+    objJPAEdmEntitySetTest = new JPAEdmEntitySetTest();
+    objJPAEdmEntitySet = new JPAEdmEntitySet(objJPAEdmEntitySetTest);
+    try {
+      objJPAEdmEntitySet.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(objJPAEdmEntitySet.getBuilder());
+  }
+
+  @Test
+  public void testGetEdmEntitySet() {
+    assertNotNull(objJPAEdmEntitySet.getEdmEntitySet());
+    assertNotNull(objJPAEdmEntitySet.getEdmEntitySet().getEntityType());
+  }
+
+  @Test
+  public void testGetConsistentEntitySetList() {
+    assertTrue(objJPAEdmEntitySet.getConsistentEdmEntitySetList().size() > 0);
+  }
+
+  @Test
+  public void testGetJPAEdmEntityTypeView() {
+    assertNotNull(objJPAEdmEntitySet.getJPAEdmEntityTypeView());
+    assertEquals("salesorderprocessing", objJPAEdmEntitySet.getJPAEdmEntityTypeView().getpUnitName());
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmEntitySet.isConsistent());
+
+    objJPAEdmEntitySet.getJPAEdmEntityTypeView().clean();
+    assertFalse(objJPAEdmEntitySet.getJPAEdmEntityTypeView().isConsistent());
+
+    objJPAEdmEntitySet.clean();
+    assertFalse(objJPAEdmEntitySet.isConsistent());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmEntitySet.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmEntitySet.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  @Override
+  public EntityType<?> getJPAEntityType() {
+    return new JPAEdmEntityType<String>();
+  }
+
+  @Override
+  public JPAEdmKeyView getJPAEdmKeyView() {
+    return this;
+  }
+
+  @Override
+  public Schema getEdmSchema() {
+    Schema schema = new Schema();
+    schema.setNamespace("salesordereprocessing");
+    return schema;
+  }
+
+  @Override
+  public String getpUnitName() {
+    return "salesorderprocessing";
+  }
+
+  @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() {
+      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 java.lang.String getName() {
+      return "SalesOrderHeader";
+    }
+
+    @Override
+    public Set<Attribute<? super String, ?>> getAttributes() {
+      setValuesToSet();
+      return attributeSet;
+    }
+
+    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 true;
+      }
+    }
+  }
+
+  private class JPAEdmMetaModel extends JPAMetaModelMock {
+    Set<EntityType<?>> entities;
+
+    public JPAEdmMetaModel() {
+      entities = new HashSet<EntityType<?>>();
+    }
+
+    @Override
+    public Set<EntityType<?>> getEntities() {
+      entities.add(new JPAEdmEntityType());
+      return entities;
+    }
+
+    private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+      @Override
+      public String getName() {
+        return "SalesOrderHeader";
+      }
+    }
+  }
+}

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/JPAEdmEntityTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
new file mode 100644
index 0000000..dfbe879
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+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.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.JPAEntityTypeMock;
+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 JPAEdmEntityTypeTest extends JPAEdmTestModelView {
+
+  private static JPAEdmEntityTypeTest objJPAEdmEntityTypeTest;
+  private static JPAEdmEntityType objJPAEdmEntityType;
+
+  @Before
+  public void setUp() {
+    objJPAEdmEntityTypeTest = new JPAEdmEntityTypeTest();
+    objJPAEdmEntityType = new JPAEdmEntityType(objJPAEdmEntityTypeTest);
+    try {
+      objJPAEdmEntityType.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(objJPAEdmEntityType.getBuilder());
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = objJPAEdmEntityType.getBuilder();
+    JPAEdmBuilder builder2 = objJPAEdmEntityType.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Test
+  public void testGetEdmEntityType() {
+    assertNotNull(objJPAEdmEntityType.getEdmEntityType());
+    assertNotNull(objJPAEdmEntityType.getEdmEntityType().getKey());
+  }
+
+  @Test
+  public void testGetJPAEntityType() {
+    assertNotNull(objJPAEdmEntityType.getJPAEntityType());
+
+  }
+
+  @Test
+  public void testGetConsistentEdmEntityTypes() {
+    assertTrue(objJPAEdmEntityType.getConsistentEdmEntityTypes().size() > 0);
+  }
+
+  @Test
+  public void testSearchEdmEntityType() {
+    assertNotNull(objJPAEdmEntityType.searchEdmEntityType("SalesOrderHeader"));
+  }
+
+  @Test
+  public void testIsConsistent() {
+    assertTrue(objJPAEdmEntityType.isConsistent());
+  }
+
+  @Override
+  public Metamodel getJPAMetaModel() {
+    return new JPAEdmMetaModel();
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public EntityType<?> getJPAEntityType() {
+    return new JPAEdmEntityTypeLocal<String>();
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  private class JPAEdmMetaModel extends JPAMetaModelMock {
+    Set<EntityType<?>> entities;
+
+    public JPAEdmMetaModel() {
+      entities = new HashSet<EntityType<?>>();
+    }
+
+    @Override
+    public Set<EntityType<?>> getEntities() {
+      entities.add(new JPAEdmEntityType());
+      return entities;
+    }
+
+    private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+      @Override
+      public String getName() {
+        return "SalesOrderHeader";
+      }
+    }
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAEdmEntityTypeLocal<String> extends JPAEntityTypeMock<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;
+    }
+
+    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 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/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..94665d7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
@@ -0,0 +1,566 @@
+/*******************************************************************************
+ * 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.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;
+
+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("Param3", funcImpList.get(1).getName());
+      assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
+
+    }
+
+  }
+
+  /**
+   * 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/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
new file mode 100644
index 0000000..0ec45df
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+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.Key;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+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.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
+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.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType.ComplexTypeA;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmKeyTest extends JPAEdmTestModelView {
+
+  private static JPAEdmKeyView keyView;
+  private static JPAEdmKeyTest objJpaEdmKeyTest;
+
+  @BeforeClass
+  public static void setup() {
+    objJpaEdmKeyTest = new JPAEdmKeyTest();
+    keyView = new JPAEdmKey(objJpaEdmKeyTest, objJpaEdmKeyTest);
+  }
+
+  @SuppressWarnings("hiding")
+  private class JPAAttributeA<Object, ComplexTypeA> extends JPAAttributeMock<Object, ComplexTypeA> {
+    @SuppressWarnings("unchecked")
+    @Override
+    public Class<ComplexTypeA> getJavaType() {
+      return (Class<ComplexTypeA>) JPAEdmMockData.ComplexType.ComplexTypeA.class;
+    }
+  }
+
+  @Test
+  public void testBuildComplexKey() {
+    try {
+      keyView.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);
+    }
+
+    Key key = keyView.getEdmKey();
+
+    assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A, key.getKeys().get(0).getName());
+    assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B, key.getKeys().get(1).getName());
+    assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D, key.getKeys().get(2).getName());
+    assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E, key.getKeys().get(3).getName());
+
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmBuilder builder1 = keyView.getBuilder();
+    JPAEdmBuilder builder2 = keyView.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public Attribute<?, ?> getJPAAttribute() {
+    return new JPAAttributeA<Object, ComplexTypeA>();
+
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
+    return searchEdmComplexType(arg0.getName());
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final String arg0) {
+    if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeA.class.getName())) {
+      return buildComplexTypeA();
+    } else if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeB.class.getSimpleName())) {
+      return buildComplexTypeB();
+    }
+
+    return null;
+
+  }
+
+  private ComplexType buildComplexTypeB() {
+    ComplexType complexType = new ComplexType();
+    complexType.setProperties(buildPropertiesB());
+
+    return complexType;
+  }
+
+  private List<Property> buildPropertiesB() {
+    List<Property> propertyList = new ArrayList<Property>();
+
+    SimpleProperty property = new SimpleProperty();
+    property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D);
+    property.setType(EdmSimpleTypeKind.Int16);
+
+    propertyList.add(property);
+
+    property = new SimpleProperty();
+    property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E);
+    property.setType(EdmSimpleTypeKind.Int16);
+
+    propertyList.add(property);
+
+    return propertyList;
+  }
+
+  private ComplexType buildComplexTypeA() {
+    ComplexType complexType = new ComplexType();
+    complexType.setProperties(buildPropertiesA());
+
+    return complexType;
+  }
+
+  private List<Property> buildPropertiesA() {
+
+    List<Property> propertyList = new ArrayList<Property>();
+
+    SimpleProperty property = new SimpleProperty();
+    property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A);
+    property.setType(EdmSimpleTypeKind.Int16);
+
+    propertyList.add(property);
+
+    property = new SimpleProperty();
+    property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B);
+    property.setType(EdmSimpleTypeKind.Int16);
+
+    propertyList.add(property);
+
+    ComplexProperty complexProperty = new ComplexProperty();
+    complexProperty.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_C);
+    complexProperty.setType(new FullQualifiedName(ODataJPAContextMock.NAMESPACE,
+        JPAEdmMockData.ComplexType.ComplexTypeB.name));
+
+    propertyList.add(complexProperty);
+    return propertyList;
+
+  }
+
+}