diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java index 8ac5b7185..84ba04fbd 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java @@ -20,6 +20,6 @@ package org.apache.olingo.odata4.server.api.uri.queryoption; public interface FormatOption extends SystemQueryOption { - // TODO planned: define best representation for format + // TODO planned: define best representation for format to enable plugging in custom formats String getFormat(); } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/SupportedQueryOptions.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/SupportedQueryOptions.java index 60ae6d4a5..63ddf117b 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/SupportedQueryOptions.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/SupportedQueryOptions.java @@ -23,7 +23,7 @@ public enum SupportedQueryOptions { FORMAT("$format"), EXPAND("$expand"), ID("$id"), - INLINECOUNT("$inlinecount"), + COUNT("$count"), ORDERBY("$orderby"), SEARCH("$search"), SELECT("$select"), diff --git a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 index d94302fb2..3c3678217 100644 --- a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 +++ b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 @@ -81,14 +81,12 @@ value : VALUE; //; 2. Query Options //;------------------------------------------------------------------------------ -queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*; +queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;//TODO can this be removed -queryOption : systemQueryOption - | AT_Q aliasAndValue; +queryOption : systemQueryOption; systemQueryOption : expand | filter - | format | inlinecount | orderBy | search @@ -148,7 +146,7 @@ orderByItem : vC=commonExpr ( WSP ( vA=ASC | vD=DESC ) )?; skip : SKIP EQ INT; top : TOP EQ INT; -format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?); +//format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?); inlinecount : COUNT EQ booleanNonCase; diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java index 59b16a457..364bd6ca6 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java @@ -256,7 +256,7 @@ public class UriInfoImpl implements UriInfo { formatOption = (FormatOptionImpl) systemOption; } else if (systemOption.getKind() == SupportedQueryOptions.ID) { idOption = (IdOptionImpl) systemOption; - } else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) { + } else if (systemOption.getKind() == SupportedQueryOptions.COUNT) { inlineCountOption = (CountOptionImpl) systemOption; } else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) { orderByOption = (OrderByOptionImpl) systemOption; diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java index 93a6ce263..bae4b2c26 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java @@ -195,12 +195,6 @@ public class Parser { idOption.setText(option.value); idOption.setValue(option.value); context.contextUriInfo.setSystemQueryOption(idOption); - } else if (option.name.equals("$inlinecount")) { - CountOptionImpl inlineCountOption = new CountOptionImpl(); - inlineCountOption.setName(option.name); - inlineCountOption.setText(option.value); - inlineCountOption.setValue(option.value.equals("true") ? true : false); - context.contextUriInfo.setSystemQueryOption(inlineCountOption); } else if (option.name.equals("$orderby")) { OrderByEOFContext ctxFilterExpression = (OrderByEOFContext) parseRule(option.value, ParserEntryRules.Orderby); @@ -243,20 +237,8 @@ public class Parser { inlineCountOption.setName(option.name); inlineCountOption.setText(option.value); inlineCountOption.setValue(option.value.equals("true") ? true : false); - context.contextUriInfo.setSystemQueryOption(inlineCountOption); - } else if (option.name.equals("$level")) { - LevelsOptionImpl inlineCountOption = new LevelsOptionImpl(); - inlineCountOption.setName(option.name); - inlineCountOption.setText(option.value); - if (option.value.equals("max")) { - inlineCountOption.setMax(); - } else { - inlineCountOption.setValue(Integer.parseInt(option.value)); - } - context.contextUriInfo.setSystemQueryOption(inlineCountOption); } - } } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriDecoder.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriDecoder.java index dc8ac0575..818e27199 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriDecoder.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriDecoder.java @@ -96,10 +96,8 @@ public class UriDecoder { public static void splittPath(final RawUri rawUri, int scipSegments) { List list = splitt(rawUri.path, '/'); - if (list.size() > 0) { - if (list.get(0).length() == 0) { - scipSegments++; - } + if (list.get(0).length() == 0) { + scipSegments++; } if (scipSegments > 0) { @@ -121,9 +119,9 @@ public class UriDecoder { start = end + 1; } - if (end == -1) { - list.add(input.substring(start)); - } + + list.add(input.substring(start)); + return list; } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java index 4f99f0182..f13484fb8 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java @@ -106,7 +106,6 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.ExpandRefO import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FilterContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FilterExpressionEOFContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FloorMethodCallExprContext; -import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FormatContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FractionalsecondsMethodCallExprContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.GeoDistanceMethodCallExprContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.GeoIntersectsMethodCallExprContext; @@ -187,22 +186,16 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.TypeLiter /** * UriVisitor * - * Converts the URI parse tree from the generate URI parser into an internal representation - * which maybe (TODO) given to the application. - * While converting the tree is validated against the EDM. + * Converts the URI parse tree the generated by ANTLR into an internal representation + * which maybe is given to the application. + * While converting the tree is only validated against the EDM if necessary. * * Attention: - *
  • This UriVisitor is at some point more lax than the original ABNF: + *
  • This UriVisitor is at somes point more lax than the original ABNF *
  • It is more tolerable against additional white spaces - * - Whenever it is possible to move edm validation to the AST classes then - * this should be done ( see visit {@link #visitSelectSegment} for example) - * - * Not supported - *
  • Parsing the context of $metadata - * - * TODO planned - *
  • Overview testcases - *
  • search + * Currently not supported + *
  • Parsing the context of $metadata
  • + *
  • Parsing $search
  • */ public class UriParseTreeVisitor extends UriParserBaseVisitor { @@ -216,7 +209,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } public TypeInformation() { - // TODO Auto-generated constructor stub } } @@ -226,14 +218,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // --- class --- - public void setContext(final UriContext context) { - this.context = context; - } - - public UriInfoImpl getUriInfo() { - return context.contextUriInfo; - } - public UriParseTreeVisitor(final Edm edm, final UriContext context) { this.edm = edm; this.context = context; @@ -639,15 +623,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { return type.getNamespace() + "." + type.getName(); } - @Override - public Object visitAliasAndValue(final AliasAndValueContext ctx) { - AliasQueryOptionImpl alias = new AliasQueryOptionImpl(); - alias.setName(ctx.vODI.getText()); - alias.setText(ctx.vV.getText()); - alias.setAliasValue((ExpressionImpl) ctx.vV.accept(this)); - return alias; - } - @Override public Object visitAllEOF(final AllEOFContext ctx) { UriInfoImpl crossJoin = new UriInfoImpl().setKind(UriInfoKind.all); @@ -1009,7 +984,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (type instanceof EdmEntityType) { context.contextUriInfo.addResourcePart(new UriResourceRefImpl()); } else { - throw wrap(new UriParserSemanticException("$ref only allowd on endity types")); + throw wrap(new UriParserSemanticException("$ref only allowed on endity types")); } } else { throw wrap(new UriParserSemanticException("$ref only allowed on typed properties")); @@ -1120,7 +1095,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { levels.setText(ctx.vM.getText()); expandItem.setSystemQueryOption(levels); } else if (ctx.vL != null) { - // TODO set value as integer LevelsOptionImpl levels = new LevelsOptionImpl(); String text = ctx.vL.getText(); levels.setText(text); @@ -1253,35 +1227,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } - @Override - public Object visitFormat(final FormatContext ctx) { - FormatOptionImpl format = new FormatOptionImpl(); - - TerminalNodeImpl c2 = (TerminalNodeImpl) ctx.children.get(2); - if (c2.symbol.getType() == UriLexer.ATOM) { - format.setFormat("atom"); - } else if (c2.symbol.getType() == UriLexer.JSON) { - format.setFormat("json"); - } else if (c2.symbol.getType() == UriLexer.XML) { - format.setFormat("xml"); - } else if (c2.symbol.getType() == UriLexer.PCHARS) { - if (ctx.getChildCount() == 2) { - format.setFormat(c2.getText()); - } else { - format.setFormat(c2.getText() + "/" + ctx.children.get(4).getText()); - } - } - String text = ctx.children.get(2).getText(); - if (ctx.getChildCount() > 4) { - text += ctx.children.get(3).getText(); - text += ctx.children.get(4).getText(); - } - - format.setText(text); - - return format; - } - @Override public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) { return new MethodCallImpl() @@ -1363,9 +1308,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (text.equals("max")) { levels.setMax(); + } else { + levels.setValue(Integer.parseInt(text)); } levels.setText(text); - // TODO set value as integer + return levels; @@ -2034,7 +1981,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // check for action EdmAction action = edm.getAction(fullName, finalTypeName, null); - // TODO verify that null ignores if it is a collection if (action != null) { UriResourceActionImpl uriAction = new UriResourceActionImpl(); @@ -2046,7 +1992,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // check for function EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null); - // TODO verify that null ignores if it is a collection if (function != null) { UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl(); @@ -2151,11 +2096,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } - @Override - public Object visitUnary(final UnaryContext ctx) { - // TODO implement - return super.visitUnary(ctx); - } @Override public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) { diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserException.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserException.java index 8f54672ab..1e5759e35 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserException.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserException.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.odata4.server.core.uri.parser; -//TODO Check name of this exception when implementing proper error handling public class UriParserException extends Exception { /** * diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserSemanticException.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserSemanticException.java index 29c6653c5..c9eb30dd4 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserSemanticException.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParserSemanticException.java @@ -18,12 +18,8 @@ */ package org.apache.olingo.odata4.server.core.uri.parser; -//TODO Check name of this exception when implementing proper error handling public class UriParserSemanticException extends UriParserException { - /** - * - */ private static final long serialVersionUID = 1L; public UriParserSemanticException(final String message, final Throwable cause) { diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java index 86841da33..49705dabb 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java @@ -26,7 +26,7 @@ public class CountOptionImpl extends SystemQueryOptionImpl implements CountOptio private boolean count; public CountOptionImpl() { - setKind(SupportedQueryOptions.INLINECOUNT); + setKind(SupportedQueryOptions.COUNT); } @Override diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java index dc3e2abe5..55c48ce3f 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java @@ -59,7 +59,7 @@ public class ExpandItemImpl implements ExpandItem { expandOption = (ExpandOptionImpl) sysItem; } else if (sysItem.getKind() == SupportedQueryOptions.FILTER) { filterOption = (FilterOptionImpl) sysItem; - } else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) { + } else if (sysItem.getKind() == SupportedQueryOptions.COUNT) { inlineCountOption = (CountOptionImpl) sysItem; } else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) { orderByOption = (OrderByOptionImpl) sysItem; diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java index fc825a4c8..37a92711f 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java @@ -22,7 +22,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.server.api.uri.queryoption.search.SearchExpression; -// TODO $search is not supported yet +// TODO planned: support $search public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOption { public SearchOptionImpl() { @@ -31,7 +31,6 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt @Override public SearchExpression getSearchExpression() { - // TODO $search is not supported yet return null; } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/RawUriTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/RawUriTest.java index b4ab2b05d..e1aa6a089 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/RawUriTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/RawUriTest.java @@ -124,16 +124,17 @@ public class RawUriTest { checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("entitySet")); } - /* - * @Test - * public void testSplitt() { - * UriRawParser.splitt("", '/'); - * UriRawParser.splitt("a", '/'); - * UriRawParser.splitt("a/", '/'); - * UriRawParser.splitt("/a", '/'); - * UriRawParser.splitt("a/a", '/'); - * } - */ + + @Test + public void testSplitt() { + UriDecoder.splitt("", '/'); + UriDecoder.splitt("/", '/'); + UriDecoder.splitt("a", '/'); + UriDecoder.splitt("a/", '/'); + UriDecoder.splitt("/a", '/'); + UriDecoder.splitt("a/a", '/'); + } + private void checkPath(final RawUri rawUri, final String path, final List list) { assertEquals(path, rawUri.path); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriResourceImplTest.java similarity index 99% rename from odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java rename to odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriResourceImplTest.java index 234ba4f71..33fcd55bf 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriResourceImplTest.java @@ -46,7 +46,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.Expressio import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl; import org.junit.Test; -public class UriParameterImplTest { +public class UriResourceImplTest { Edm edm = new EdmProviderImpl(new EdmTechTestProvider()); @Test @@ -200,10 +200,12 @@ public class UriParameterImplTest { .getFunction(new ArrayList()); assertNotNull(function); impl.setFunction(function); + assertEquals(function, impl.getFunction()); assertEquals("UFNRTInt16", impl.toString()); assertEquals(function.getReturnType().getType(), impl.getType()); + assertEquals(false,impl.isParameterListFilled()); // function import impl = new UriResourceFunctionImpl(); @@ -226,6 +228,7 @@ public class UriParameterImplTest { assertEquals(false, impl.isCollection()); assertEquals(parameter, impl.getParameters().get(0)); + assertEquals(true,impl.isParameterListFilled()); } @Test @@ -476,7 +479,7 @@ public class UriParameterImplTest { assertEquals(true, impl.isCollection()); } - /* + @Test public void testUriResourceStartingTypeFilterImpl() { UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl(); @@ -498,5 +501,5 @@ public class UriParameterImplTest { impl.setKeyPredicates(keyPredicates); assertEquals(false, impl.isCollection()); - }*/ + } } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java index 5f723a266..08989389e 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java @@ -18,17 +18,12 @@ */ package org.apache.olingo.odata4.server.core.uri.antlr; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.commons.api.edm.Edm; -import org.apache.olingo.odata4.commons.api.edm.EdmType; -import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName; import org.apache.olingo.odata4.server.api.uri.UriInfoKind; import org.apache.olingo.odata4.server.api.uri.UriResourceKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; @@ -38,7 +33,6 @@ import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl; import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider; import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider; import org.apache.olingo.odata4.server.core.uri.parser.UriParserException; -import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl; import org.apache.olingo.odata4.server.core.uri.testutil.FilterValidator; import org.apache.olingo.odata4.server.core.uri.testutil.ResourceValidator; import org.apache.olingo.odata4.server.core.uri.testutil.UriValidator; @@ -68,8 +62,7 @@ public class TestFullResourcePath { testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETTwoKeyNav); @@ -78,8 +71,7 @@ public class TestFullResourcePath { testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETTwoKeyNav); @@ -88,8 +80,7 @@ public class TestFullResourcePath { testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETTwoKeyNav); @@ -807,8 +798,7 @@ public class TestFullResourcePath { .goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETAllPrim) - .isCollection(false) + .isType(EdmTechProvider.nameETAllPrim, false) .at(1) .isUriPathInfoKind(UriResourceKind.primitiveProperty) .isType(EdmTechProvider.nameString); @@ -818,8 +808,7 @@ public class TestFullResourcePath { .goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETCollAllPrim) - .isCollection(false) + .isType(EdmTechProvider.nameETCollAllPrim, false) .at(1) .isUriPathInfoKind(UriResourceKind.primitiveProperty) .isType(EdmTechProvider.nameString); @@ -830,8 +819,7 @@ public class TestFullResourcePath { .goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(false) + .isType(EdmTechProvider.nameETTwoKeyNav, false) .at(1) .isUriPathInfoKind(UriResourceKind.complexProperty) .at(2) @@ -843,8 +831,7 @@ public class TestFullResourcePath { .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) .at(1) - .isType(EdmTechProvider.nameCTPrimComp) - .isCollection(true) + .isType(EdmTechProvider.nameCTPrimComp, true) .at(2) .isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETAllPrim); @@ -855,8 +842,7 @@ public class TestFullResourcePath { .goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(false) + .isType(EdmTechProvider.nameETTwoKeyNav, false) .at(1) .isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETTwoKeyNav); @@ -866,8 +852,7 @@ public class TestFullResourcePath { .goPath() .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1).isUriPathInfoKind(UriResourceKind.function) .isType(EdmTechProvider.nameETTwoKeyNav); } @@ -1118,15 +1103,16 @@ public class TestFullResourcePath { @Test public void runEsNameKeyCast() { - - testUri.runEx("xESTwoPrim(1)/com.sap.odata.test1.ETBase(1)") - .isExSemantic(0); - - testUri.runEx("xESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)") - .isExSemantic(0); - - testUri.runEx("xESBase/com.sap.odata.test1.ETTwoPrim(1)") - .isExSemantic(0); + /* + * testUri.runEx("ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)") + * .isExSemantic(0); + * + * testUri.runEx("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)") + * .isExSemantic(0); + * + * testUri.runEx("ESBase/com.sap.odata.test1.ETTwoPrim(1)") + * .isExSemantic(0); + */ testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase") .isKind(UriInfoKind.resource).goPath() @@ -2365,9 +2351,9 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) - //.n() + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + // .n() .isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true); testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?" @@ -2378,9 +2364,9 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) - //.n() + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + // .n() .isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true); testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" @@ -2391,9 +2377,9 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) - //.n() + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + // .n() .isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav); @@ -2402,9 +2388,9 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) - //.n() + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) + // .n() .isComplex("PropertyComplexNav") .isType(EdmTechProvider.nameCTBasePrimCompNav) .n() @@ -2416,9 +2402,9 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) - //.n() + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) + // .n() .isComplex("PropertyComplexNav") .isType(EdmTechProvider.nameCTBasePrimCompNav) .n() @@ -2448,10 +2434,10 @@ public class TestFullResourcePath { .goExpand().first() .isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav) .goPath().first() - //.isUriPathInfoKind(UriResourceKind.startingTypeFilter) - //.isType(EdmTechProvider.nameETTwoKeyNav) - //.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) - //.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) + // .isUriPathInfoKind(UriResourceKind.startingTypeFilter) + // .isType(EdmTechProvider.nameETTwoKeyNav) + // .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + // .n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .isType(EdmTechProvider.nameETTwoKeyNav) .isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav) .goUpExpandValidator() @@ -2475,7 +2461,7 @@ public class TestFullResourcePath { .goPath().first() .isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false) .isType(EdmTechProvider.nameETKeyNav); - + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$select=com.sap.odata.test1.ETBaseTwoKeyNav" + "/PropertyInt16") .isKind(UriInfoKind.resource).goPath() @@ -2485,7 +2471,7 @@ public class TestFullResourcePath { .isSelectStartType(0, EdmTechProvider.nameETBaseTwoKeyNav) .goSelectItem(0) .first() - .isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); + .isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyInt16)") .isKind(UriInfoKind.resource) @@ -4170,7 +4156,6 @@ public class TestFullResourcePath { .n().isComplex("PropertyComplex") .n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); - // TODO lambda does not check if the previous path segment is a collection testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyInt16 eq 1 or d/any" + "(e:e/CollPropertyString eq 'SomeString'))") .is(" eq <1>> or " @@ -4381,7 +4366,6 @@ public class TestFullResourcePath { .goUpFilterValidator() .root().goParameter(1).isTypedLiteral(EdmTechProvider.nameString); - // TODO cross check with abap coding testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyString,Edm.Guid)") .is(",)>") .root() @@ -5020,7 +5004,6 @@ public class TestFullResourcePath { .goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator() .goOrder(0).right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1")); - // TODO testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1").isExSyntax(0); testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16, PropertyInt32 PropertyDuration").isExSyntax(0); testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 PropertyInt32, PropertyDuration desc").isExSyntax(0); @@ -5062,6 +5045,57 @@ public class TestFullResourcePath { testUri.run("ESTwoKeyNav?$search= abc AND (def ghi)"); } + @Test + public void testErrors() { + testUri.runEx("FICRTString(wrong1='ABC')/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0); + testUri.runEx("FICRTString(wrong1='ABC', wrong2=1)/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0); + + // type filter for entity incompatible + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBase").isExSemantic(0); + + // type filter for entity double on entry + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')" + + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0); + // type filter for entity double on collection + testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav") + .isExSemantic(0); + // type filter for entity double on non key pred + testUri.runEx("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0); + + // type filter for complex incompatible + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim" + + "/com.sap.odata.test1.CTCollAllPrim").isExSemantic(0); + + // type filter for complex double on entry + testUri.runEx("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')" + + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0); + + // type filter for complex double on collection + testUri.runEx("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')" + + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0); + + // type filter for complex double on non key pred + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim" + + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0); + + testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav").isExSemantic(0); + + // $ref + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$ref").isExSemantic(0); + testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$count").isExSemantic(0); + + } + + @Test + public void testAlias() { + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString=@A)?@A='2'").goPath() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicateAlias(1, "PropertyString", "A") + .goUpUriValidator() + .isCustomParameter(0, "@A", "'2'"); + + } + public static String encode(final String decoded) throws UnsupportedEncodingException { return URLEncoder.encode(decoded, "UTF-8"); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java index fd0f8beaa..415a10d3c 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java @@ -68,29 +68,20 @@ public class TestLexer { test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP); test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP); - // TODO check and add error handling - // test.run("$skip=A").isExType(LexerNoViableAltException.class); - test.run("$top=1").isAllText("$top=1").isType(UriLexer.TOP); test.run("$top=2").isAllText("$top=2").isType(UriLexer.TOP); test.run("$top=123").isAllText("$top=123").isType(UriLexer.TOP); - // TODO check and add error handling - // test.run("$top=A").isExType(LexerNoViableAltException.class); - + test.run("$levels=1").isAllText("$levels=1").isType(UriLexer.LEVELS); test.run("$levels=2").isAllText("$levels=2").isType(UriLexer.LEVELS); test.run("$levels=123").isAllText("$levels=123").isType(UriLexer.LEVELS); test.run("$levels=max").isAllText("$levels=max").isType(UriLexer.LEVELS); - // TODO check and add error handling - // test.run("$levels=A").isExType(LexerNoViableAltException.class); - + test.run("$format=atom").isAllText("$format=atom").isType(UriLexer.FORMAT); test.run("$format=json").isAllText("$format=json").isType(UriLexer.FORMAT); test.run("$format=xml").isAllText("$format=xml").isType(UriLexer.FORMAT); test.run("$format=abc/def").isAllText("$format=abc/def").isType(UriLexer.FORMAT); - // TODO check and add error handling - // test.run("$format=abc").isExType(LexerNoViableAltException.class); - + test.run("$id=123").isAllText("$id=123").isType(UriLexer.ID); test.run("$id=ABC").isAllText("$id=ABC").isType(UriLexer.ID); @@ -108,11 +99,8 @@ public class TestLexer { @Test public void testQueryExpressions() { test.globalMode(Lexer.DEFAULT_MODE); - // assertEquals("expected","actual"); test.run("$it").isText("$it").isType(UriLexer.IT); - // TODO check and add error handling - // test.run("$itabc").isText("$it").isType(UriLexer.IMPLICIT_VARIABLE_EXPR); test.run("$filter=contains(").at(2).isText("contains(").isType(UriLexer.CONTAINS_WORD); @@ -131,106 +119,6 @@ public class TestLexer { } - // ;------------------------------------------------------------------------------ - // ; 5. JSON format for function parameters - // ;------------------------------------------------------------------------------ - - @Test - public void testQueryJSON_and_otheres() { - // QUOTATION_MARK - // test.run("\"").isText("\"").isType(UriLexer.QUOTATION_MARK); - // test.run("%22").isText("%22").isType(UriLexer.QUOTATION_MARK); - - // Lexer rule QCHAR_UNESCAPED - test.run("\"abc\"").isText("\"abc\"").isType(UriLexer.STRING_IN_JSON); - - // Lexer rule QCHAR_JSON_SPECIAL - /* - * test.run("\"" + cQCHAR_JSON_SPECIAL + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * - * // Lexer rule CHAR_IN_JSON - * test.run("\"" + cQCHAR_UNESCAPED + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cQCHAR_JSON_SPECIAL + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * - * // Lexer rule ESCAPE CHAR_IN_JSON - * test.run("\"" + cESCAPE + cQUOTATION_MARK + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + cESCAPE + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "/" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "%2F" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "b" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "f" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "n" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "r" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "t" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - * test.run("\"" + cESCAPE + "u12AB" + "\"").isInput().isType(UriLexer.STRING_IN_JSON); - */ - } - - // ;------------------------------------------------------------------------------ - // ; 6. Names and identifiers - // ;------------------------------------------------------------------------------ - - @Test - public void testNamesAndIdentifiers() { - /* - * test.run("Binary").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Boolean").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Byte").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Date").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("DateTimeOffset").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Decimal").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Double").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Duration").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Guid").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Int16").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Int32").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Int64").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("SByte").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Single").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Stream").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("String").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("TimeOfDay").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * - * test.run("Geography").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run("Geometry").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * - * String g = "Geography"; - * test.run(g ).isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Collection").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiLineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiPoint").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiPolygon").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Point").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Polygon").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * - * g = "Geometry"; - * test.run(g ).isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Collection").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiLineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiPoint").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "MultiPolygon").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Point").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME); - * test.run(g + "Polygon").isInput().isType(UriLexer.PRIMITIVETYPENAME); - */ - } - - @Test - public void testNameClaches() { - /* - * test.run("Collection").isInput().isType(UriLexer.COLLECTION_CS_FIX); - * test.run("LineString").isInput().isType(UriLexer.LINESTRING_CS_FIX); - * test.run("MultiLineString").isInput().isType(UriLexer.MULTILINESTRING_CS_FIX); - * test.run("MultiPoint").isInput().isType(UriLexer.MULTIPOINT_CS_FIX); - * test.run("MultiPolygon").isInput().isType(UriLexer.MULTIPOLYGON_CS_FIX); - * test.run("Point").isInput().isType(UriLexer.POINT_CS_FIX); - * test.run("Polygon").isInput().isType(UriLexer.POLYGON_CS_FIX); - * test.run("Srid").isInput().isType(UriLexer.SRID_CS); - */ - } // ;------------------------------------------------------------------------------ // ; 7. Literal Data Values @@ -246,11 +134,6 @@ public class TestLexer { test.run("binary'ABCD'").isInput().isType(UriLexer.BINARY); test.run("BiNaRy'ABCD'").isInput().isType(UriLexer.BINARY); - // not a binary TODO add error handling - test.run("BiNaRy'ABCDA'") - .at(0).isText("BiNaRy").isType(UriLexer.ODATAIDENTIFIER) - .at(1).isText("'ABCDA'").isType(UriLexer.STRING); - // boolean test.run("true").isInput().isType(UriLexer.TRUE); test.run("false").isInput().isType(UriLexer.FALSE); @@ -342,28 +225,7 @@ public class TestLexer { } - /* - * // ;------------------------------------------------------------------------------ - * // ; 0. misc - * // ;------------------------------------------------------------------------------ - * - * @Test - * public void testCriticalOrder() { - * // Test lexer rule STRING - * test.run("'abc'").isInput().isType(UriLexer.STRING); - * - * // Test lexer rule SEARCHWORD - * test.run("abc", true).isInput().isType(UriLexer.SEARCHWORD); - * - * // Test lexer rule SEARCHPHRASE - * test.run("\"abc\"", true).isInput().isType(UriLexer.SEARCHPHRASE); - * - * // Test lexer rule ODATAIDENTIFIER - * test.run("abc").isInput().isType(UriLexer.ODATAIDENTIFIER); - * - * test.run("\"abc\"").isInput().isType(UriLexer.STRING_IN_JSON); - * } - */ + @Test public void testDelims() { String reserved = "/"; @@ -383,27 +245,6 @@ public class TestLexer { // Test lexer rule PCHAR all test.run("$format=" + cPCHAR + "/" + cPCHAR).isAllInput().isType(UriLexer.FORMAT); - /* - * test.run("$format=" + cPCHAR + "/" + cPCHAR + reserved) - * .isType(UriLexer.FORMAT).at(4) - * .isText(cPCHAR); - */ - - // Test lexer rule QCHAR_NO_AMP - // String amp = "&"; - // Test lexer rule UNRESERVED - // test.run("$id=" + cUNRESERVED).isAllInput().isType(UriLexer.ID); - // test.run("$id=" + cUNRESERVED + amp).isType(UriLexer.ID).at(2).isText(cUNRESERVED); - // Test lexer rule PCT_ENCODED - // test.run("$id=" + cPCT_ENCODED).isAllInput().isType(UriLexer.ID); - // test.run("$id=" + cPCT_ENCODED + amp).isType(UriLexer.ID).at(2).isText(cPCT_ENCODED); - // Test lexer rule OTHER_DELIMS - // test.run("$id=" + cOTHER_DELIMS).isAllInput().isType(UriLexer.ID); - // test.run("$id=" + cOTHER_DELIMS + amp).isType(UriLexer.ID).at(2).isText(cOTHER_DELIMS); - // Lexer rule QCHAR_NO_AMP rest - // test.run("$id=:@/?$'=").isAllText("$id=:@/?$'=").isType(UriLexer.ID); - // test.run("$id=:@/?$'=" + amp).isType(UriLexer.ID).at(2).isText(":@/?$'="); - } } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestParser.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestParser.java deleted file mode 100644 index 7f2add77a..000000000 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestParser.java +++ /dev/null @@ -1,1359 +0,0 @@ -/* - * 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.odata4.server.core.uri.antlr; - -import org.apache.olingo.odata4.server.core.uri.testutil.ParserValidator; -import org.junit.Test; - -/** - * The class {@link TestParser} contains regression tests which work directly on the - * output of the parser (which is generated by ANTLR). These tests should only test the - * parser and must NOT require any EDM in order to ensure that the parser can run in a - * context free manner. - * The single test cases are written according the ABNF (not the parser) since we - * want if the parser works as defined in the ABNF. - * - * Ideally these test detect any (wrong) change on the grammar files - */ -public class TestParser { - private ParserValidator test = null; - - public TestParser() { - test = new ParserValidator(); - } - - @Test - public void test() { - // test.aAM().aFC().aCS().log(1).run("ODI?$filter=PropertyEnumString has com.sap.odata.test1.ENString'String1'"); - } - - // ;------------------------------------------------------------------------------ - // ; 0. URI - // ;------------------------------------------------------------------------------ - // @Test - public void testUri() { - // Test parser rule odataRelativeUri - - test.run("$batch").isText("odataRelativeUriEOF(odataRelativeUri(altBatch($batch)) )"); - - // TODO do more tests on entity - test.run("$entity?$id=ODI").isText("odataRelativeUriEOF(odataRelativeUri($entity ? " - + "entityOptions(id($id = ODI))) )"); - - test.run("$entity?$id=ODI&$format=json").isText("odataRelativeUriEOF(odataRelativeUri($entity ? " - + "entityOptions(id($id = ODI) & entityOption(format($format = json)))) )"); - - // TODO do more tests on entity - test.run("$metadata").isText("odataRelativeUriEOF(odataRelativeUri(altMetadata($metadata)) )"); - - test.run("ODI").isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI))))) )"); - - // Test parser rule resourcePath - test.run("$all").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath($all)) )"); - - test.run("$crossjoin(ODI)").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(" - + "crossjoin($crossjoin ( odataIdentifier(ODI) )))) )"); - - // Test parser rule pathSegments - test.run("ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI)) / " - + "pathSegment(odataIdentifier(ODI))))) )"); - test.run("NS.ODI/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "pathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))))) )"); - test.run("NS.ODI/ODI/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "pathSegment(odataIdentifier(ODI)) / " - + "pathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))))) )"); - // Test parser rule constSegment - test.run("ODI/$value").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)) constSegmentSL(/ constSegment(value($value)))))) )"); - test.run("ODI/$count").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)) constSegmentSL(/ constSegment(count($count)))))) )"); - test.run("ODI/$ref").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)) constSegmentSL(/ constSegment(ref($ref)))))) )"); - - // Test parser rule pathSegment - test.run("NS.ODI") - .isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "namespace(odataIdentifier(NS) .) odataIdentifier(ODI))))) )"); - test.run("ODI(1)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )))))) )"); - - test.run("ODI('ABC')") - .isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(string('ABC')))) )))))) )"); - - test.run("ODI(K1=1)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(1)))) )))))) )"); - - test.run("ODI(K1='ABC')") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(string('ABC'))))) )))))) )"); - - test.run("ODI(K1='ABC',K2=123)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(string('ABC')))) , nameValuePair(odataIdentifier(K2) = " - + "commonExpr(primitiveLiteral(123)))) )))))) )"); - - test.run("ODI(K1=1)(P1=1)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(1)))) )) nameValueOptList(( " - + "nameValueList(nameValuePair(odataIdentifier(P1) = commonExpr(primitiveLiteral(1)))) )))))) )"); - - test.run("ODI(K1='ABC',K2=123)(P1='ABC',P2=123)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(string('ABC')))) , nameValuePair(odataIdentifier(K2) = " - + "commonExpr(primitiveLiteral(123)))) )) nameValueOptList(( " - + "nameValueList(nameValuePair(odataIdentifier(P1) = commonExpr(primitiveLiteral(string('ABC')))) ," - + " nameValuePair(odataIdentifier(P2) = commonExpr(primitiveLiteral(123)))) )))))) )"); - - test.run("NS.ODI(K1='ABC',K2=123)(P1='ABC',P2=123)") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI) " - + "nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(string('ABC')))) , nameValuePair(odataIdentifier(K2) = " - + "commonExpr(primitiveLiteral(123)))) )) nameValueOptList(( " - + "nameValueList(nameValuePair(odataIdentifier(P1) = commonExpr(primitiveLiteral(string('ABC')))) , " - + "nameValuePair(odataIdentifier(P2) = commonExpr(primitiveLiteral(123)))) )))))) )"); - - test.run("ODI(K1=@ABC)").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(" - + "pathSegments(pathSegment(odataIdentifier(ODI) nameValueOptList(( nameValueList(" - + "nameValuePair(odataIdentifier(K1) = @ odataIdentifier(ABC))) )))))) )"); - - test.run("ODI(K1=1,K2=@ABC)").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI) nameValueOptList(( nameValueList(nameValuePair(odataIdentifier(K1) = " - + "commonExpr(primitiveLiteral(1))) , nameValuePair(odataIdentifier(K2) = @ " - + "odataIdentifier(ABC))) )))))) )"); - - } - - // TODO error testing - @Test - public void testUriError() { - // test.run("$entity").isExType(InputMismatchException.class); - // test.run("$entity").isText(""); - } - - // ;------------------------------------------------------------------------------ - // ; 2. Query Options - // ;------------------------------------------------------------------------------ - - // @Test - public void testQueryOptions() { - - // Test parser rule expand - test.run("ODI?$expand=*").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "expand($expand = expandItem(*)))))) )"); - - test.run("ODI?$expand=*,*,*").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "expand($expand = " - + "expandItem(*) , " - + "expandItem(*) , " - + "expandItem(*)))))) )"); - - test.run("ODI?$expand=*/$ref").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "expand($expand = " - + "expandItem(* / ref($ref))))))) )"); - - test.run("ODI?$expand=*/$ref,*,*/$ref").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "expand($expand = expandItem(* / ref($ref)) , " - + "expandItem(*) , " - + "expandItem(* / ref($ref))))))) )"); - - // Test parser rules expand -> levels - test.run("ODI?$expand=*($levels=12)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "expand($expand = " - + "expandItem(* ( $levels = 12 ))))))) )"); - test.run("ODI?$expand=*($levels=max)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(expand($expand = expandItem(* ( $levels = max ))))))) )"); - - // Test parser rules expand -> expandPath - test.run("ODI?$expand=ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(expandPathSegment(odataIdentifier(ODI))))))))) )"); - - test.run("ODI?$expand=NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(" - + "expandPathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))))))))) )"); - - test.run("ODI?$expand=ODI/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI)) / " - + "expandPathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))))))))) )"); - - test.run("ODI?$expand=ODI/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(expandPathSegment(odataIdentifier(ODI)) / " - + "expandPathSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "expandPathSegment(odataIdentifier(ODI))))))))) )"); - - test.run("ODI?$expand=ODI/$ref").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ ref($ref)))))))) )"); - - // Test options for expand items - test.run("ODI?$expand=ODI/$ref($skip=1)").isText("odataRelativeUriEOF(odataRelativeUri" - + "(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(expand($expand = expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ ref($ref) ( " - + "expandRefOption(skip($skip = 1)) )))))))) )"); - - test.run("ODI?$expand=ODI/$count").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(expand($expand = " - + "expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ count($count)))))))) )"); - - test.run("ODI?$expand=ODI/$count($filter=1)").isText("odataRelativeUriEOF(" - + "odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(expand($expand = expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ count($count) ( " - + "expandCountOption(filter($filter = commonExpr(primitiveLiteral(1)))) )))))))) )"); - - test.run("ODI?$expand=ODI/$count($search=\"abc\")").isText("odataRelativeUriEOF(" - + "odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(expand($expand = expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ count($count) ( " - + "expandCountOption($search = \"abc\") )))))))) )"); - - test.run("ODI?$expand=ODI/$ref($skip=1;$filter=true)").isText("odataRelativeUriEOF(" - + "odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(expand($expand = expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(/ ref($ref) ( " - + "expandRefOption(skip($skip = 1)) ; expandRefOption(expandCountOption(filter($filter = " - + "commonExpr(primitiveLiteral(booleanNonCase(true)))))) )))))))) )"); - - test.run("ODI?$expand=ODI($skip=1;$filter=true)").isText("odataRelativeUriEOF(" - + "odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(expand($expand = expandItem(expandPath(" - + "expandPathSegment(odataIdentifier(ODI))) expandPathExtension(( expandOption(" - + "expandRefOption(skip($skip = 1))) ; expandOption(expandRefOption(expandCountOption(filter($filter = " - + "commonExpr(primitiveLiteral(booleanNonCase(true))))))) )))))))) )"); - - // Test parser rule filter ( more filter test in method testExpressions) - test.run("ODI?$filter=true") - .isText( - "odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(booleanNonCase(true)))))))) )"); - - // Test parser rule format - test.run("ODI?$format=atom").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(format($format = atom))))) )"); - - test.run("ODI?$format=json").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(format($format = json))))) )"); - - test.run("ODI?$format=xml").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(format($format = xml))))) )"); - - // Test parser rule id - test.run("ODI?$id=abc") - .isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(id($id = abc))))) )"); - - // Test parser rule count - /* - * TODO add count to new mode based lexer - * test.lexerlog(1).run("ODI?$count=true").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - * + "systemQueryOption(" - * + "inlinecount($count = booleanNonCase(true)))))) )"); - */ - test.run("ODI?$count=false").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(" - + "inlinecount($count = booleanNonCase(false)))))) )"); - - test.run("ODI?$count=TrUe").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(" - + "inlinecount($count = booleanNonCase(TrUe)))))) )"); - - // Test parser rule orderby - test.run("ODI?$orderby=ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(memberExpr(" - + "pathSegments(pathSegment(odataIdentifier(ODI))))))))))) )"); - - test.run("ODI?$orderby=ODI asc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(memberExpr(" - + "pathSegments(pathSegment(odataIdentifier(ODI))))) asc)))))) )"); - - test.run("ODI?$orderby=ODI desc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(memberExpr(" - + "pathSegments(pathSegment(odataIdentifier(ODI))))) desc)))))) )"); - - test.run("ODI?$orderby=ODI desc,ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(memberExpr(" - + "pathSegments(pathSegment(odataIdentifier(ODI))))) desc) , orderByItem(commonExpr(" - + "memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))))))))) )"); - - test.run("ODI?$orderby=ODI desc,ODI asc").isText("odataRelativeUriEOF(odataRelativeUri" - + "(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(memberExpr(" - + "pathSegments(pathSegment(odataIdentifier(ODI))))) desc) , orderByItem(commonExpr(" - + "memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))) asc)))))) )"); - - test.aFC().aAM().aCS().run("ODI?$orderby=3 add 4,ODI asc").isText("odataRelativeUriEOF(" - + "odataRelativeUri(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(orderBy($orderby = orderByItem(commonExpr(" - + "commonExpr(primitiveLiteral(3)) add commonExpr(primitiveLiteral(4)))) , orderByItem(" - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))) asc)))))) )"); - - // Test parser rule skiptoken - test.run("ODI?$skiptoken=abc").isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(" - + "pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(skiptoken($skiptoken = abc))))) )"); - - // Test parser rule search - test.run("ODI?$search=abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= searchExpr(searchWord(abc)))))))) )"); - - test.run("ODI?$search=NOT abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= searchExpr(NOT searchExpr(searchWord(abc))))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$search=abc abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= searchExpr(searchExpr(searchWord(abc)) s" - + "earchExpr(searchWord(abc))))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$search=abc AND abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= searchExpr(searchExpr(searchWord(abc)) AND " - + "searchExpr(searchWord(abc))))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$search=abc OR abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search($search searchSpecialToken(= searchExpr(searchExpr(searchWord(abc)) OR " - + "searchExpr(searchWord(abc))))))))) )"); - - test.run("ODI?$search=\"a%20b%20c\"").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(search(" - + "$search searchSpecialToken(= searchExpr(searchPhrase(\"a%20b%20c\")))))))) )"); - - // Test parser rule search - test.run("ODI?$select=*").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(selectSegment(*))))))) )"); - - test.run("ODI?$select=ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(selectSegment(odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.*").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(selectSegment(namespace(odataIdentifier(NS) .) *))))))) )"); - - test.run("ODI?$select=NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.ODI/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select(" - + "$select = selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=ODI,ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select($select = " - + "selectItem(selectSegment(odataIdentifier(ODI))) , " - + "selectItem(selectSegment(odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.ODI,NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select($select = " - + "selectItem(selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) , " - + "selectItem(selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.ODI/ODIm,NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select($select = " - + "selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(odataIdentifier(ODIm))) , " - + "selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$select=NS.ODI/NS.ODI,NS.ODI/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(select($select = " - + "selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) , " - + "selectItem(" - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)) / " - + "selectSegment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI)))))))) )"); - - test.run("ODI?$skip=123").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(skip($skip = 123))))) )"); - - test.run("ODI?$skiptoken=abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(skiptoken($skiptoken = abc))))) )"); - - test.run("ODI?$top=123").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(top($top = 123))))) )"); - - // test.run("ODI?customparameter=abc"); - - // test.run("ODI").isText(""); - }; - - // @Test - public void testExpressions() { - // Test parser rule commonExpr -> primitiveLiteral - test.run("ODI?$filter=null").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(nullrule(null)))))))) )"); - - test.run("ODI?$filter=true").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(booleanNonCase(true)))))))) )"); - - test.run("ODI?$filter=false").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(booleanNonCase(false)))))))) )"); - - test.run("ODI?$filter=1").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(1))))))) )"); - - test.run("ODI?$filter=-1").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(-1))))))) )"); - - test.run("ODI?$filter=1.1").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(1.1))))))) )"); - - test.run("ODI?$filter=-1.2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(-1.2))))))) )"); - - test.run("ODI?$filter=-1.2e3").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(-1.2e3))))))) )"); - - test.run("ODI?$filter=-1.2e-3").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(-1.2e-3))))))) )"); - - test.run("ODI?$filter=binary'12AB'").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(binary'12AB'))))))) )"); - - test.run("ODI?$filter=BiNaRy'12AB'").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(BiNaRy'12AB'))))))) )"); - - test.run("ODI?$filter=2013-11-15").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(2013-11-15))))))) )"); - - test.run("ODI?$filter=2013-11-15T13:35Z").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(2013-11-15T13:35Z))))))) )"); - - test.run("ODI?$filter=duration'PT67S'").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(duration'PT67S'))))))) )"); - - test.run("ODI?$filter=1234ABCD-12AB-23CD-45EF-123456780ABC").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(1234ABCD-12AB-23CD-45EF-123456780ABC))))))) )"); - - test.run("ODI?$filter='ABC'").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(string('ABC')))))))) )"); - - test.run("ODI?$filter=20:00").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(20:00))))))) )"); - - // Test enum - test.run("ODI?$filter=NS.ODI'1'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(filter($filter = " - + "commonExpr(primitiveLiteral(enumLit(namespace(odataIdentifier(NS) .) " - + "odataIdentifier(ODI) '1')))))))) )"); - test.run("ODI?$filter=NS.ODI'1,3'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(filter($filter = " - + "commonExpr(primitiveLiteral(enumLit(namespace(odataIdentifier(NS) .) " - + "odataIdentifier(ODI) '1,3')))))))) )"); - test.run("ODI?$filter=NS.ODI'ODI,3'") - .isText( - "odataRelativeUriEOF(odataRelativeUri" - + "(resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? " - + "queryOptions(queryOption(systemQueryOption(filter($filter = " - + "commonExpr(primitiveLiteral(enumLit(namespace(odataIdentifier(NS) .) " - + "odataIdentifier(ODI) 'ODI,3')))))))) )"); - - // Test Geometry - - // Rule GeographyCollection - - test.run("ODI?$filter=geography'SRID=0;Collection(LineString(142.1 64.1,3.14 2.78))'") - .isText("odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyCollection(" - + "geography' fullCollectionLiteral(sridLiteral(SRID = 0 ;) collectionLiteral(" - + "Collection ( geoLiteral(lineStringLiteral(" - + "LineString lineStringData(( " - + "positionLiteral(142.1 64.1) , " - + "positionLiteral(3.14 2.78) )))) ))) ')))))))) )"); - - // Rule GeographyLineString - test.run("ODI?$filter=geography'SRID=0;LineString(142.1 64.1,3.14 2.78)'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyLineString(" - + "geography' fullLineStringLiteral(sridLiteral(SRID = 0 ;) lineStringLiteral(" - + "LineString lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )))) '" - + ")))))))) )"); - - // Rule GeographyMultiLineString - test.run("ODI?$filter=geography'SRID=0;MultiLineString((142.1 64.1,3.14 2.78),(142.1 64.1,3.14 2.78))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyMultilineString(" - + "geography' fullMultilineStringLiteral(sridLiteral(SRID = 0 ;) multilineStringLiteral(" - + "MultiLineString ( " - + "lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )) , " - + "lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )) ))) '" - + ")))))))) )"); - - // Rule GeographyMultiPoint - test.run("ODI?$filter=geography'SRID=0;MultiPoint()'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyMultipoint(" - + "geography' fullMultipointLiteral(sridLiteral(SRID = 0 ;) multipointLiteral(" - + "MultiPoint ( ))) ')))))))) )"); - // Rule GeographyMultiPoint - test.run("ODI?$filter=geography'SRID=0;MultiPoint((142.1 64.1),(1 2))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyMultipoint(" - + "geography' fullMultipointLiteral(sridLiteral(SRID = 0 ;) multipointLiteral(" - + "MultiPoint ( " - + "pointData(( positionLiteral(142.1 64.1) )) , " - + "pointData(( positionLiteral(1 2) )) ))) ')))))))) )"); - // Rule GeographyMultiPolygon - test.run("ODI?$filter=geography'SRID=0;MultiPolygon(((1 1,1 1),(1 1,2 2,3 3,1 1)))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyMultipolygon(" - + "geography' fullmultipolygonLiteral(sridLiteral(SRID = 0 ;) multipolygonLiteral(" - + "MultiPolygon ( polygonData(( " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(1 1) )) , " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(2 2) , " - + "positionLiteral(3 3) , positionLiteral(1 1) )) )) ))) ')))))))) )"); - // Rule GeographyPoint - test.run("ODI?$filter=geography'SRID=0;Point(142.1 64.1)'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyPoint(" - + "geography' fullpointLiteral(sridLiteral(SRID = 0 ;) pointLiteral(" - + "Point pointData(( positionLiteral(142.1 64.1) )))) ')))))))) )"); - // Rule GeographyPolygon - test.run("ODI?$filter=geography'SRID=0;Polygon((1 1,1 1),(1 1,2 2,3 3,1 1))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geographyPolygon(" - + "geography' fullPolygonLiteral(sridLiteral(SRID = 0 ;) polygonLiteral(" - + "Polygon polygonData(( " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(1 1) )) , " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(2 2) , " - + "positionLiteral(3 3) , positionLiteral(1 1) )) )))) ')))))))) )"); - // Rule GeometryCollection - test.run("ODI?$filter=geometry'SRID=0;Collection(LineString(142.1 64.1,3.14 2.78))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryCollection(" - + "geometry' fullCollectionLiteral(sridLiteral(SRID = 0 ;) collectionLiteral(" - + "Collection ( geoLiteral(lineStringLiteral(LineString lineStringData(( " - + "positionLiteral(142.1 64.1) , " - + "positionLiteral(3.14 2.78) )))) ))) ')))))))) )"); - // Rule GeometryLineString - test.run("ODI?$filter=geometry'SRID=0;LineString(142.1 64.1,3.14 2.78)'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryLineString(" - + "geometry' fullLineStringLiteral(sridLiteral(SRID = 0 ;) lineStringLiteral(" - + "LineString lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )))) '" - + ")))))))) )"); - // Rule GeometryMultiLineString - test.run("ODI?$filter=geometry'SRID=0;MultiLineString((142.1 64.1,3.14 2.78),(142.1 64.1,3.14 2.78))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryMultilineString(" - + "geometry' fullMultilineStringLiteral(sridLiteral(SRID = 0 ;) multilineStringLiteral(" - + "MultiLineString ( " - + "lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )) , " - + "lineStringData(( positionLiteral(142.1 64.1) , positionLiteral(3.14 2.78) )) ))) '" - + ")))))))) )"); - // Rule GeometryMultiPoint - test.run("ODI?$filter=geometry'SRID=0;MultiPoint()'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryMultipoint(" - + "geometry' fullMultipointLiteral(sridLiteral(SRID = 0 ;) multipointLiteral(MultiPoint ( ))) '" - + ")))))))) )"); - // Rule GeometryMultiPoint - test.run("ODI?$filter=geometry'SRID=0;MultiPoint((142.1 64.1),(1 2))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryMultipoint(" - + "geometry' fullMultipointLiteral(sridLiteral(SRID = 0 ;) " - + "multipointLiteral(MultiPoint ( " - + "pointData(( positionLiteral(142.1 64.1) )) , " - + "pointData(( positionLiteral(1 2) )) ))) ')))))))) )"); - // Rule GeometryMultiPolygon - test.run("ODI?$filter=geometry'SRID=0;MultiPolygon(((1 1,1 1),(1 1,2 2,3 3,1 1)))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryMultipolygon(" - + "geometry' fullmultipolygonLiteral(sridLiteral(SRID = 0 ;) " - + "multipolygonLiteral(MultiPolygon ( polygonData(( " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(1 1) )) , " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(2 2) , " - + "positionLiteral(3 3) , positionLiteral(1 1) )) )) ))) ')))))))) )"); - // Rule GeometryPoint - test.run("ODI?$filter=geometry'SRID=0;Point(142.1 64.1)'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryPoint(" - + "geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) pointLiteral(" - + "Point pointData(( positionLiteral(142.1 64.1) )))) ')))))))) )"); - // Rule GeometryPolygon - test.run("ODI?$filter=geometry'SRID=0;Polygon((1 1,1 1),(1 1,2 2,3 3,1 1))'") - .isText( - "odataRelativeUriEOF(odataRelativeUri(resourcePath(pathSegments(pathSegment(" - + "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption(" - + "filter($filter = commonExpr(primitiveLiteral(geometryPolygon(" - + "geometry' fullPolygonLiteral(sridLiteral(SRID = 0 ;) polygonLiteral(" - + "Polygon polygonData(( " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(1 1) )) , " - + "ringLiteral(( positionLiteral(1 1) , positionLiteral(2 2) , " - + "positionLiteral(3 3) , positionLiteral(1 1) )) )))) ')))))))) )"); - - // Parsing expression required in some cases a FullContextParsing and a report of a ContextSensitivity is fine - - // Test commonExpr - parenthesis - test.aAM().aFC().aCS().run("ODI?$filter=(1) mul 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(" - + "commonExpr(( commonExpr(primitiveLiteral(1)) )) " - + "mul " - + "commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=((((1)))) mul 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(( commonExpr(( commonExpr(( commonExpr(( commonExpr(" - + "primitiveLiteral(1)) )) )) )) )) " - + "mul commonExpr(primitiveLiteral(2)))))))) )"); - test.aAM().aFC().aCS().run("ODI?$filter=(1 add 2)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(( commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(primitiveLiteral(2))) ))))))) )"); - test.aAM().aFC().aCS().run("ODI?$filter=1 mul (2 add 3)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(( commonExpr(commonExpr(primitiveLiteral(2)) " - + "add commonExpr(primitiveLiteral(3))) )))))))) )"); - - // Test commonExpr - methodCallExpr - test.run("ODI?$filter=indexof('ABCXYZ','CXY')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "indexOfMethodCallExpr(indexof( " - + "commonExpr(primitiveLiteral(string('ABCXYZ'))) , " - + "commonExpr(primitiveLiteral(string('CXY'))) ))))))))) )"); - - test.run("ODI?$filter=tolower('ABC')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "toLowerMethodCallExpr(tolower( " - + "commonExpr(primitiveLiteral(string('ABC'))) ))))))))) )"); - - test.run("ODI?$filter=toupper('ABC')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "toUpperMethodCallExpr(toupper( " - + "commonExpr(primitiveLiteral(string('ABC'))) ))))))))) )"); - - test.run("ODI?$filter=trim('%20%20%20ABC%20%20%20')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "trimMethodCallExpr(trim( " - + "commonExpr(primitiveLiteral(string('%20%20%20ABC%20%20%20'))) ))))))))) )"); - - test.run("ODI?$filter=substring('ABC',1)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "substringMethodCallExpr(substring( " - + "commonExpr(primitiveLiteral(string('ABC'))) , " - + "commonExpr(primitiveLiteral(1)) ))))))))) )"); - - test.run("ODI?$filter=substring('ABC',1,2)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "substringMethodCallExpr(substring( " - + "commonExpr(primitiveLiteral(string('ABC'))) , " - + "commonExpr(primitiveLiteral(1)) , " - + "commonExpr(primitiveLiteral(2)) ))))))))) )"); - - test.run("ODI?$filter=concat('ABC','XYZ')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "concatMethodCallExpr(concat( " - + "commonExpr(primitiveLiteral(string('ABC'))) , " - + "commonExpr(primitiveLiteral(string('XYZ'))) ))))))))) )"); - - test.run("ODI?$filter=length('ABC')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "lengthMethodCallExpr(length( commonExpr(primitiveLiteral(string('ABC'))) ))))))))) )"); - - test.run("ODI?$filter=year(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "yearMethodCallExpr(year( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=month(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "monthMethodCallExpr(month( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=day(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "dayMethodCallExpr(day( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=hour(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "hourMethodCallExpr(hour( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=minute(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "minuteMethodCallExpr(minute( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=second(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "secondMethodCallExpr(second( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=fractionalseconds(BirthDate)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "fractionalsecondsMethodCallExpr(fractionalseconds( " - + "commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(BirthDate))))) ))))))))) )"); - - test.run("ODI?$filter=totalseconds(duration'PT67S')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "totalsecondsMethodCallExpr(totalseconds( commonExpr(primitiveLiteral(duration'PT67S')) ))))))))) )"); - - test.run("ODI?$filter=date(2013-11-15T13:35Z)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "dateMethodCallExpr(date( commonExpr(primitiveLiteral(2013-11-15T13:35Z)) ))))))))) )"); - - test.run("ODI?$filter=time(2013-11-15T13:35Z)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "timeMethodCallExpr(time( commonExpr(primitiveLiteral(2013-11-15T13:35Z)) ))))))))) )"); - - test.run("ODI?$filter=round(12.34)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "roundMethodCallExpr(round( commonExpr(primitiveLiteral(12.34)) ))))))))) )"); - - test.run("ODI?$filter=floor(12.34)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "floorMethodCallExpr(floor( commonExpr(primitiveLiteral(12.34)) ))))))))) )"); - - test.run("ODI?$filter=ceiling(12.34)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "ceilingMethodCallExpr(ceiling( commonExpr(primitiveLiteral(12.34)) ))))))))) )"); - - test.run("ODI?$filter=geo.distance(geometry'SRID=0;Point(142.1 64.1)',geometry'SRID=0;Point(142.1 64.1)')") - .isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "geoDistanceMethodCallExpr(" - + "geo.distance( " - + "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) " - + "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , " - + "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) " - + "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) ))))))))) )"); - - // TODO check this - /* - * test.run("ODI?$filter=geo.length(geometry'SRID=0;LineString(142.1 64.1,3.14 2.78)')") - * .isText("odataRelativeUriEOF(odataRelativeUri(" - * + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - * + "queryOption(systemQueryOption(filter($filter = commonExpr(methodCallExpr(" - * + "geoLengthMethodCallExpr(geo.length ( commonExpr(primitiveLiteral(" - * + "geometryLineString(geometry' fullLineStringLiteral(sridLiteral(SRID = 0 ;) lineStringLiteral(" - * + "LineString lineStringData(( positionLiteral(142.1 64.1) , " - * + "positionLiteral(3.14 2.78) )))) '))) ))))))))) )"); - */ - test.run("ODI?$filter=totaloffsetminutes(2013-11-15T13:35Z)") - .isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(methodCallExpr(" - + "totalOffsetMinutesMethodCallExpr(totaloffsetminutes( commonExpr(" - + "primitiveLiteral(2013-11-15T13:35Z)) ))))))))) )"); - - test.run("ODI?$filter=mindatetime()").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(minDateTimeMethodCallExpr(mindatetime( ))))))))) )"); - - test.run("ODI?$filter=maxdatetime()").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(maxDateTimeMethodCallExpr(maxdatetime( ))))))))) )"); - - test.run("ODI?$filter=now()").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(nowMethodCallExpr(now( ))))))))) )"); - - // from boolean - test.run("ODI?$filter=isof(Model.Employee)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(filter($filter = commonExpr(methodCallExpr(isofExpr(isof( namespace(" - + "odataIdentifier(Model) .) odataIdentifier(Employee) ))))))))) )"); - - test.run("ODI?$filter=isof(ODI,Model.Employee)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(filter($filter = commonExpr(methodCallExpr(isofExpr(isof( commonExpr(" - + "memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))) , namespace(odataIdentifier(Model) .) " - + "odataIdentifier(Employee) ))))))))) )"); - - test.run("ODI?$filter=cast(Model.Employee)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(filter($filter = commonExpr(methodCallExpr(castExpr(cast( namespace(" - + "odataIdentifier(Model) .) odataIdentifier(Employee) ))))))))) )"); - - test.run("ODI?$filter=cast(ODI,Model.Employee)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(filter($filter = commonExpr(methodCallExpr(castExpr(cast( commonExpr(" - + "memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))) , namespace(odataIdentifier(Model) .) " - + "odataIdentifier(Employee) ))))))))) )"); - - test.run("ODI?$filter=endswith('ABCXYZ','YZ')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "endsWithMethodCallExpr(endswith( " - + "commonExpr(primitiveLiteral(string('ABCXYZ'))) , " - + "commonExpr(primitiveLiteral(string('YZ'))) ))))))))) )"); - - test.run("ODI?$filter=startswith('ABCXYZ','YZ')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "startsWithMethodCallExpr(startswith( " - + "commonExpr(primitiveLiteral(string('ABCXYZ'))) , " - + "commonExpr(primitiveLiteral(string('YZ'))) ))))))))) )"); - test.run("ODI?$filter=contains('ABCXYZ','YZ')").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(methodCallExpr(" - + "containsMethodCallExpr(contains( " - + "commonExpr(primitiveLiteral(string('ABCXYZ'))) , " - + "commonExpr(primitiveLiteral(string('YZ'))) ))))))))) )"); - /* - * test.run("ODI?$filter=geo.intersects(" - * + "geometry'SRID=0;Point(142.1 64.1)'," - * + "geometry'SRID=0;Polygon((1 1,1 1),(1 1,2 2,3 3,1 1))')").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - * + "queryOption(systemQueryOption(" - * + "filter($filter = commonExpr(methodCallExpr(" - * + "intersectsMethodCallExpr(geo.intersects ( " - * + "commonExpr(primitiveLiteral(" - * + "geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) " - * + "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , " - * + "commonExpr(primitiveLiteral(" - * + "geometryPolygon(geometry' fullPolygonLiteral(sridLiteral(SRID = 0 ;) " - * + "polygonLiteral(Polygon polygonData(( " - * + "ringLiteral(( positionLiteral(1 1) , positionLiteral(1 1) )) , " - * + "ringLiteral(( positionLiteral(1 1) , positionLiteral(2 2) , " - * + "positionLiteral(3 3) , positionLiteral(1 1) )) )))) '))) ))))))))) )"); - */ - // Test commonExpr - unary - test.run("ODI?$filter=true").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = commonExpr(" - + "primitiveLiteral(booleanNonCase(true)))))))) )"); - - // Test commonExpr - member - test.run("ODI?$filter=ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(" - + "memberExpr(pathSegments(pathSegment(odataIdentifier(ODI)))))))))) )"); - - // Test commonExpr - mathematical - test.aAM().aFC().aCS().run("ODI?$filter=1 mul 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 div 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "div commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 mod 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "mod commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 add 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 sub 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "sub commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 gt 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "gt commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 ge 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "ge commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 lt 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "lt commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=1 le 2").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) " - + "le commonExpr(primitiveLiteral(2)))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=true and false").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(booleanNonCase(true))) " - + "and commonExpr(primitiveLiteral(booleanNonCase(false))))))))) )"); - - test.aAM().aFC().aCS().run("ODI?$filter=true or false").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(commonExpr(primitiveLiteral(booleanNonCase(true))) " - + "or commonExpr(primitiveLiteral(booleanNonCase(false))))))))) )"); - - // Test commonExpr - $root - test.run("ODI?$filter=$root/ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(" - + "rootExpr($root/ pathSegments(pathSegment(odataIdentifier(ODI)))))))))) )"); - - // Test concatenated parenthesis - test.run("ODI?$filter=not true").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = commonExpr(" - + "unary(not) commonExpr(primitiveLiteral(booleanNonCase(true))))))))) )"); - } - - @Test - public void testFragment() { - - /* - * test.run("$metadata#Collection($ref)").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(Collection($ref))) )"); - */ - /* - * test.run("$metadata#Collection(Edm.EntityType)").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(Collection(Edm.EntityType))) )"); - * - * test.run("$metadata#Collection(Edm.ComplexType)").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(Collection(Edm.ComplexType))) )"); - * - * test.run("$metadata#singletonEntity").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(singletonEntity)) )"); - * - * test.run("$metadata#NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(NS . ODI)) )"); - * - * test.run("$metadata#Edm.Boolean").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(Edm . Boolean)) )"); - * - * test.run("$metadata#ODI/$deletedEntity").isText("odataRelativeUriEOF(" - * + "odataRelativeUri($metadata # contextFragment(ODI / $deletedEntity)) )"); - * - * test.run("$metadata#ODI/$link").isText("odataRelativeUriEOF(" - * + "odataRelativeUri($metadata # contextFragment(ODI / $link)) )"); - * - * test.run("$metadata#ODI/$deletedLink").isText("odataRelativeUriEOF(" - * + "odataRelativeUri($metadata # contextFragment(ODI / $deletedLink)) )"); - * - * test.run("$metadata#ODI(1)/ODI") - * .isText( - * "odataRelativeUriEOF(odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) " - * + "nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) / odataIdentifier(ODI))) )"); - * - * test.run("$metadata#ODI(1)/NS.ODI") - * .isText( - * "odataRelativeUriEOF(odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) " - * + "nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) / namespace(odataIdentifier(NS) .) " - * + "odataIdentifier(ODI))) )"); - * - * test.run("$metadata#ODI(1)/NS.ODI/ODI") - * .isText( - * "odataRelativeUriEOF(odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) " - * + "nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) / namespace(odataIdentifier(NS) .) " - * + "odataIdentifier(ODI) / odataIdentifier(ODI))) )"); - * - * test.run("$metadata#NS.ODI(*)").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI) " - * + "propertyList(( propertyListItem(*) )))) )"); - * - * test.run("$metadata#ODI(1)") - * .isText( - * "odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(" - * + "primitiveLiteral(1))) )))) )"); - * - * test.run("$metadata#ODI(1)/ODI").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "/ odataIdentifier(ODI))) )"); - * - * test.run("$metadata#ODI(1)/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) )"); - * - * test.run("$metadata#ODI(1)/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri($metadata" - * + " # contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI) / odataIdentifier(ODI))) )"); - * - * test.run("$metadata#ODI(1)(*)").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(*) )))) )"); - * - * test.run("$metadata#ODI(1)(PROP)").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(PROP))) )))) )"); - * test.run("$metadata#ODI(1)(NAVPROP+)").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) +)) )))) )"); - * test.run("$metadata#ODI(1)(NAVPROP+(*))").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + propertyList(( " - * + "propertyListItem(*) )))) )))) )"); - * test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + propertyList(( " - * + "propertyListItem(propertyListProperty(odataIdentifier(A))) , propertyListItem(propertyListProperty(" - * + "odataIdentifier(B))) , propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )))) )"); - * - * test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta").isText("odataRelativeUriEOF(odataRelativeUri($metadata " - * + "# contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + propertyList(( " - * + "propertyListItem(propertyListProperty(odataIdentifier(A))) , propertyListItem(propertyListProperty(" - * + "odataIdentifier(B))) , propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) / " - * + "$delta)) )"); - * - * test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$entity").isText("odataRelativeUriEOF(odataRelativeUri($metadata # " - * + "contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(primitiveLiteral(1))) )) " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + propertyList(( " - * + "propertyListItem(propertyListProperty(odataIdentifier(A))) , propertyListItem(propertyListProperty(" - * + "odataIdentifier(B))) , propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) / " - * + "$entity)) )"); - * test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta/$entity").isText("odataRelativeUriEOF(odataRelativeUri(" - * + "$metadata # contextFragment(odataIdentifier(ODI) nameValueOptList(( valueOnly(commonExpr(" - * + "primitiveLiteral(1))) )) propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + " - * + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(A))) , propertyListItem(" - * + "propertyListProperty(odataIdentifier(B))) , propertyListItem(propertyListProperty(" - * + "odataIdentifier(C))) )))) )) / $delta / $entity)) )"); - */ - } - - // @Test - public void testPrecedence() { - // Test operator precedence - - test.aFC().aCS().aAM().run("ODI?$filter=(1 add 2) mul 3").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(( commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(primitiveLiteral(2))) )) " - + "mul commonExpr(primitiveLiteral(3)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 add (2 mul 3)").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(( commonExpr(commonExpr(primitiveLiteral(2)) " - + "mul commonExpr(primitiveLiteral(3))) )))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 add 2 add 3 add 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(primitiveLiteral(2))) " - + "add commonExpr(primitiveLiteral(3))) " - + "add commonExpr(primitiveLiteral(4)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 add 2 add 3 mul 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(primitiveLiteral(2))) " - + "add commonExpr(commonExpr(primitiveLiteral(3)) " - + "mul commonExpr(primitiveLiteral(4))))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 add 2 mul 3 add 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(commonExpr(primitiveLiteral(2)) " - + "mul commonExpr(primitiveLiteral(3)))) " - + "add commonExpr(primitiveLiteral(4)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 add 2 mul 3 mul 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(primitiveLiteral(1)) " - + "add commonExpr(commonExpr(commonExpr(primitiveLiteral(2)) " - + "mul commonExpr(primitiveLiteral(3))) " - + "mul commonExpr(primitiveLiteral(4))))))))) )"); - test.aFC().aCS().aAM().run("ODI?$filter=1 mul 2 add 3 add 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2))) " - + "add commonExpr(primitiveLiteral(3))) " - + "add commonExpr(primitiveLiteral(4)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 mul 2 add 3 mul 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2))) " - + "add commonExpr(commonExpr(primitiveLiteral(3)) " - + "mul commonExpr(primitiveLiteral(4))))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 mul 2 mul 3 add 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2))) " - + "mul commonExpr(primitiveLiteral(3))) " - + "add commonExpr(primitiveLiteral(4)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 mul 2 mul 3 mul 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(filter($filter = " - + "commonExpr(commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2))) " - + "mul commonExpr(primitiveLiteral(3))) " - + "mul commonExpr(primitiveLiteral(4)))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$filter=1 mul 2 add 3 mul 4").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(" - + "queryOption(systemQueryOption(" - + "filter($filter = " - + "commonExpr(commonExpr(commonExpr(primitiveLiteral(1)) " - + "mul commonExpr(primitiveLiteral(2))) " - + "add commonExpr(commonExpr(primitiveLiteral(3)) " - + "mul commonExpr(primitiveLiteral(4))))))))) )"); - - // Test parser rule search - test.aFC().aCS().aAM().run("ODI?$search=abc OR abc AND abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= " - + "searchExpr(searchExpr(searchWord(abc)) OR " - + "searchExpr(" - + "searchExpr(searchWord(abc)) AND " - + "searchExpr(searchWord(abc)))))))))) )"); - - test.aFC().aCS().aAM().run("ODI?$search=abc OR abc abc").isText("odataRelativeUriEOF(odataRelativeUri(" - + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption(" - + "systemQueryOption(search(" - + "$search searchSpecialToken(= " - + "searchExpr(searchExpr(searchWord(abc)) OR " - + "searchExpr(" - + "searchExpr(searchWord(abc)) " - + "searchExpr(searchWord(abc)))))))))) )"); - } - -} diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java index e0fb3c1b1..035817082 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java @@ -104,69 +104,57 @@ public class TestUriParserImpl { testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameString) - .isCollection(false); + .isType(EdmTechProvider.nameString, false); // returning collection of primitive testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameString) - .isCollection(true); + .isType(EdmTechProvider.nameString, true); // returning single complex testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameCTTwoPrim) - .isCollection(false); + .isType(EdmTechProvider.nameCTTwoPrim, false); // returning collection of complex testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameCTTwoPrim) - .isCollection(true); + .isType(EdmTechProvider.nameCTTwoPrim, true); // returning single entity testRes.run( esTwoKeyNav + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) + .isType(EdmTechProvider.nameETTwoKeyNav, false) .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) - .isCollection(false) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(false); + .isType(EdmTechProvider.nameETTwoKeyNav, false); // returning collection of entity (aka entitySet) testRes.run(esTwoKeyNav + "/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(false) + .isType(EdmTechProvider.nameETTwoKeyNav, false) .at(1) .isUriPathInfoKind(UriResourceKind.function) - .isType(EdmTechProvider.nameETTwoKeyNav) - .isCollection(true); + .isType(EdmTechProvider.nameETTwoKeyNav, true); } @Test @@ -212,8 +200,7 @@ public class TestUriParserImpl { testRes.run("ESAllPrim/$count") .at(0) .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETAllPrim) - .isCollection(true) + .isType(EdmTechProvider.nameETAllPrim,true) .at(1) .isUriPathInfoKind(UriResourceKind.count); @@ -517,10 +504,9 @@ public class TestUriParserImpl { testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase") .at(0) .isEntitySet("ESTwoPrim") - .isType(EdmTechProvider.nameETTwoPrim) + .isType(EdmTechProvider.nameETTwoPrim,true) .isTypeFilterOnCollection(EdmTechProvider.nameETBase) - .isTypeFilterOnEntry(null) - .isCollection(true); + .isTypeFilterOnEntry(null); // filter before key predicate testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)") @@ -531,10 +517,9 @@ public class TestUriParserImpl { .isTypeFilterOnCollection(EdmTechProvider.nameETBase) .isTypeFilterOnEntry(null) .at(0) - .isType(EdmTechProvider.nameETTwoPrim) - .isKeyPredicate(0, "PropertyInt16", "1") - .isCollection(false); - + .isType(EdmTechProvider.nameETTwoPrim,false) + .isKeyPredicate(0, "PropertyInt16", "1"); + // filter before key predicate; property of sub type testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)/AdditionalPropertyString_5") .at(0) @@ -553,11 +538,10 @@ public class TestUriParserImpl { .at(0) .isEntitySet("ESTwoPrim") .isUriPathInfoKind(UriResourceKind.entitySet) - .isType(EdmTechProvider.nameETTwoPrim) + .isType(EdmTechProvider.nameETTwoPrim,false) .isTypeFilterOnCollection(null) .isTypeFilterOnEntry(EdmTechProvider.nameETBase) - .isKeyPredicate(0, "PropertyInt16", "1") - .isCollection(false); + .isKeyPredicate(0, "PropertyInt16", "1"); // filter after key predicate; property of sub type testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase/AdditionalPropertyString_5") @@ -1027,10 +1011,10 @@ public class TestUriParserImpl { + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString") .goFilter().root().isMember() .isMemberStartType(EdmTechProvider.nameCTBase).goPath() - //.at(0) - //.isUriPathInfoKind(UriResourceKind.startingTypeFilter) - //.isType(EdmTechProvider.nameCTTwoPrim, false) - //.isTypeFilterOnEntry(EdmTechProvider.nameCTBase) + // .at(0) + // .isUriPathInfoKind(UriResourceKind.startingTypeFilter) + // .isType(EdmTechProvider.nameCTTwoPrim, false) + // .isTypeFilterOnEntry(EdmTechProvider.nameCTBase) .at(0).isType(EdmTechProvider.nameString); // on Complex collection @@ -1038,10 +1022,10 @@ public class TestUriParserImpl { + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString") .goFilter().root().isMember() .isMemberStartType(EdmTechProvider.nameCTBase).goPath() - //.at(0) - //.isUriPathInfoKind(UriResourceKind.startingTypeFilter) - //.isType(EdmTechProvider.nameCTTwoPrim, true) - //.isTypeFilterOnCollection(EdmTechProvider.nameCTBase) + // .at(0) + // .isUriPathInfoKind(UriResourceKind.startingTypeFilter) + // .isType(EdmTechProvider.nameCTTwoPrim, true) + // .isTypeFilterOnCollection(EdmTechProvider.nameCTBase) .at(0).isType(EdmTechProvider.nameString); } @@ -1120,10 +1104,10 @@ public class TestUriParserImpl { .isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false); testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav") - .isSelectStartType(0,EdmTechProvider.nameETBaseTwoKeyNav); + .isSelectStartType(0, EdmTechProvider.nameETBaseTwoKeyNav); testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav") - .isSelectStartType(0,EdmTechProvider.nameCTTwoBasePrimCompNav); + .isSelectStartType(0, EdmTechProvider.nameCTTwoBasePrimCompNav); testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav") .goSelectItemPath(0) diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java index b4aba01b0..4f62dddbd 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java @@ -161,7 +161,7 @@ public class QueryOptionTest { @Test public void testInlineCountImpl() { CountOptionImpl option = new CountOptionImpl(); - assertEquals(SupportedQueryOptions.INLINECOUNT, option.getKind()); + assertEquals(SupportedQueryOptions.COUNT, option.getKind()); assertEquals(false, option.getValue()); option.setValue(true); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ParserValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ParserValidator.java index dc4936e41..be79777d7 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ParserValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ParserValidator.java @@ -26,7 +26,6 @@ import java.util.List; import org.antlr.v4.runtime.ParserRuleContext; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser; -// TODO extend to test also exception which can occure while paring public class ParserValidator { private String input = null; @@ -55,7 +54,6 @@ public class ParserValidator { } /** - * TODO verify * Used in fast LL Parsing: * Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is * required @@ -67,8 +65,6 @@ public class ParserValidator { } /** - * - * TODO verify * Used in fast LL Parsing: * Allows ContextSensitifity Errors which occur often when using the slower full context parsing * and indicate that there is a context sensitivity ( which may not be an error). @@ -80,7 +76,6 @@ public class ParserValidator { } /** - * TODO verify * Used in fast LL Parsing: * Allows ambiguities * @return @@ -164,80 +159,4 @@ public class ParserValidator { return this; } - // --- Helper --- - /* - * private OdataRelativeUriEOFContext parseInput(final String input) { - * UriParserParser parser = null; - * UriLexerWithTrace lexer = null; - * OdataRelativeUriEOFContext ret = null; - * - * // Use 2 stage approach to improve performance - * // see https://github.com/antlr/antlr4/issues/192 - * // TODO verify this - * - * // stage= 1 - * try { - * curException = null; - * exceptions.clear(); - * - * // create parser - * lexer = new UriLexerWithTrace(new ANTLRInputStream(input), lexerLogLevel); - * parser = new UriParserParser(new CommonTokenStream(lexer)); - * - * // write always a error message in case of syntax errors - * // parser.addErrorListener(new TestErrorHandler()); - * // check error message if whether they are allowed or not - * // parser.addErrorListener(new ErrorCollector()); - * - * // bail out of parser at first syntax error. --> proceed in catch block with step 2 - * parser.setErrorHandler(new BailErrorStrategy()); - * - * // user the faster SLL parsing - * parser.getInterpreter().setPredictionMode(PredictionMode.SLL); - * - * // parse - * if (logLevel > 0) { - * System.out.println("Step 1"); - * System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode()); - * } - * ret = parser.odataRelativeUriEOF(); - * - * } catch (Exception exception) { - * curException = exception; - * try { - * // clear status - * curException = null; - * exceptions.clear(); - * - * // create parser - * lexer = new UriLexerWithTrace(new ANTLRInputStream(input), lexerLogLevel); - * parser = new UriParserParser(new CommonTokenStream(lexer)); - * - * // write always a error message in case of syntax errors - * // parser.addErrorListener(new ErrorCollector(this)); - * // check error message if whether they are allowed or not - * // parser.addErrorListener(new ErrorCollector(this)); - * - * // Used default error strategy - * parser.setErrorHandler(new DefaultErrorStrategy()); - * - * // User the slower SLL parsing - * parser.getInterpreter().setPredictionMode(PredictionMode.LL); - * - * // parse - * if (logLevel > 1) { - * System.out.println("Step 2"); - * System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode() + ")"); - * } - * ret = parser.odataRelativeUriEOF(); - * - * } catch (Exception exception1) { - * curException = exception1; - * // exceptionOnStage = 2; - * } - * } - * - * return ret; - * } - */ } \ No newline at end of file diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ResourceValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ResourceValidator.java index 0e1b46a23..933028079 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ResourceValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/testutil/ResourceValidator.java @@ -327,7 +327,7 @@ public class ResourceValidator implements Validator { } // TODO remove - public ResourceValidator isCollection(final boolean isCollection) { + /*public ResourceValidator isCollection(final boolean isCollection) { if (!(uriPathInfo instanceof UriResourcePartTyped)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -339,7 +339,7 @@ public class ResourceValidator implements Validator { } assertEquals(isCollection, uriPathInfoTyped.isCollection()); return this; - } + }*/ public ResourceValidator isFilterString(final String expectedFilterTreeAsString) { @@ -368,6 +368,19 @@ public class ResourceValidator implements Validator { return this; } + + public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) { + if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) { + fail("invalid resource kind: " + uriPathInfo.getKind().toString()); + } + + UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo; + List keyPredicates = info.getKeyPredicates(); + assertEquals(name, keyPredicates.get(index).getName()); + assertEquals(alias, keyPredicates.get(index).getAlias()); + return this; + + } public ResourceValidator isKeyPredicate(final int index, final String name, final String text) { if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {