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:23 UTC

[25/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/jpql/JPQLSelectContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
new file mode 100644
index 0000000..817d8d3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+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.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
+import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
+import org.apache.olingo.odata2.api.uri.expression.SortOrder;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLSelectContextImplTest {
+
+  private static String entityTypeName = "MockEntity";
+  private static String[] fields = { "Field1", "Field2" };
+  private static List<KeyPredicate> keyPredicates;
+  private static SortOrder[] orderType = { SortOrder.asc, SortOrder.desc };
+
+  private static JPQLSelectContextBuilder builder;
+  private static JPQLSelectContext selectContext;
+
+  @BeforeClass
+  public static void setup() {
+
+  }
+
+  private void buildSelectContext(final boolean orderByIsNull, final boolean selectFieldsIsNull,
+      final boolean filterIsNull, final boolean isTopNull, final boolean isSkipNull) {
+    builder = null;
+    selectContext = null;
+    keyPredicates = new ArrayList<KeyPredicate>();
+    GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+    EdmType edmType1 = EasyMock.createMock(EdmType.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+    try {
+      EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
+      EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
+      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);
+
+    } catch (EdmException e2) {
+      fail("this should not happen");
+    }
+    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+    EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
+    keyPredicates.add(keyPredicate);
+    int i = 0;
+    List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
+    do {
+
+      EdmType edmType = EasyMock.createMock(EdmType.class);
+      try {
+        EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
+        EasyMock.replay(edmType);
+      } catch (EdmException e2) {
+        fail("Exception not Expected");
+      }
+
+      PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
+      EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);
+
+      EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+      EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+      EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+      try {
+        EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+      } catch (EdmException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+      EasyMock.expect(commonExpression.getEdmProperty()).andStubReturn(edmTyped);
+      OrderExpression order = EasyMock.createMock(OrderExpression.class);
+      EasyMock.expect(order.getExpression()).andStubReturn(commonExpression);
+      EasyMock.expect(order.getSortOrder()).andStubReturn(orderType[i]);
+      EasyMock.replay(edmMapping, edmTyped, commonExpression);
+      EasyMock.replay(order);
+
+      orderList.add(order);
+
+    } while (++i < 2);
+
+    OrderByExpression orderBy = EasyMock.createMock(OrderByExpression.class);
+    EasyMock.expect(orderBy.getOrders()).andStubReturn(orderList);
+    EasyMock.replay(orderBy);
+
+    try {
+      i = 0;
+      List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
+      do {
+        EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+        EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+        EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+        EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+        EasyMock.replay(edmMapping, edmProperty);
+
+        SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+        EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
+        EasyMock.replay(selectItem);
+
+        selectItemList.add(selectItem);
+
+      } while (++i < 2);
+      EasyMock.expect(entityType.getMapping()).andStubReturn(null);
+      EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
+      EasyMock.expect(entityType.getKeyProperties()).andStubReturn(getLocalKeyProperties());
+
+      EasyMock.replay(entityType);
+      EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
+      EasyMock.replay(entitySet);
+
+      EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+      if (orderByIsNull) {
+        EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
+      } else {
+        EasyMock.expect(resultsView.getOrderBy()).andStubReturn(orderBy);
+      }
+      if (selectFieldsIsNull) {
+        EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+      } else {
+        EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
+      }
+      // FilterExpression filterExpression =
+      // EasyMock.createMock(FilterExpression.class);
+      // EasyMock.expect(filterExpression.g)
+      if (filterIsNull) {
+        EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+      } else {
+        EasyMock.expect(resultsView.getFilter()).andStubReturn(
+            getFilterExpressionMockedObj(ExpressionKind.PROPERTY, "SalesOrder"));
+      }
+      if (isTopNull) {
+        EasyMock.expect(resultsView.getTop()).andStubReturn(null);
+      } else {
+        EasyMock.expect(resultsView.getTop()).andStubReturn(10);
+      }
+      if (isSkipNull) {
+        EasyMock.expect(resultsView.getSkip()).andStubReturn(null);
+      } else {
+        EasyMock.expect(resultsView.getSkip()).andStubReturn(0);
+      }
+      EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(keyPredicates);
+      EasyMock.replay(resultsView);
+
+    } catch (EdmException e1) {
+      fail("Exception not Expected");
+    }
+    try {
+      builder = (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
+
+      selectContext = (JPQLSelectContext) builder.build();
+    } catch (ODataJPAModelException e) {
+      fail("Exception not Expected");
+    } catch (ODataJPARuntimeException e) {
+      fail("Runtime Exception thrown");
+    }
+  }
+
+  private List<EdmProperty> getLocalKeyProperties() {
+    List<EdmProperty> propertyList = new ArrayList<EdmProperty>();
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+    try {
+      EasyMock.expect(edmProperty.getName()).andStubReturn("Field1");
+      EasyMock.expect(edmProperty.getMapping()).andStubReturn(null);
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(edmProperty);
+    propertyList.add(edmProperty);
+    return propertyList;
+  }
+
+  @Test
+  public void testEntityNameThrowingException() {
+    // buildSelectContext(false, false, false);
+    GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+    try {
+      EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
+      EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
+    } catch (EdmException e1) {
+      // throw new ODataException();
+    }
+
+    EasyMock.replay(entityType);
+    EasyMock.replay(entitySet);
+
+    EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+    EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
+    EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+    EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+    EasyMock.replay(resultsView);
+    try {
+      JPQLSelectContextBuilder builder1 =
+          (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
+
+      builder1.build();
+      fail("Should not come here");
+    } catch (ODataJPAModelException e) {
+      fail();
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+  @Test
+  public void testSelectFieldsAsNull() {
+    buildSelectContext(false, true, true, true, true);
+
+    try {
+      selectContext = (JPQLSelectContext) builder.build();
+      assertEquals("E2", selectContext.getSelectExpression());
+    } catch (ODataJPAModelException e) {
+      fail();
+    } catch (ODataJPARuntimeException e) {
+      fail();
+    }
+  }
+
+  @Test
+  public void testGetOrderByCollection() {
+    buildSelectContext(false, false, true, true, true);
+    assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+    assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+    assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+    assertEquals("DESC", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[1]));
+  }
+
+  @Test
+  public void testGetWhereExpression() {
+    buildSelectContext(false, false, true, true, true);
+    // fail("Not yet implemented");
+  }
+
+  @Test
+  public void testGetJPAEntityName() {
+    buildSelectContext(false, false, true, true, true);
+    assertEquals(JPQLSelectContextImplTest.entityTypeName, selectContext.getJPAEntityName());
+  }
+
+  @Test
+  public void testGetType() {
+    buildSelectContext(false, false, true, true, true);
+    assertEquals(JPQLContextType.SELECT, selectContext.getType());
+  }
+
+  @Test
+  public void testCreateBuilder() {
+    buildSelectContext(false, false, true, true, true);
+    assertEquals(JPQLSelectContextBuilder.class.toString(), builder.getClass().toString());
+  }
+
+  @Test
+  public void testEntitySetAsNull() {
+    buildSelectContext(false, false, true, true, true);
+    try {
+      JPQLSelectContextBuilder builder =
+          (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, null);
+
+      JPQLSelectContext selectContext1 = (JPQLSelectContext) builder.build();
+      assertNull(selectContext1.getJPAEntityAlias());
+      assertNull(selectContext1.getJPAEntityName());
+      assertNull(selectContext1.getOrderByCollection());
+      assertNull(selectContext1.getSelectExpression());
+      assertNull(selectContext1.getType());
+      assertNull(selectContext1.getWhereExpression());
+    } catch (ODataJPAModelException e) {
+      fail("Exception not Expected");
+    } catch (ODataJPARuntimeException e) {
+      fail("Runtime Exception thrown");
+    }
+  }
+
+  @Test
+  public void testOrderingWithSkip() {
+    buildSelectContext(true, false, true, true, false);
+    assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+    assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+    assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+
+  }
+
+  @Test
+  public void testOrderingWithTop() {
+    buildSelectContext(true, false, true, false, true);
+    assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+    assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+    assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+
+  }
+
+  @Test
+  public void testOrderByTopSkipAsNull() {
+    buildSelectContext(true, true, true, true, true);
+    assertNull(selectContext.getOrderByCollection());
+  }
+
+  @Test
+  public void testFilter() {
+    buildSelectContext(true, false, false, false, false);
+    assertEquals("E1.field", selectContext.whereCondition);
+
+  }
+
+  private FilterExpression getFilterExpressionMockedObj(final ExpressionKind leftOperandExpKind,
+      final String propertyName) throws EdmException {
+    FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
+    EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
+    EasyMock.expect(filterExpression.getExpression()).andStubReturn(
+        getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
+    EasyMock.replay(filterExpression);
+    return filterExpression;
+  }
+
+  private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
+    PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
+    EasyMock.expect(leftOperandPropertyExpresion.getKind()).andReturn(ExpressionKind.PROPERTY);
+    EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andReturn(propertyName);
+    EdmProperty edmtTyped = EasyMock.createMock(EdmProperty.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("field");
+    try {
+      EasyMock.expect(edmtTyped.getMapping()).andStubReturn(mapping);
+    } catch (EdmException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andReturn(edmtTyped);
+    EasyMock.replay(mapping, edmtTyped, leftOperandPropertyExpresion);
+    return leftOperandPropertyExpresion;
+  }
+
+}

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/jpql/JPQLSelectSingleContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
new file mode 100644
index 0000000..841ff5a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.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.jpql;
+
+import static org.junit.Assert.assertEquals;
+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.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPQLSelectSingleContextImplTest {
+
+  private static String entityTypeName = "MockEntity";
+  private static String[] fields = { "Field1", "Field2" };
+  private static List<KeyPredicate> keyPredicates;
+
+  private static JPQLSelectSingleContextBuilder builder;
+  private static JPQLSelectSingleContext selectContext;
+
+  private void buildContextBuilder(final boolean isSelectNull) {
+    builder = null;
+    selectContext = null;
+    keyPredicates = new ArrayList<KeyPredicate>();
+    GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
+
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+    EdmType edmType = EasyMock.createMock(EdmType.class);
+    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+    try {
+      EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
+      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
+
+    } catch (EdmException e2) {
+      fail("this should not happen");
+    }
+    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+    EasyMock.replay(edmType, kpProperty, keyPredicate);
+    keyPredicates.add(keyPredicate);
+    int i = 0;
+    try {
+
+      List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
+      do {
+        EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+        EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+        EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+        EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+        EasyMock.replay(edmMapping, edmProperty);
+
+        SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+        EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
+        EasyMock.replay(selectItem);
+
+        selectItemList.add(selectItem);
+
+      } while (++i < 2);
+
+      EasyMock.expect(entityType.getMapping()).andStubReturn(null);
+      EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
+      EasyMock.replay(entityType);
+      EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
+      EasyMock.replay(entitySet);
+
+      EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+      if (isSelectNull) {
+        selectItemList = null;
+      }
+      EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
+      ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
+      arrayList.add(keyPredicate);
+      EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(arrayList);
+      EasyMock.replay(resultsView);
+
+    } catch (EdmException e1) {
+      fail("Exception not Expected");
+    }
+    try {
+      builder = (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
+
+      selectContext = (JPQLSelectSingleContext) builder.build();
+    } catch (ODataJPAModelException e) {
+      fail("Exception not Expected");
+    } catch (ODataJPARuntimeException e) {
+      fail("Runtime Exception thrown");
+    }
+  }
+
+  @Test
+  public void testEntityNameThrowingException() {
+    // buildSelectContext(false, false, false);
+    GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
+
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+    try {
+      EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
+      EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
+    } catch (EdmException e1) {
+      // throw new ODataException();
+    }
+
+    EasyMock.replay(entityType);
+    EasyMock.replay(entitySet);
+
+    EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+    EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+    EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+    EasyMock.replay(resultsView);
+    try {
+      JPQLSelectSingleContextBuilder builder1 =
+          (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
+      builder1.build();
+      fail("Should not come here");
+    } catch (ODataJPAModelException e) {
+      fail();
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+  @Test
+  public void testSlectedFieldsAsNull() {
+    buildContextBuilder(true);
+    try {
+      selectContext = (JPQLSelectSingleContext) builder.build();
+      assertEquals("E2", selectContext.getSelectExpression());
+    } catch (ODataJPAModelException e) {
+      fail();
+    } catch (ODataJPARuntimeException e) {
+      fail();
+    }
+  }
+
+  @Test
+  public void getKeyPredicates() {
+    buildContextBuilder(false);
+    assertEquals(keyPredicates.size(), selectContext.getKeyPredicates().size());
+    assertEquals(keyPredicates, selectContext.getKeyPredicates());
+  }
+
+  @Test
+  public void testGetJPAEntityName() {
+    buildContextBuilder(false);
+    assertEquals(JPQLSelectSingleContextImplTest.entityTypeName, selectContext.getJPAEntityName());
+  }
+
+  @Test
+  public void testGetType() {
+    buildContextBuilder(false);
+    assertEquals(JPQLContextType.SELECT_SINGLE, selectContext.getType());
+  }
+
+  @Test
+  public void testCreateBuilder() {
+    buildContextBuilder(false);
+    assertEquals(JPQLSelectSingleContextBuilder.class.toString(), builder.getClass().toString());
+  }
+
+}

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/jpql/JPQLSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
new file mode 100644
index 0000000..c5d5f95
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPQLSelectSingleStatementBuilderTest {
+
+  /**
+   * @throws java.lang.Exception
+   */
+  private JPQLSelectSingleStatementBuilder JPQLSelectSingleStatementBuilder;
+
+  @Before
+  public void setUp() throws Exception {
+
+  }
+
+  private JPQLSelectSingleContext createSelectContext() throws ODataJPARuntimeException, EdmException {
+    // Object Instantiation
+
+    JPQLSelectSingleContext JPQLSelectSingleContextImpl = null;// new JPQLSelectSingleContextImpl();
+    GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
+
+    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+    List<SelectItem> selectItemList = null;
+
+    // Setting up the expected value
+    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+    EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
+    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+    try {
+      EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
+      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
+
+      EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
+
+    } catch (EdmException e2) {
+      fail("this should not happen");
+    }
+    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+    EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
+    EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+    EasyMock.expect(getEntityView.getSelect()).andStubReturn(selectItemList);
+
+    EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+    EasyMock.replay(edmEntitySet);
+    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+    EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
+    EasyMock.replay(edmEntityType);
+    ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
+    arrayList.add(keyPredicate);
+    EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(arrayList);
+    EasyMock.replay(getEntityView);
+
+    JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView);
+    try {
+      JPQLSelectSingleContextImpl = (JPQLSelectSingleContext) contextBuilder1.build();
+    } catch (ODataJPAModelException e) {
+      fail("Model Exception thrown");
+    }
+
+    return JPQLSelectSingleContextImpl;
+  }
+
+  /**
+   * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
+   * @throws EdmException
+   * @throws ODataJPARuntimeException
+   */
+
+  @Test
+  public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
+    JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext();
+    JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);
+
+    assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 = 1", JPQLSelectSingleStatementBuilder.build()
+        .toString());
+  }
+
+}

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/jpql/JPQLSelectStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
new file mode 100644
index 0000000..2434809
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPQLSelectStatementBuilderTest {
+
+  /**
+   * @throws java.lang.Exception
+   */
+  private JPQLSelectStatementBuilder jpqlSelectStatementBuilder;
+
+  @Before
+  public void setUp() throws Exception {
+
+  }
+
+  private JPQLSelectContext createSelectContext(final OrderByExpression orderByExpression,
+      final FilterExpression filterExpression) throws ODataJPARuntimeException, EdmException {
+    // Object Instantiation
+
+    JPQLSelectContext jpqlSelectContextImpl = null;
+    GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+    List<SelectItem> selectItemList = null;
+
+    // Setting up the expected value
+
+    EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+    EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
+    EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(selectItemList);
+    EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(filterExpression);
+    EasyMock.replay(getEntitySetView);
+    EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+    EasyMock.replay(edmEntitySet);
+    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+    EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
+    EasyMock.replay(edmEntityType);
+
+    JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView);
+    try {
+      jpqlSelectContextImpl = (JPQLSelectContext) contextBuilder1.build();
+    } catch (ODataJPAModelException e) {
+      fail("Model Exception thrown");
+    }
+
+    return jpqlSelectContextImpl;
+  }
+
+  /**
+   * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectStatementBuilder#build)}.
+   * @throws EdmException
+   * @throws ODataJPARuntimeException
+   */
+
+  @Test
+  public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
+    OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+    JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
+    jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+    assertEquals("SELECT E1 FROM SalesOrderHeader E1", jpqlSelectStatementBuilder.build().toString());
+  }
+
+  @Test
+  public void testBuildQueryWithOrderBy() throws EdmException, ODataJPARuntimeException {
+    OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+
+    JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
+    HashMap<String, String> orderByCollection = new HashMap<String, String>();
+    orderByCollection.put("E1.soID", "ASC");
+    orderByCollection.put("E1.buyerId", "DESC");
+    jpqlSelectContextImpl.setOrderByCollection(orderByCollection);
+    jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+    assertEquals("SELECT E1 FROM SalesOrderHeader E1 ORDER BY E1.soID ASC , E1.buyerId DESC",
+        jpqlSelectStatementBuilder.build().toString());
+  }
+
+  @Test
+  public void testBuildQueryWithFilter() throws EdmException, ODataJPARuntimeException {
+    OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+    FilterExpression filterExpression = null;// getFilterExpressionMockedObj();
+    JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, filterExpression);
+    jpqlSelectContextImpl.setWhereExpression("E1.soID >= 1234");
+
+    jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+    assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.soID >= 1234", jpqlSelectStatementBuilder.build()
+        .toString());
+  }
+
+}

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/mock/ODataJPAContextMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
new file mode 100644
index 0000000..7fc3a6d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.mock;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.easymock.EasyMock;
+
+public abstract class ODataJPAContextMock {
+
+  public static final String NAMESPACE = "salesorderprocessing";
+  public static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel";
+  public static final String PERSISTENCE_UNIT_NAME = "salesorderprocessing";
+
+  public static ODataJPAContext mockODataJPAContext() {
+    ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+    EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn(NAMESPACE);
+    EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andReturn(mockEntityManagerFactory());
+    EasyMock.expect(odataJPAContext.getJPAEdmMappingModel()).andReturn(MAPPING_MODEL);
+    EasyMock.expect(odataJPAContext.getJPAEdmExtension()).andReturn(null);
+    EasyMock.expect(odataJPAContext.getDefaultNaming()).andReturn(true);
+    EasyMock.replay(odataJPAContext);
+    return odataJPAContext;
+  }
+
+  private static EntityManagerFactory mockEntityManagerFactory() {
+    EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+    EasyMock.expect(emf.getMetamodel()).andReturn(mockMetaModel());
+    EasyMock.replay(emf);
+    return emf;
+  }
+
+  private static Metamodel mockMetaModel() {
+    Metamodel metaModel = EasyMock.createMock(Metamodel.class);
+    EasyMock.replay(metaModel);
+    return metaModel;
+  }
+
+}

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/mock/data/EdmMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
new file mode 100644
index 0000000..57866e3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * 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.mock.data;
+
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.easymock.EasyMock;
+
+public class EdmMockUtil {
+
+  public static ExpandSelectTreeNode mockExpandSelectTreeNode() {
+    ExpandSelectTreeNode nextExpandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+    Map<String, ExpandSelectTreeNode> nextLink = null;
+    EasyMock.expect(nextExpandNode.getLinks()).andStubReturn(nextLink);
+    EasyMock.replay(nextExpandNode);
+    ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+    Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
+    links.put("SalesOrderLineItemDetails", nextExpandNode);
+    EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
+    EasyMock.replay(expandNode);
+    return expandNode;
+  }
+
+  public static ExpandSelectTreeNode mockCurrentExpandSelectTreeNode() {
+    ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+    Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
+    EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
+    EasyMock.replay(expandNode);
+    return expandNode;
+  }
+
+  public static List<ArrayList<NavigationPropertySegment>> getExpandList() {
+    List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+    ArrayList<NavigationPropertySegment> expands = new ArrayList<NavigationPropertySegment>();
+    expands.add(mockNavigationPropertySegment());
+    expandList.add(expands);
+    return expandList;
+  }
+
+  public static WriteFeedCallbackContext getWriteFeedCallBackContext() {
+    URI selfLink = null;
+    WriteFeedCallbackContext writeContext = new WriteFeedCallbackContext();
+    try {
+      selfLink = new URI("SalesOrders(2L)/SalesOrderLineItemDetails");
+      writeContext.setSelfLink(selfLink);
+      writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
+      writeContext.setNavigationProperty(mockNavigationProperty());
+      writeContext.setSourceEntitySet(mockSourceEntitySet());
+      writeContext.setEntryData(getFeedData());
+
+    } catch (URISyntaxException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+
+    return writeContext;
+  }
+
+  public static WriteEntryCallbackContext getWriteEntryCallBackContext() {
+    WriteEntryCallbackContext writeContext = new WriteEntryCallbackContext();
+    writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
+    writeContext.setNavigationProperty(mockNavigationProperty());
+    writeContext.setSourceEntitySet(mockSourceEntitySet());
+    writeContext.setEntryData(getEntryData());
+    return writeContext;
+  }
+
+  private static EdmEntitySet mockSourceEntitySet() {
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    try {
+      EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockSourceEdmEntityType());
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entitySet);
+    return entitySet;
+  }
+
+  public static EdmEntityType mockSourceEdmEntityType() {
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    List<String> navigationPropertyNames = new ArrayList<String>();
+    List<String> propertyNames = new ArrayList<String>();
+    propertyNames.add("id");
+    propertyNames.add("description");
+    navigationPropertyNames.add("SalesOrderLineItemDetails");
+    try {
+      EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderHeader");
+      EasyMock.replay(mapping);
+      EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderHeader");
+      EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+      EasyMock.expect(entityType.getNavigationPropertyNames()).andStubReturn(navigationPropertyNames);
+      EasyMock.expect(entityType.getProperty("SalesOrderLineItemDetails")).andStubReturn(mockNavigationProperty());
+      EdmProperty property1 = mockEdmPropertyOfSource1();
+      EasyMock.expect(entityType.getProperty("id")).andStubReturn(property1);
+      EasyMock.expect(entityType.getProperty("description")).andStubReturn(mockEdmPropertyOfSource2());
+      EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entityType);
+    return entityType;
+  }
+
+  private static EdmTyped mockEdmPropertyOfSource2() {
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+    EdmType type = EasyMock.createMock(EdmType.class);
+    EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+    EasyMock.replay(type);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("description");
+    EasyMock.replay(mapping);
+    try {
+      EasyMock.expect(edmProperty.getName()).andStubReturn("description");
+      EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+      EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(edmProperty);
+    return edmProperty;
+  }
+
+  private static EdmProperty mockEdmPropertyOfSource1() {
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+    EdmType type = EasyMock.createMock(EdmType.class);
+    EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+    EasyMock.replay(type);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("id");
+    EasyMock.replay(mapping);
+    try {
+      EasyMock.expect(edmProperty.getName()).andStubReturn("id");
+      EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+      EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(edmProperty);
+    return edmProperty;
+  }
+
+  private static Map<String, Object> getFeedData() {
+    Map<String, Object> entryData = new HashMap<String, Object>();
+    entryData.put("id", 1);
+    entryData.put("description", "laptop");
+    List<SalesOrderLineItem> salesOrderLineItems = new ArrayList<SalesOrderLineItem>();
+    salesOrderLineItems.add(new SalesOrderLineItem(23));
+    salesOrderLineItems.add(new SalesOrderLineItem(45));
+    entryData.put("SalesOrderLineItemDetails", salesOrderLineItems);
+    return entryData;
+  }
+
+  private static Map<String, Object> getEntryData() {
+    Map<String, Object> entryData = new HashMap<String, Object>();
+    entryData.put("id", 1);
+    entryData.put("description", "laptop");
+    entryData.put("SalesOrderLineItemDetails", new SalesOrderLineItem(23));
+    return entryData;
+  }
+
+  private static NavigationPropertySegment mockNavigationPropertySegment() {
+    NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
+    EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockNavigationProperty());
+    EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockTargetEntitySet());
+    EasyMock.replay(navigationPropSegment);
+    return navigationPropSegment;
+  }
+
+  public static NavigationPropertySegment mockThirdNavigationPropertySegment() {
+    NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
+    EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockSecondNavigationProperty());
+    EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockThirdEntitySet());
+    EasyMock.replay(navigationPropSegment);
+    return navigationPropSegment;
+  }
+
+  public static EdmNavigationProperty mockSecondNavigationProperty() {
+    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("materials");
+    EasyMock.replay(mapping);
+    try {
+      EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
+      EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
+      EasyMock.expect(navigationProperty.getName()).andStubReturn("MaterialDetails");
+      EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderLineItem");
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(navigationProperty);
+    return navigationProperty;
+  }
+
+  public static EdmEntitySet mockTargetEntitySet() {
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    try {
+      EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockTargetEdmEntityType());
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entitySet);
+    return entitySet;
+  }
+
+  public static EdmEntitySet mockThirdEntitySet() {
+    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+    try {
+      EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockThirdEdmEntityType());
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entitySet);
+    return entitySet;
+
+  }
+
+  private static EdmEntityType mockThirdEdmEntityType() {
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+
+    List<String> propertyNames = new ArrayList<String>();
+    propertyNames.add("price");
+    try {
+      EasyMock.expect(mapping.getInternalName()).andStubReturn("Material");
+      EasyMock.replay(mapping);
+      EasyMock.expect(entityType.getName()).andStubReturn("Material");
+      EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+      EdmProperty property = mockEdmPropertyOfTarget();
+      EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
+      EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entityType);
+    return entityType;
+  }
+
+  public static EdmEntityType mockTargetEdmEntityType() {
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+
+    List<String> propertyNames = new ArrayList<String>();
+    propertyNames.add("price");
+    try {
+      EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderLineItem");
+      EasyMock.replay(mapping);
+      EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderLineItem");
+      EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+      EdmProperty property = mockEdmPropertyOfTarget();
+      EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
+      EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(entityType);
+    return entityType;
+  }
+
+  private static EdmProperty mockEdmPropertyOfTarget() {
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+
+    EdmType type = EasyMock.createMock(EdmType.class);
+    EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+    EasyMock.replay(type);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("price");
+    EasyMock.replay(mapping);
+    try {
+      EasyMock.expect(edmProperty.getName()).andStubReturn("price");
+      EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+      EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(edmProperty);
+    return edmProperty;
+  }
+
+  public static EdmNavigationProperty mockNavigationProperty() {
+    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(mapping.getInternalName()).andStubReturn("salesOrderLineItems");
+    EasyMock.replay(mapping);
+    try {
+      EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.MANY);
+      EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
+      EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderLineItemDetails");
+      EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderHeader");
+    } catch (EdmException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    EasyMock.replay(navigationProperty);
+    return navigationProperty;
+  }
+
+}

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/mock/data/EdmMockUtilV2.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
new file mode 100644
index 0000000..6611fb1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * 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.mock.data;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+import org.apache.olingo.odata2.api.edm.EdmComplexType;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+import org.easymock.EasyMock;
+
+public class EdmMockUtilV2 {
+
+  public static interface JPAEdmMappingMock extends JPAEdmMapping, EdmMapping {
+
+  }
+
+  public static EdmEntityType mockEdmEntityType(final String entityName, final boolean withComplexType)
+      throws EdmException {
+
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    EasyMock.expect(entityType.getName()).andReturn(entityName).anyTimes();
+    EasyMock.expect(entityType.getKeyPropertyNames()).andReturn(mockSimpleKeyPropertyNames(entityName));
+    if (withComplexType == false) {
+      EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNames(entityName)).anyTimes();
+    } else {
+      EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNamesWithComplexType(entityName)).anyTimes();
+    }
+
+    EasyMock.expect(entityType.getNavigationPropertyNames()).andReturn(mockNavigationPropertyNames(entityName));
+    EasyMock.expect(entityType.getKind()).andReturn(EdmTypeKind.ENTITY);
+    EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, null, null));
+    if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+      EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MINT)).andReturn(
+          mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MINT)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MSTRING)).andReturn(
+          mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MSTRING)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MDATETIME)).andReturn(
+          mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MDATETIME)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).andReturn(
+          mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPATypeMock.NAVIGATION_PROPERTY_X)).andReturn(
+          mockEdmNavigationProperty(JPATypeMock.NAVIGATION_PROPERTY_X, EdmMultiplicity.ONE)).anyTimes();
+    } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+      EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MLONG)).andReturn(
+          mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MLONG)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).andReturn(
+          mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).andReturn(
+          mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).andReturn(
+          mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).anyTimes();
+    }
+    EasyMock.replay(entityType);
+    return entityType;
+  }
+
+  public static List<String> mockNavigationPropertyNames(final String entityName) {
+    List<String> propertyNames = new ArrayList<String>();
+    propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_X);
+    propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_XS);
+    return propertyNames;
+  }
+
+  public static List<String> mockSimpleKeyPropertyNames(final String entityName) {
+    List<String> keyPropertyNames = new ArrayList<String>();
+    if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+      keyPropertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
+    } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+      keyPropertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+    }
+
+    return keyPropertyNames;
+  }
+
+  public static List<String> mockPropertyNames(final String entityName) {
+    List<String> propertyNames = new ArrayList<String>();
+
+    if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+      propertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
+      propertyNames.add(JPATypeMock.PROPERTY_NAME_MDATETIME);
+      propertyNames.add(JPATypeMock.PROPERTY_NAME_MSTRING);
+    } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+      propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+      propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
+      propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
+      propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
+    } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+      propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
+      propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
+    } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+      propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
+      propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
+    }
+
+    return propertyNames;
+  }
+
+  public static List<String> mockPropertyNamesWithComplexType(final String entityName) {
+    List<String> propertyNames = mockPropertyNames(entityName);
+    propertyNames.add(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
+
+    return propertyNames;
+
+  }
+
+  public static EdmAssociationEnd mockEdmAssociatioEnd(final String navigationPropertyName, final String role)
+      throws EdmException {
+    EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
+    EasyMock.expect(associationEnd.getMultiplicity()).andReturn(EdmMultiplicity.ONE);
+    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+    EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping("JPARelatedTypeMock", null, null));
+    EasyMock.replay(entityType);
+
+    EasyMock.expect(associationEnd.getEntityType()).andReturn(entityType);
+    EasyMock.replay(associationEnd);
+    return associationEnd;
+  }
+
+  public static EdmAssociation mockEdmAssociation(final String navigationPropertyName) throws EdmException {
+    EdmAssociation edmAssociation = EasyMock.createMock(EdmAssociation.class);
+    EasyMock.expect(edmAssociation.getEnd("TO")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "TO"));
+    EasyMock.expect(edmAssociation.getEnd("FROM")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "FROM"));
+    EasyMock.replay(edmAssociation);
+    return edmAssociation;
+  }
+
+  public static EdmEntitySet mockEdmEntitySet(final String entityName, final boolean withComplexType)
+      throws EdmException {
+    EdmEntitySet entitySet = null;
+    if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+      entitySet = EasyMock.createMock(EdmEntitySet.class);
+      EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
+      EasyMock.expect(entitySet.getRelatedEntitySet(EasyMock.isA(EdmNavigationProperty.class))).andReturn(
+          mockEdmEntitySet(JPARelatedTypeMock.ENTITY_NAME, false)).anyTimes();
+    } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+      entitySet = EasyMock.createMock(EdmEntitySet.class);
+      EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
+    }
+
+    EasyMock.replay(entitySet);
+    return entitySet;
+  }
+
+  public static EdmNavigationProperty mockEdmNavigationProperty(final String navigationPropertyName,
+      final EdmMultiplicity multiplicity) throws EdmException {
+
+    EdmEntityType edmEntityType = mockEdmEntityType(JPARelatedTypeMock.ENTITY_NAME, false);
+
+    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+    EasyMock.expect(navigationProperty.getType()).andReturn(edmEntityType).anyTimes();
+    EasyMock.expect(navigationProperty.getMultiplicity()).andReturn(multiplicity);
+    EasyMock.expect(navigationProperty.getMapping()).andReturn(
+        (EdmMapping) mockEdmMapping(null, null, navigationPropertyName)).anyTimes();
+    EasyMock.expect(navigationProperty.getToRole()).andReturn("TO");
+    EasyMock.expect(navigationProperty.getRelationship()).andReturn(mockEdmAssociation(navigationPropertyName));
+    if (multiplicity.equals(EdmMultiplicity.ONE)) {
+      EasyMock.expect(navigationProperty.getName()).andReturn(JPATypeMock.NAVIGATION_PROPERTY_X).anyTimes();
+    }
+
+    EasyMock.replay(navigationProperty);
+
+    return navigationProperty;
+  }
+
+  public static EdmProperty mockEdmProperty(final String entityName, final String propertyName) throws EdmException {
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+
+    if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT) ||
+        propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
+        propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME) ||
+        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT) ||
+        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT) ||
+        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID) ||
+        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG) ||
+        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE) ||
+        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE) ||
+        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
+
+      EdmType edmType = EasyMock.createMock(EdmType.class);
+      EasyMock.expect(edmProperty.getType()).andReturn(edmType).anyTimes();
+      EasyMock.expect(edmType.getKind()).andReturn(EdmTypeKind.SIMPLE).anyTimes();
+      EasyMock.replay(edmType);
+      EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
+      EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, propertyName, null))
+          .anyTimes();
+
+    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE) ||
+        propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+      EdmComplexType complexType = mockComplexType(propertyName);
+
+      EasyMock.expect(edmProperty.getType()).andReturn(complexType).anyTimes();
+      EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
+      EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(null, propertyName, null))
+          .anyTimes();
+
+    }
+
+    EasyMock.replay(edmProperty);
+    return edmProperty;
+  }
+
+  public static EdmComplexType mockComplexType(final String complexPropertyName) throws EdmException {
+
+    String complexTypeName = null;
+    if (complexPropertyName.equals(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
+      complexTypeName = JPATypeEmbeddableMock2.ENTITY_NAME;
+    } else if (complexPropertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+      complexTypeName = JPATypeEmbeddableMock.ENTITY_NAME;
+    }
+
+    EdmComplexType edmComplexType = EasyMock.createMock(EdmComplexType.class);
+    EasyMock.expect(edmComplexType.getKind()).andReturn(EdmTypeKind.COMPLEX);
+    EasyMock.expect(edmComplexType.getPropertyNames()).andReturn(mockPropertyNames(complexTypeName)).anyTimes();
+    EasyMock.expect(edmComplexType.getMapping()).andReturn((EdmMapping) mockEdmMapping(complexTypeName, null, null));
+
+    if (complexTypeName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+      EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).andReturn(
+          mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).anyTimes();
+      EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).andReturn(
+          mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).anyTimes();
+    } else if (complexTypeName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+      EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).andReturn(
+          mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).anyTimes();
+      EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).andReturn(
+          mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).anyTimes();
+    }
+
+    EasyMock.replay(edmComplexType);
+    return edmComplexType;
+  }
+
+  public static JPAEdmMapping mockEdmMapping(final String entityName, final String propertyName,
+      final String navigationPropertyName) {
+    JPAEdmMapping mapping = new JPAEdmMappingImpl();
+
+    if (propertyName == null && entityName != null) {
+      if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+        mapping.setJPAType(JPATypeMock.class);
+      } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+        mapping.setJPAType(JPARelatedTypeMock.class);
+      } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+        mapping.setJPAType(JPATypeEmbeddableMock.class);
+      } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+        mapping.setJPAType(JPATypeEmbeddableMock2.class);
+      }
+    } else if (entityName == null && navigationPropertyName != null) {
+      mapping.setJPAType(JPARelatedTypeMock.class);
+      mapping.setJPAColumnName(JPATypeMock.NAVIGATION_PROPERTY_X);
+    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT)) {
+      mapping.setJPAType(int.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MINT);
+    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING)) {
+      mapping.setJPAType(String.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MSTRING);
+    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME)) {
+      mapping.setJPAType(Calendar.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MDATETIME);
+    } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG)) {
+      mapping.setJPAType(long.class);
+      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+    } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)) {
+      mapping.setJPAType(double.class);
+      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
+    } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)) {
+      mapping.setJPAType(byte.class);
+      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
+    } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
+      mapping.setJPAType(byte[].class);
+      ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
+    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)) {
+      mapping.setJPAType(Short.TYPE);
+      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
+    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)) {
+      mapping.setJPAType(Float.TYPE);
+      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
+    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)) {
+      mapping.setJPAType(UUID.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
+    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
+      mapping.setJPAType(JPATypeEmbeddableMock2.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
+    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+      mapping.setJPAType(JPATypeEmbeddableMock.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
+    }
+    return mapping;
+  }
+
+}

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/mock/data/JPATypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
new file mode 100644
index 0000000..d7bb703
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * 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.mock.data;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+/* ========================================================================= */
+public class JPATypeMock {
+
+  public static final String ENTITY_NAME = "JPATypeMock";
+  public static final String PROPERTY_NAME_MINT = "mInt";
+  public static final String PROPERTY_NAME_MSTRING = "mString";
+  public static final String PROPERTY_NAME_MDATETIME = "mDateTime";
+  public static final String PROPERTY_NAME_MKEY = "key";
+  public static final String PROPERTY_NAME_MCOMPLEXTYPE = "complexType";
+
+  public static final String NAVIGATION_PROPERTY_X = "mRelatedEntity";
+  public static final String NAVIGATION_PROPERTY_XS = "mRelatedEntities";
+
+  private JPATypeEmbeddableMock key;
+  private JPATypeEmbeddableMock complexType;
+  private int mInt;
+  private String mString;
+  private Calendar mDateTime;
+  private JPARelatedTypeMock mRelatedEntity;
+  private List<JPARelatedTypeMock> mRelatedEntities = new ArrayList<JPATypeMock.JPARelatedTypeMock>();
+
+  public String getMString() {
+    return mString;
+  }
+
+  public void setMString(final String mString) {
+    this.mString = mString;
+  }
+
+  public JPATypeEmbeddableMock getKey() {
+    return key;
+  }
+
+  public void setKey(final JPATypeEmbeddableMock key) {
+    this.key = key;
+  }
+
+  public int getMInt() {
+    return mInt;
+  }
+
+  public void setMInt(final int mInt) {
+    this.mInt = mInt;
+  }
+
+  public Calendar getMDateTime() {
+    return mDateTime;
+  }
+
+  public void setMDateTime(final Calendar mDateTime) {
+    this.mDateTime = mDateTime;
+  }
+
+  public JPARelatedTypeMock getMRelatedEntity() {
+    return mRelatedEntity;
+  }
+
+  public void setMRelatedEntity(final JPARelatedTypeMock mRelatedEntity) {
+    this.mRelatedEntity = mRelatedEntity;
+  }
+
+  public List<JPARelatedTypeMock> getMRelatedEntities() {
+    return mRelatedEntities;
+  }
+
+  public void setMRelatedEntities(final List<JPARelatedTypeMock> mRelatedEntities) {
+    this.mRelatedEntities = mRelatedEntities;
+  }
+
+  public JPATypeEmbeddableMock getComplexType() {
+    return complexType;
+  }
+
+  public void setComplexType(final JPATypeEmbeddableMock complexType) {
+    this.complexType = complexType;
+  }
+
+  /* ========================================================================= */
+  public static class JPATypeEmbeddableMock {
+
+    public static final String ENTITY_NAME = "JPATypeEmbeddableMock";
+    public static final String PROPERTY_NAME_MSHORT = "mShort";
+    public static final String PROPERTY_NAME_MEMBEDDABLE = "mEmbeddable";
+
+    private short mShort;
+    private JPATypeEmbeddableMock2 mEmbeddable;
+
+    public short getMShort() {
+      return mShort;
+    }
+
+    public void setMShort(final short mShort) {
+      this.mShort = mShort;
+    }
+
+    public JPATypeEmbeddableMock2 getMEmbeddable() {
+      return mEmbeddable;
+    }
+
+    public void setMEmbeddable(final JPATypeEmbeddableMock2 mEmbeddable) {
+      this.mEmbeddable = mEmbeddable;
+    }
+
+  }
+
+  /* ========================================================================= */
+  public static class JPATypeEmbeddableMock2 {
+
+    public static final String ENTITY_NAME = "JPATypeEmbeddableMock2";
+    public static final String PROPERTY_NAME_MUUID = "mUUID";
+    public static final String PROPERTY_NAME_MFLOAT = "mFloat";
+
+    private UUID mUUID;
+    private float mFloat;
+
+    public UUID getMUUID() {
+      return mUUID;
+    }
+
+    public void setMUUID(final UUID mUUID) {
+      this.mUUID = mUUID;
+    }
+
+    public float getMFloat() {
+      return mFloat;
+    }
+
+    public void setMFloat(final float mFloat) {
+      this.mFloat = mFloat;
+    }
+
+  }
+
+  /* ========================================================================= */
+  public static final class JPARelatedTypeMock {
+    public static final String ENTITY_NAME = "JPARelatedTypeMock";
+    public static final String PROPERTY_NAME_MLONG = "mLong";
+    public static final String PROPERTY_NAME_MDOUBLE = "mDouble";
+    public static final String PROPERTY_NAME_MBYTE = "mByte";
+    public static final String PROPERTY_NAME_MBYTEARRAY = "mByteArray";
+
+    private long mLong;
+    private double mDouble;
+    private byte mByte;
+    private byte mByteArray[];
+
+    public long getMLong() {
+      return mLong;
+    }
+
+    public void setMLong(final long key) {
+      mLong = key;
+    }
+
+    public double getMDouble() {
+      return mDouble;
+    }
+
+    public void setMDouble(final double mDouble) {
+      this.mDouble = mDouble;
+    }
+
+    public byte getMByte() {
+      return mByte;
+    }
+
+    public void setMByte(final byte mByte) {
+      this.mByte = mByte;
+    }
+
+    public byte[] getMByteArray() {
+      return mByteArray;
+    }
+
+    public void setMByteArray(final byte mByteArray[]) {
+      this.mByteArray = mByteArray;
+    }
+
+  }
+}