You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2016/06/29 13:01:31 UTC

olingo-odata4 git commit: [OLINGO-966] Fix filter parser guid detection

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 2e24ffd1d -> 6afb7fff4


[OLINGO-966] Fix filter parser guid detection


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6afb7fff
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6afb7fff
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6afb7fff

Branch: refs/heads/master
Commit: 6afb7fff4ba84fca7773dc067f0e8e3a66d44dcb
Parents: 2e24ffd
Author: Christian Amend <ch...@sap.com>
Authored: Wed Jun 29 14:53:09 2016 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Wed Jun 29 14:57:31 2016 +0200

----------------------------------------------------------------------
 .../server/core/uri/parser/ParserHelper.java    |  2 +-
 .../server/core/uri/parser/ParserTest.java      | 32 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6afb7fff/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
index 6ff8f2f..498ba18 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
@@ -125,9 +125,9 @@ public class ParserHelper {
 
         // The order of the next seven expressions is important in order to avoid
         // finding partly parsed tokens (counter-intuitive as it may be, even a GUID may start with digits ...).
+        TokenKind.GuidValue,
         TokenKind.DoubleValue,
         TokenKind.DecimalValue,
-        TokenKind.GuidValue,
         TokenKind.DateTimeOffsetValue,
         TokenKind.DateValue,
         TokenKind.TimeOfDayValue,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6afb7fff/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
index f89a863..1eaa7ff 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
@@ -68,6 +68,38 @@ public class ParserTest {
         .goPath()
         .at(0).isEntitySet(entitySetName)
         .at(0).isKeyPredicate(0, keyPropertyName, "f89dee73-af9f-4cd4-b330-db93c25ff3c7");
+
+    new TestUriValidator().setEdm(mockedEdm)
+        .run("ESGuid(889e3e73-af9f-4cd4-b330-db93c25ff3c7)")
+        .goPath()
+        .at(0).isEntitySet(entitySetName)
+        .at(0).isKeyPredicate(0, keyPropertyName, "889e3e73-af9f-4cd4-b330-db93c25ff3c7");
+  }
+
+  @Test
+  public void keyPropertyGuidStartsWithNumber() throws Exception {
+    final String entitySetName = "ESGuid";
+    final String keyPropertyName = "a";
+    EdmProperty keyProperty = Mockito.mock(EdmProperty.class);
+    Mockito.when(keyProperty.getType())
+        .thenReturn(OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Guid));
+    EdmKeyPropertyRef keyPropertyRef = Mockito.mock(EdmKeyPropertyRef.class);
+    Mockito.when(keyPropertyRef.getName()).thenReturn(keyPropertyName);
+    Mockito.when(keyPropertyRef.getProperty()).thenReturn(keyProperty);
+    EdmEntityType entityType = Mockito.mock(EdmEntityType.class);
+    Mockito.when(entityType.getKeyPredicateNames()).thenReturn(Collections.singletonList(keyPropertyName));
+    Mockito.when(entityType.getKeyPropertyRefs()).thenReturn(Collections.singletonList(keyPropertyRef));
+    Mockito.when(entityType.getPropertyNames()).thenReturn(Collections.singletonList(keyPropertyName));
+    Mockito.when(entityType.getProperty(keyPropertyName)).thenReturn(keyProperty);
+    EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class);
+    Mockito.when(entitySet.getName()).thenReturn(entitySetName);
+    Mockito.when(entitySet.getEntityType()).thenReturn(entityType);
+    EdmEntityContainer container = Mockito.mock(EdmEntityContainer.class);
+    Mockito.when(container.getEntitySet(entitySetName)).thenReturn(entitySet);
+    Edm mockedEdm = Mockito.mock(Edm.class);
+    Mockito.when(mockedEdm.getEntityContainer()).thenReturn(container);
+    new TestUriValidator().setEdm(mockedEdm)
+        .run("ESGuid", "$filter=a eq 889e3e73-af9f-4cd4-b330-db93c25ff3c7");
   }
 
   @Test