[OLINGO-966] Fix filter parser guid detection
This commit is contained in:
parent
2e24ffd1d3
commit
6afb7fff4b
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue