Repository: olingo-odata2
Updated Branches:
  refs/heads/OLINGO-1146-Fix 00586891a -> 681f7de77


[OLINGO-1146] Fixed test improved solution


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/681f7de7
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/681f7de7
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/681f7de7

Branch: refs/heads/OLINGO-1146-Fix
Commit: 681f7de778263ba533800215d19b1e89a59786d9
Parents: 0058689
Author: mibo <[email protected]>
Authored: Sat Sep 23 20:55:12 2017 +0200
Committer: mibo <[email protected]>
Committed: Sat Sep 23 20:55:12 2017 +0200

----------------------------------------------------------------------
 .../odata2/core/uri/expression/FilterParserImpl.java   | 13 +++++++++++--
 .../olingo/odata2/core/uri/expression/TestParser.java  |  5 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/681f7de7/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
----------------------------------------------------------------------
diff --git 
a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
 
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
index 709f284..b3b20f1 100644
--- 
a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
+++ 
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
@@ -526,9 +526,18 @@ public class FilterParserImpl implements FilterParser {
     }
   }
 
+  /**
+   * Check if the property name is the last or only element of the filter
+   * @param propertyName name of the property
+   * @return <code>true</code> if this is the last or only otherwise 
<code>false</code>
+   */
   private boolean isLastFilterElement(String propertyName) {
-    final String lastElement = "/" + propertyName + " ";
-    return curExpression.contains(lastElement);
+    if(curExpression.contains("/")) {
+      final String lastElement = "/" + propertyName + " ";
+      return curExpression.contains(lastElement);
+    }
+    // if no `/` is present this property is implicit the last filter element
+    return true;
   }
 
   protected void validateUnaryOperatorTypes(final UnaryExpression 
unaryExpression)

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/681f7de7/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
----------------------------------------------------------------------
diff --git 
a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
 
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
index bbec5d9..637287c 100644
--- 
a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
+++ 
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
@@ -389,11 +389,12 @@ public class TestParser extends TestBase {
     final EdmEntityType entityType = edmInfo.getTypeEtKeyTypeInteger();
     final EdmEntityType entityType2 = edmInfo.getTypeEtKeyTypeString();
     GetPTF_noTEST(entityType, 
"navProperty").aExKey(ExpressionParserException.TYPE_EXPECTED_AT);
-    GetPTF_noTEST(entityType, 
"navProperty/navProperty").aExKey(ExpressionParserException.INVALID_MULTIPLICITY);
+    GetPTF_noTEST(entityType, 
"navProperty/navProperty").aExKey(ExpressionParserException.TYPE_EXPECTED_AT);
     GetPTF_noTEST(entityType, "navProperty/KeyString eq 'a'")
         .root().left().left().aEdmType(entityType2)
         .root().left().right().aEdmType(EdmString.getInstance());
-    GetPTF_noTEST(entityType2, "navProperty/KeyInteger eq 
1").aExKey(ExpressionParserException.INVALID_MULTIPLICITY);
+    GetPTF_noTEST(entityType2, "navProperty/KeyInteger eq 1")
+        .aExKey(ExpressionParserException.INVALID_TYPES_FOR_BINARY_OPERATOR);
     GetPTF_noTEST(entityType, "navProperty ne 
null").root().left().aEdmType(entityType2);
     GetPTF_noTEST(entityType, "navProperty ne null and not (navProperty eq 
null)")
         .root().aKind(ExpressionKind.BINARY)

Reply via email to