Repository: olingo-odata2 Updated Branches: refs/heads/master 85c993f1c -> ca39c367a
OLINGO-1174 OlingoV2JPA: Filters having multiple dots generates wrong queries Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/ca39c367 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/ca39c367 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/ca39c367 Branch: refs/heads/master Commit: ca39c367a2ca6548c6446958c1750c3c61211adc Parents: 85c993f Author: ramya vasanth <ramya.vasa...@sap.com> Authored: Tue Sep 5 09:09:47 2017 +0530 Committer: ramya vasanth <ramya.vasa...@sap.com> Committed: Tue Sep 5 09:09:47 2017 +0530 ---------------------------------------------------------------------- .../core/access/data/JPAQueryBuilder.java | 2 +- .../core/access/data/JPAEntityTest.java | 2 +- .../core/access/data/JPAQueryBuilderTest.java | 307 +++++++++++++++++++ 3 files changed, 309 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ca39c367/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java index 6f66af9..61ce1ba 100644 --- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java +++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java @@ -239,7 +239,7 @@ public class JPAQueryBuilder { } private static final Pattern NORMALIZATION_NEEDED_PATTERN = Pattern.compile(".*[\\s(](\\S+\\.\\S+\\.\\S+).*"); - private static final Pattern VALUE_NORM_PATTERN = Pattern.compile("(?:^|\\s)'([^'](\\S+\\.\\S+\\.\\S+)')"); + private static final Pattern VALUE_NORM_PATTERN = Pattern.compile("(?:^|\\s|\\()'(([^']*)')"); private static final Pattern JOIN_ALIAS_PATTERN = Pattern.compile(".*\\sJOIN\\s(\\S*\\s\\S*).*"); private static String normalizeMembers(EntityManager em, String jpqlQuery) { http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ca39c367/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java index 331a3d2..92445ab 100644 --- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java +++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java @@ -354,7 +354,7 @@ public class JPAEntityTest { assertEquals(jpaEmbeddableMock.getMDate().getDate(), ODataEntryMockUtil.VALUE_DATE.getDate()); assertEquals(jpaEmbeddableMock.getMDate().getDay(), ODataEntryMockUtil.VALUE_DATE.getDay()); assertEquals(jpaEmbeddableMock.getMDate1().getDate(), ODataEntryMockUtil.VALUE_DATE1.getDate()); - assertEquals(jpaEmbeddableMock.getMTime(), ODataEntryMockUtil.VALUE_TIME); + assertEquals(jpaEmbeddableMock.getMTime().getTime(), ODataEntryMockUtil.VALUE_TIME.getTime()); assertEquals(jpaEmbeddableMock.getMTimestamp(), ODataEntryMockUtil.VALUE_TIMESTAMP); JPATypeEmbeddableMock2 jpaEmbeddableMock2 = jpaEmbeddableMock.getMEmbeddable(); assertNotNull(jpaEmbeddableMock2); http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ca39c367/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilderTest.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilderTest.java index 7d35ed6..a3b9ec5 100644 --- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilderTest.java +++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilderTest.java @@ -33,12 +33,26 @@ 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.EdmNavigationProperty; import org.apache.olingo.odata2.api.edm.EdmProperty; +import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; import org.apache.olingo.odata2.api.exception.ODataException; import org.apache.olingo.odata2.api.processor.ODataContext; import org.apache.olingo.odata2.api.uri.KeyPredicate; import org.apache.olingo.odata2.api.uri.NavigationSegment; import org.apache.olingo.odata2.api.uri.UriInfo; +import org.apache.olingo.odata2.api.uri.expression.BinaryExpression; +import org.apache.olingo.odata2.api.uri.expression.BinaryOperator; +import org.apache.olingo.odata2.api.uri.expression.CommonExpression; +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.LiteralExpression; +import org.apache.olingo.odata2.api.uri.expression.MemberExpression; +import org.apache.olingo.odata2.api.uri.expression.MethodExpression; +import org.apache.olingo.odata2.api.uri.expression.MethodOperator; +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.info.DeleteUriInfo; import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo; import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo; @@ -200,8 +214,123 @@ public class JPAQueryBuilderTest { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } } + + @Test + public void buildQueryGetEntitySetTestWithNoNormalizationWithSubstringof() { + EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "substringof"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNormalizationWithSubstringof() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "substringof"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNormalizationWithStartsWith() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "startsWith"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNoNormalizationWithStartsWith() { + EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "startsWith"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNormalizationWithEndsWith() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "endsWith"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNoNormalizationWithEndsWith() { + EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoForEntitySet(mapping, "endsWith"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNormalizationWithSubstring() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) + mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "substring"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNoNormalizationWithSubstring() { + EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) + mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "substring"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } @Test + public void buildQueryGetEntitySetTestWithNormalizationWithtoLower() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) + mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toLower"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNoNormalizationWithtoLower() { + EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) + mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toLower"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test + public void buildQueryGetEntitySetTestWithNormalizationWithSubstringof1() { + EdmMapping mapping = (EdmMapping) mockNormalizedMapping1(); + try { + assertNotNull(builder.build((GetEntitySetUriInfo) + mockURIInfoForEntitySet(mapping, "substringof_1"))); + } catch (ODataException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + } + + @Test public void buildQueryValueNormalizeTest() { EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping(); try { @@ -269,6 +398,160 @@ public class JPAQueryBuilderTest { return uriInfo; } + + private UriInfo mockURIInfoForEntitySet(EdmMapping mapping, String methodName) throws EdmException { + + UriInfo uriInfo = EasyMock.createMock(UriInfo.class); + List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); + EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); + EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); + EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); + EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); + EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); + EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); + EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class); + EasyMock.expect(edmProperty.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty()); + + EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class); + EasyMock.expect(edmProperty1.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty1()); + + EdmNavigationProperty navEdmProperty = EasyMock.createMock(EdmNavigationProperty.class); + EasyMock.expect(navEdmProperty.getMapping()).andStubReturn((EdmMapping)mockNavEdmMappingForProperty()); + + OrderByExpression orderbyExpression = EasyMock.createMock(OrderByExpression.class); + List<OrderExpression> orders = new ArrayList<OrderExpression>(); + EasyMock.expect(orderbyExpression.getOrders()).andStubReturn(orders); + EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(orderbyExpression); + FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class); + MethodExpression commonExpression = EasyMock.createMock(MethodExpression.class); + EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.METHOD); + PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class); + LiteralExpression literalExp = EasyMock.createMock(LiteralExpression.class); + MemberExpression memberExp = EasyMock.createMock(MemberExpression.class); + List<CommonExpression> parameterList = new ArrayList<CommonExpression>(); + + PropertyExpression navPropExp = EasyMock.createMock(PropertyExpression.class); + if ("substringof".equals(methodName)) { + EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.SUBSTRINGOF); + EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2); + EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'"); + EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); + parameterList.add(literalExp); + EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); + EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + parameterList.add(propExp); + } else if ("startsWith".equals(methodName) || "endsWith".equals(methodName)) { + EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.STARTSWITH); + EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2); + EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); + EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + parameterList.add(propExp); + EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'"); + EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); + parameterList.add(literalExp); + } else if ("substringof_1".equals(methodName)) { + EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.SUBSTRINGOF); + EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2); + EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'"); + EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); + parameterList.add(literalExp); + EasyMock.expect(memberExp.getKind()).andStubReturn(ExpressionKind.MEMBER); + EasyMock.expect(memberExp.getProperty()).andStubReturn(propExp); + + EasyMock.expect(memberExp.getPath()).andStubReturn(navPropExp); + EasyMock.expect(navPropExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + EasyMock.expect(navPropExp.getEdmProperty()).andStubReturn(navEdmProperty); + EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty1); + + parameterList.add(propExp); + } + + EasyMock.expect(commonExpression.getParameters()).andStubReturn(parameterList); + + EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression); + EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER); + EasyMock.expect(filterExpression.getExpressionString()).andStubReturn("substringof('a.b.c',Id)"); + EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression); + EasyMock.replay(edmEntityType, edmEntitySet, orderbyExpression, filterExpression, + commonExpression, literalExp, propExp, uriInfo, edmProperty, memberExp, + edmProperty1, navEdmProperty); + return uriInfo; + + } + + private UriInfo mockURIInfoForEntitySetWithBinaryFilterExpression + (EdmMapping mapping, String methodName) throws EdmException { + + UriInfo uriInfo = EasyMock.createMock(UriInfo.class); + List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); + EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); + EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); + EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); + EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); + EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); + EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); + EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class); + EasyMock.expect(edmProperty.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty()); + OrderByExpression orderbyExpression = EasyMock.createMock(OrderByExpression.class); + List<OrderExpression> orders = new ArrayList<OrderExpression>(); + EasyMock.expect(orderbyExpression.getOrders()).andStubReturn(orders); + EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(orderbyExpression); + FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class); + BinaryExpression commonExpression = EasyMock.createMock(BinaryExpression.class); + EasyMock.expect(commonExpression.getOperator()).andStubReturn(BinaryOperator.EQ); + EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.BINARY); + MethodExpression methodExp = EasyMock.createMock(MethodExpression.class); + EasyMock.expect(commonExpression.getLeftOperand()).andStubReturn(methodExp); + + LiteralExpression literalValueExp = EasyMock.createMock(LiteralExpression.class); + EasyMock.expect(commonExpression.getRightOperand()).andStubReturn(literalValueExp); + EasyMock.expect(literalValueExp.getUriLiteral()).andStubReturn("'a%.b*.c'"); + EasyMock.expect(literalValueExp.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalValueExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); + + PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class); + LiteralExpression literalExp1 = EasyMock.createMock(LiteralExpression.class); + LiteralExpression literalExp2 = EasyMock.createMock(LiteralExpression.class); + List<CommonExpression> parameterList = new ArrayList<CommonExpression>(); + if ("substring".equals(methodName)) { + EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.SUBSTRING); + EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD); + EasyMock.expect(methodExp.getParameterCount()).andStubReturn(3); + EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); + EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + parameterList.add(propExp); + EasyMock.expect(literalExp1.getUriLiteral()).andStubReturn("1"); + EasyMock.expect(literalExp1.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalExp1.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()); + parameterList.add(literalExp1); + EasyMock.expect(literalExp2.getUriLiteral()).andStubReturn("2"); + EasyMock.expect(literalExp2.getKind()).andStubReturn(ExpressionKind.LITERAL); + EasyMock.expect(literalExp2.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()); + parameterList.add(literalExp2); + EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList); + } else if ("toLower".equals(methodName)) { + EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.TOLOWER); + EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD); + EasyMock.expect(methodExp.getParameterCount()).andStubReturn(1); + EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); + EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); + parameterList.add(propExp); + EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList); + } + EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression); + EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER); + EasyMock.expect(filterExpression.getExpressionString()).andStubReturn("substring(CompanyName,1,2) eq 'a.b.c'"); + EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression); + EasyMock.replay(edmEntityType, edmEntitySet, orderbyExpression, filterExpression, + commonExpression, literalExp1, literalExp2, propExp, uriInfo, edmProperty, + methodExp, literalValueExp); + return uriInfo; + + } private JPAEdmMapping mockEdmMapping() { JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); @@ -276,6 +559,24 @@ public class JPAQueryBuilderTest { return mockedEdmMapping; } + private JPAEdmMapping mockEdmMappingForProperty() { + JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); + mockedEdmMapping.setInternalName("CustomerName"); + return mockedEdmMapping; + } + + private JPAEdmMapping mockEdmMappingForProperty1() { + JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); + mockedEdmMapping.setInternalName("SalesOrderHeader.CustomerName"); + return mockedEdmMapping; + } + + private JPAEdmMapping mockNavEdmMappingForProperty() { + JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); + mockedEdmMapping.setInternalName("SalesOrderHeader"); + return mockedEdmMapping; + } + private JPAEdmMapping mockMapping() { JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); mockedEdmMapping.setInternalName("Customer"); @@ -289,6 +590,12 @@ public class JPAQueryBuilderTest { return mockedEdmMapping; } + private JPAEdmMapping mockNormalizedMapping1() { + JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); + mockedEdmMapping.setInternalName("E1.SalesOrderItem"); + return mockedEdmMapping; + } + private JPAEdmMapping mockNormalizedValueMapping() { JPAEdmMappingImpl mockedEdmMapping = new JPAEdmMappingImpl(); mockedEdmMapping.setInternalName("'C1.Customer.Name'");