You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:43 UTC

[38/51] [partial] initial commit

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
new file mode 100644
index 0000000..eae1716
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *        or more contributor license agreements.  See the NOTICE file
+ *        distributed with this work for additional information
+ *        regarding copyright ownership.  The ASF licenses this file
+ *        to you under the Apache License, Version 2.0 (the
+ *        "License"); you may not use this file except in compliance
+ *        with the License.  You may obtain a copy of the License at
+ * 
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *        Unless required by applicable law or agreed to in writing,
+ *        software distributed under the License is distributed on an
+ *        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *        KIND, either express or implied.  See the License for the
+ *        specific language governing permissions and limitations
+ *        under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.jpql;
+
+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.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+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.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectSingleContext.JPQLJoinSelectSingleContextBuilder;
+
+public class JPQLJoinSelectSingleContextTest {
+
+  GetEntityUriInfo entityUriInfo;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {}
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {}
+
+  public void setUp(final boolean toThrowException) throws Exception {
+    entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+    List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+    final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
+    final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
+    final List<KeyPredicate> keyPredicates = createKeyPredicates(toThrowException);
+    NavigationSegment navigationSegment = new NavigationSegment() {
+
+      @Override
+      public EdmNavigationProperty getNavigationProperty() {
+        return navigationProperty;
+      }
+
+      @Override
+      public List<KeyPredicate> getKeyPredicates() {
+        return keyPredicates;
+      }
+
+      @Override
+      public EdmEntitySet getEntitySet() {
+        // TODO Auto-generated method stub
+        return null;
+      }
+    };
+    NavigationSegment navigationSegment1 = new NavigationSegment() {
+
+      @Override
+      public EdmNavigationProperty getNavigationProperty() {
+        return navigationProperty1;
+      }
+
+      @Override
+      public List<KeyPredicate> getKeyPredicates() {
+        return keyPredicates;
+      }
+
+      @Override
+      public EdmEntitySet getEntitySet() {
+        // TODO Auto-generated method stub
+        return null;
+      }
+    };
+    navigationSegments.add(navigationSegment);
+    navigationSegments.add(navigationSegment1);
+    EasyMock.expect(entityUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
+    EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(null);
+    EasyMock.expect(entityUriInfo.getFilter()).andStubReturn(null);
+    EasyMock.expect(entityUriInfo.getKeyPredicates()).andStubReturn(createKeyPredicates(toThrowException));
+    EasyMock.expect(entityUriInfo
+        .getTargetEntitySet()).andStubReturn(edmEntitySet);
+    EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+    EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+    EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
+    EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
+    EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
+    EasyMock.expect(entityUriInfo.getStartEntitySet()).andStubReturn(
+        startEdmEntitySet);
+    EasyMock.replay(startEdmEntityType, startEdmEntitySet);
+    EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+    EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
+    EasyMock.replay(edmEntityType, edmEntitySet, entityUriInfo);
+
+  }
+
+  @After
+  public void tearDown() throws Exception {}
+
+  @Test
+  public void testGetJPAOuterJoinClauses() throws Exception {
+    setUp(false);
+
+    JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
+    JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
+    try {
+      joinContextBuilder.entityView = entityUriInfo;
+      joinContextBuilder.build();
+    } catch (ODataJPAModelException e) {
+      fail("Should not come here");
+    } catch (ODataJPARuntimeException e) {
+      fail("Should not come here");
+    }
+    List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
+    assertNotNull(joinClauses);
+    assertTrue(joinClauses.size() > 0);
+    assertEquals("E1", joinClauses.get(0).getEntityAlias());
+    assertEquals("SOHeader", joinClauses.get(0).getEntityName());
+    assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
+    assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
+  }
+
+  @Test
+  public void testExceptionThrown() throws Exception {
+    setUp(true);
+    JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
+    JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
+    try {
+      joinContextBuilder.entityView = entityUriInfo;
+      joinContextBuilder.build();
+      fail("Should not come here");
+    } catch (ODataJPAModelException e) {
+      fail("Should not come here");
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+  private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
+    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+    EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
+    EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
+    EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
+    EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
+    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+    EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
+    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
+    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
+    EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
+    EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
+    EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
+    EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
+    EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
+    EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
+    EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
+    return navigationProperty;
+  }
+
+  private List<KeyPredicate> createKeyPredicates(final boolean toThrowException) throws EdmException {
+    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
+    EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+    EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
+    EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+    if (toThrowException) {
+      EasyMock.expect(edmProperty.getType()).andStubThrow(new EdmException(null));
+    } else {
+      EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+    }
+    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
+
+    EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
+    List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+    keyPredicates.add(keyPredicate);
+    return keyPredicates;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
new file mode 100644
index 0000000..91faa5d
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+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.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+
+public class JPQLJoinSelectSingleStatementBuilderTest {
+  JPQLJoinSelectSingleContextView context = null;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {}
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {}
+
+  public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
+    context = EasyMock.createMock(JPQLJoinSelectSingleContextView.class);
+    EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("gt1");
+    EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
+    EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
+    EasyMock.expect(context.getKeyPredicates()).andStubReturn(createKeyPredicates());
+    EasyMock.expect(context.getSelectExpression()).andStubReturn("gt1");
+    EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
+    EasyMock.replay(context);
+  }
+
+  private List<JPAJoinClause> getJoinClauseList() {
+    List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+    JPAJoinClause jpaOuterJoinClause = new JPAJoinClause("SOHeader", "soh", null, null, "soh.soId = 1", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    jpaOuterJoinClause = new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    jpaOuterJoinClause = new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    return joinClauseList;
+  }
+
+  @After
+  public void tearDown() throws Exception {}
+
+  @Test
+  public void testBuild() throws Exception {
+    setUp(getJoinClauseList());
+    JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder = new JPQLJoinSelectSingleStatementBuilder(context);
+    try {
+      JPQLStatement jpqlStatement = jpqlJoinSelectsingleStatementBuilder.build();
+      assertEquals("SELECT gt1 FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.soId = 1 AND soi.shId = soh.soId AND mat.id = 'abc'", jpqlStatement.toString());
+    } catch (ODataJPARuntimeException e) {
+      fail("Should not have come here");
+    }
+
+  }
+
+  private List<KeyPredicate> createKeyPredicates() throws EdmException {
+    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
+    EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+    EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+    EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
+
+    EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
+    List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+    keyPredicates.add(keyPredicate);
+    return keyPredicates;
+  }
+
+  @Test
+  public void testJoinClauseAsNull() throws Exception {
+    setUp(null);
+    JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder = new JPQLJoinSelectSingleStatementBuilder(context);
+    try {
+      jpqlJoinSelectsingleStatementBuilder.build();
+      fail("Should not have come here");
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+  @Test
+  public void testJoinClauseListAsEmpty() throws Exception {
+    List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+    setUp(joinClauseList);
+    JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder = new JPQLJoinSelectSingleStatementBuilder(context);
+    try {
+      jpqlJoinSelectsingleStatementBuilder.build();
+      fail("Should not have come here");
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
new file mode 100644
index 0000000..542800e
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.HashMap;
+import java.util.List;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+
+public class JPQLJoinStatementBuilderTest {
+  JPQLJoinContextView context = null;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {}
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {}
+
+  public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
+    context = EasyMock.createMock(JPQLJoinContextView.class);
+    EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("mat");
+    EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
+    EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
+    EasyMock.expect(context.getSelectExpression()).andStubReturn("mat");
+    EasyMock.expect(context.getWhereExpression()).andStubReturn("soh.buyerId = 2");
+    HashMap<String, String> orderByMap = new HashMap<String, String>();
+    orderByMap.put("mat.buyerId", "asc");
+    orderByMap.put("mat.city", "desc");
+    EasyMock.expect(context.getOrderByCollection()).andStubReturn(orderByMap);
+    EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
+    EasyMock.replay(context);
+  }
+
+  private List<JPAJoinClause> getJoinClauseList() {
+    List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+    JPAJoinClause jpaOuterJoinClause = new JPAJoinClause("SOHeader", "soh", null, null, "soh.createdBy = 'Peter'", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    jpaOuterJoinClause = new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    jpaOuterJoinClause = new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
+    joinClauseList.add(jpaOuterJoinClause);
+    return joinClauseList;
+  }
+
+  @After
+  public void tearDown() throws Exception {}
+
+  @Test
+  public void testBuild() throws Exception {
+    setUp(getJoinClauseList());
+    JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+    try {
+      JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
+      assertEquals("SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' ORDER BY mat.buyerId asc , mat.city desc", jpqlStatement.toString());
+    } catch (ODataJPARuntimeException e) {
+      fail("Should not have come here");
+    }
+
+  }
+
+  @Test
+  public void testJoinClauseAsNull() throws Exception {
+    setUp(null);
+    JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+    try {
+      jpqlJoinStatementBuilder.build();
+      fail("Should not have come here");
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+  @Test
+  public void testJoinClauseListAsEmpty() throws Exception {
+    setUp(new ArrayList<JPAJoinClause>());
+    JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+    try {
+      jpqlJoinStatementBuilder.build();
+      fail("Should not have come here");
+    } catch (ODataJPARuntimeException e) {
+      assertTrue(true);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
new file mode 100644
index 0000000..09f533d
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
@@ -0,0 +1,454 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+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;
+
+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/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
new file mode 100644
index 0000000..7baa021
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+import org.junit.Test;
+
+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;
+
+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/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
new file mode 100644
index 0000000..a22dc63
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+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;
+
+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/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
new file mode 100644
index 0000000..e7af4bd
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+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;
+
+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/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
new file mode 100644
index 0000000..da6d075
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.easymock.EasyMock;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+
+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.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/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
new file mode 100644
index 0000000..ad3fe5a
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+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.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+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.PropertyRef;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+
+public class EdmSchemaMock {
+
+  private static final String ASSOCIATION_ROLE_NAME_ONE = "SalesOrderHeader";
+  private static final String ASSOCIATION_NAME = "SalesOrderHeader_SalesOrderItem";
+  private static final String ASSOCIATION_SET_NAME = "SalesOrderHeader_SalesOrderItemSet";
+  private static final String ASSOCIATION_ROLE_NAME_TWO = "SalesOrderItem";
+  private static final String NAMESPACE = "salesorderprocessing";
+  private static final String ENTITY_CONTAINER_NAME = "salesorderprocessingContainer";
+  private static final String ENTITY_NAME_ONE = "SalesOrderHeader";
+  private static final String ENTITY_NAME_TWO = "SalesOrderItem";
+  private static final String ENTITY_SET_NAME_ONE = "SalesOrderHeaders";
+  private static final String FUNCTION_IMPORT_NAME_ONE = "SalesOrder_FunctionImport1";
+  private static final String FUNCTION_IMPORT_NAME_TWO = "SalesOrder_FunctionImport2";
+  private static final String ENTITY_SET_NAME_TWO = "SalesOrderItems";
+  private static final String COMPLEX_TYPE_NAME_ONE = "Address";
+  private static final String COMPLEX_TYPE_NAME_TWO = "SalesOrderItemKey";
+
+  public static Schema createMockEdmSchema()
+  {
+    Schema schema = new Schema();
+    schema.setNamespace(NAMESPACE);
+    schema.setComplexTypes(createComplexTypes());
+    schema.setEntityContainers(createEntityContainer());
+    schema.setEntityTypes(createEntityTypes());
+    schema.setAssociations(createAssociations());
+    return schema;
+  }
+
+  private static List<EntityContainer> createEntityContainer() {
+    List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+    EntityContainer entityContainer = new EntityContainer();
+    entityContainer.setDefaultEntityContainer(true);
+    entityContainer.setName(ENTITY_CONTAINER_NAME);
+    entityContainer.setEntitySets(createEntitySets());
+    entityContainer.setAssociationSets(createAssociationSets());
+    entityContainer.setFunctionImports(createFunctionImports());
+    entityContainers.add(entityContainer);
+    return entityContainers;
+  }
+
+  private static List<AssociationSet> createAssociationSets() {
+    List<AssociationSet> associationSets = new ArrayList<AssociationSet>();
+    AssociationSet associationSet = new AssociationSet();
+    associationSet.setName(ASSOCIATION_SET_NAME);
+    associationSet.setAssociation(new FullQualifiedName(NAMESPACE, ASSOCIATION_NAME));
+    associationSet.setEnd1(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_ONE)
+        .setRole(ASSOCIATION_ROLE_NAME_ONE));
+    associationSet.setEnd2(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_TWO)
+        .setRole(ASSOCIATION_ROLE_NAME_TWO));
+    associationSets.add(associationSet);
+    return associationSets;
+  }
+
+  private static List<EntitySet> createEntitySets() {
+    List<EntitySet> entitySets = new ArrayList<EntitySet>();
+    EntitySet entitySet = new EntitySet();
+    entitySet.setName(ENTITY_SET_NAME_ONE);
+    entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE));
+    entitySets.add(entitySet);
+    entitySet = new EntitySet();
+    entitySet.setName(ENTITY_SET_NAME_TWO);
+    entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO));
+    entitySets.add(entitySet);
+    return entitySets;
+  }
+
+  private static List<FunctionImport> createFunctionImports() {
+    List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+    FunctionImport functionImport = new FunctionImport();
+    functionImport.setName(FUNCTION_IMPORT_NAME_ONE);
+    functionImports.add(functionImport);
+    functionImport = new FunctionImport();
+    functionImport.setName(FUNCTION_IMPORT_NAME_TWO);
+    functionImports.add(functionImport);
+    return functionImports;
+  }
+
+  private static List<Association> createAssociations() {
+    List<Association> associations = new ArrayList<Association>();
+    Association association = new Association();
+    association.setName(ASSOCIATION_NAME);
+    association.setEnd1(new AssociationEnd().setMultiplicity(EdmMultiplicity.ONE)
+        .setRole(ASSOCIATION_ROLE_NAME_ONE)
+        .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE)));
+    association.setEnd2(new AssociationEnd().setMultiplicity(EdmMultiplicity.MANY)
+        .setRole(ASSOCIATION_ROLE_NAME_TWO)
+        .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO)));
+    associations.add(association);
+    return associations;
+  }
+
+  private static List<EntityType> createEntityTypes() {
+    List<EntityType> entityTypes = new ArrayList<EntityType>();
+    EntityType entityType = new EntityType();
+    entityType.setName(ENTITY_NAME_ONE);
+    String[] keyNamesOne = { "SoId" };
+    entityType.setKey(createKey(keyNamesOne));
+    entityTypes.add(entityType);
+
+    entityType = new EntityType();
+    entityType.setName(ENTITY_NAME_TWO);
+    String[] keyNamesTwo = { "SoId", "LiId" };
+    entityType.setKey(createKey(keyNamesTwo));
+    entityTypes.add(entityType);
+    return entityTypes;
+
+  }
+
+  private static Key createKey(final String[] keyNames) {
+    Key key = new Key();
+    List<PropertyRef> keys = new ArrayList<PropertyRef>();
+    for (String keyName : keyNames) {
+      keys.add(new PropertyRef().setName(keyName));
+    }
+    key.setKeys(keys);
+    return null;
+  }
+
+  private static List<ComplexType> createComplexTypes() {
+    List<ComplexType> complexTypes = new ArrayList<ComplexType>();
+    ComplexType complexTypeOne = new ComplexType();
+    complexTypeOne.setName(COMPLEX_TYPE_NAME_ONE);
+    complexTypeOne.setProperties(createComplexTypePropertiesOne());
+    complexTypes.add(complexTypeOne);
+    ComplexType complexTypeTwo = new ComplexType();
+    complexTypeTwo.setName(COMPLEX_TYPE_NAME_TWO);
+    complexTypeTwo.setProperties(createComplexTypePropertiesTwo());
+    complexTypes.add(complexTypeTwo);
+    return complexTypes;
+  }
+
+  private static List<Property> createComplexTypePropertiesTwo() {
+    List<Property> properties = new ArrayList<Property>();
+    SimpleProperty property = new SimpleProperty();
+    property.setName("SoId");
+    property.setType(EdmSimpleTypeKind.Int64);
+    JPAEdmMapping mapping = new JPAEdmMappingImpl();
+    mapping.setJPAColumnName("Sales_Order_Id");
+    ((Mapping) mapping).setInternalName("SalesOrderItemKey.SoId");
+    property.setMapping((Mapping) mapping);
+    properties.add(property);
+    property = new SimpleProperty();
+    property.setName("LiId");
+    property.setType(EdmSimpleTypeKind.Int64);
+    mapping = new JPAEdmMappingImpl();
+    mapping.setJPAColumnName("Sales_Order_Item_Id");
+    property.setMapping((Mapping) mapping);
+    properties.add(property);
+    return properties;
+
+  }
+
+  private static List<Property> createComplexTypePropertiesOne() {
+    List<Property> properties = new ArrayList<Property>();
+    SimpleProperty property = new SimpleProperty();
+    property.setName("StreetName");
+    property.setType(EdmSimpleTypeKind.String);
+    JPAEdmMapping mapping = new JPAEdmMappingImpl();
+    mapping.setJPAColumnName("STREET_NAME");
+    property.setMapping((Mapping) mapping);
+    properties.add(property);
+    property = new SimpleProperty();
+    property.setName("City");
+    property.setType(EdmSimpleTypeKind.String);
+    mapping = new JPAEdmMappingImpl();
+    mapping.setJPAColumnName("CITY");
+    property.setMapping((Mapping) mapping);
+    properties.add(property);
+    return properties;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
new file mode 100644
index 0000000..0ec7610
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.lang.reflect.Member;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+public abstract class JPAAttributeMock<X, Y> implements Attribute<X, Y> {
+
+  @Override
+  public ManagedType<X> getDeclaringType() {
+    return null;
+  }
+
+  @Override
+  public Member getJavaMember() {
+    return null;
+  }
+
+  @Override
+  public Class<Y> getJavaType() {
+    return null;
+  }
+
+  @Override
+  public String getName() {
+    return null;
+  }
+
+  @Override
+  public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+    return null;
+  }
+
+  @Override
+  public boolean isAssociation() {
+    return false;
+  }
+
+  @Override
+  public boolean isCollection() {
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
new file mode 100644
index 0000000..eb99b4a
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.Facets;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+
+public class JPACustomProcessorMock {
+
+  public static final String className = "JPACustomProcessorMock";
+  public static final String edmName = "JPACustomProcessor";
+
+  @FunctionImport(name = "Method1", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
+  public List<JPACustomProcessorMock> method1(
+      @Parameter(name = "Param1", facets = @Facets(nullable = true, maxLength = 2), mode = Mode.IN) final String param1,
+      final int param2,
+      @Parameter(name = "Param3", facets = @Facets(precision = 10, scale = 2), mode = Mode.IN) final double param3) {
+    return new ArrayList<JPACustomProcessorMock>();
+  }
+
+  @FunctionImport(name = "Method2", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
+  public List<JPACustomProcessorMock> method2(
+      @Parameter(facets = @Facets(maxLength = 2), name = "Param2") final String param2) {
+    return new ArrayList<JPACustomProcessorMock>();
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR)
+  public int method3(@Parameter(name = "Param3") final String param3) {
+    return 0;
+  }
+
+  @FunctionImport(returnType = ReturnType.NONE)
+  public void method4() {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.ONE)
+  public JPACustomProcessorMock method7() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public JPACustomProcessorMock method9() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.MANY)
+  public List<JPACustomProcessorMock> method10() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
new file mode 100644
index 0000000..b5e560a
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+
+public class JPACustomProcessorNegativeMock {
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
+  public List<JPACustomProcessorNegativeMock> method5() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
+  public void method6() {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
+  public JPACustomProcessorNegativeMock method8() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public JPACustomProcessorNegativeMock method11() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public JPACustomProcessorMock method12() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public int method13(@Parameter(name = "") final int y) {
+    return 0;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public void method16(@Parameter(name = "") final int y) {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public void method17(@Parameter(name = "") final int y) {
+    return;
+  }
+}