mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-02-06 18:18:55 +00:00
[OLINGO-63] Uri Parser: add testes for
This commit is contained in:
parent
71ea12382c
commit
7a3ee483ba
@ -30,9 +30,6 @@ public interface SelectItem {
|
|||||||
|
|
||||||
FullQualifiedName getAllOperationsInSchemaNameSpace();
|
FullQualifiedName getAllOperationsInSchemaNameSpace();
|
||||||
|
|
||||||
EdmEntityType getEntityTypeCast();
|
|
||||||
|
|
||||||
|
|
||||||
UriInfoResource getResourceInfo();
|
UriInfoResource getResourceInfo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,6 @@ public enum SupportedBinaryOperators {
|
|||||||
ADD("add"), SUB("sub"),
|
ADD("add"), SUB("sub"),
|
||||||
// comparism
|
// comparism
|
||||||
GT("gt"), GE("ge"), LT("lt"), LE("le"),
|
GT("gt"), GE("ge"), LT("lt"), LE("le"),
|
||||||
// isof
|
|
||||||
ISOF("isof"),
|
|
||||||
// equality
|
// equality
|
||||||
EQ("eq"), NE("ne"),
|
EQ("eq"), NE("ne"),
|
||||||
// and/or
|
// and/or
|
||||||
|
@ -29,7 +29,8 @@ public enum SupportedMethodCalls {
|
|||||||
|
|
||||||
ROUND("round"), FLOOR("floor"),
|
ROUND("round"), FLOOR("floor"),
|
||||||
|
|
||||||
CEILING("ceiling"), DISTANCE("distance"), GEOLENGTH("geolength"), INTERSECTS("intersects"), CAST("cast"),
|
CEILING("ceiling"), GEODISTANCE("geo.distance"), GEOLENGTH("geo.length"), GEOINTERSECTS("geo.intersects"),
|
||||||
|
CAST("cast"),
|
||||||
ISOF("isof");
|
ISOF("isof");
|
||||||
|
|
||||||
private String syntax;
|
private String syntax;
|
||||||
|
@ -268,7 +268,7 @@ commonExpr : OPEN commonExpr CLOSE
|
|||||||
| vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult
|
| vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult
|
||||||
| vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd
|
| vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd
|
||||||
| vE1=commonExpr (WSP vO=GT WSP | WSP vO=GE WSP | WSP vO=LT WSP
|
| vE1=commonExpr (WSP vO=GT WSP | WSP vO=GE WSP | WSP vO=LT WSP
|
||||||
| WSP vO=LE WSP | WSP vO=ISOF WSP) vE2=commonExpr #altComparism
|
| WSP vO=LE WSP ) vE2=commonExpr #altComparism
|
||||||
| vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality
|
| vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality
|
||||||
| vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd
|
| vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd
|
||||||
| vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr
|
| vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr
|
||||||
@ -307,7 +307,7 @@ methodCallExpr : indexOfMethodCallExpr
|
|||||||
| roundMethodCallExpr
|
| roundMethodCallExpr
|
||||||
| floorMethodCallExpr
|
| floorMethodCallExpr
|
||||||
| ceilingMethodCallExpr
|
| ceilingMethodCallExpr
|
||||||
| distanceMethodCallExpr
|
| geoDistanceMethodCallExpr
|
||||||
| geoLengthMethodCallExpr
|
| geoLengthMethodCallExpr
|
||||||
| totalOffsetMinutesMethodCallExpr
|
| totalOffsetMinutesMethodCallExpr
|
||||||
| minDateTimeMethodCallExpr
|
| minDateTimeMethodCallExpr
|
||||||
@ -319,7 +319,7 @@ methodCallExpr : indexOfMethodCallExpr
|
|||||||
| endsWithMethodCallExpr
|
| endsWithMethodCallExpr
|
||||||
| startsWithMethodCallExpr
|
| startsWithMethodCallExpr
|
||||||
| containsMethodCallExpr
|
| containsMethodCallExpr
|
||||||
| intersectsMethodCallExpr
|
| geoIntersectsMethodCallExpr
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -354,9 +354,9 @@ roundMethodCallExpr : ROUND_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
|||||||
floorMethodCallExpr : FLOOR_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
floorMethodCallExpr : FLOOR_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
||||||
ceilingMethodCallExpr : CEILING_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
ceilingMethodCallExpr : CEILING_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
||||||
|
|
||||||
distanceMethodCallExpr : GEO_DISTANCE_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
|
geoDistanceMethodCallExpr : GEO_DISTANCE_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
|
||||||
geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE;
|
||||||
intersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
|
geoIntersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
|
||||||
|
|
||||||
isofExpr : ISOF_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
|
isofExpr : ISOF_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
|
||||||
castExpr : CAST_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
|
castExpr : CAST_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.apache.olingo.odata4.producer.core.uri;
|
package org.apache.olingo.odata4.producer.core.uri;
|
||||||
|
|
||||||
|
import org.antlr.v4.runtime.ANTLRErrorListener;
|
||||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||||
import org.antlr.v4.runtime.BailErrorStrategy;
|
import org.antlr.v4.runtime.BailErrorStrategy;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
@ -30,27 +31,29 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
|
|||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
|
||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
static public UriInfo parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor)
|
public UriInfo parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor)
|
||||||
throws UriParserException {
|
throws UriParserException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OdataRelativeUriEOFContext parseTree = parseInput(input, true);
|
OdataRelativeUriEOFContext parseTree = parseInput(input, true);
|
||||||
//reset visitor
|
|
||||||
|
// reset visitor
|
||||||
uriParseTreeVisitor.init();
|
uriParseTreeVisitor.init();
|
||||||
parseTree.accept(uriParseTreeVisitor);
|
parseTree.accept(uriParseTreeVisitor);
|
||||||
UriInfoImpl uriInput = uriParseTreeVisitor.getUriInfo();
|
UriInfoImpl uriInput = uriParseTreeVisitor.getUriInfo();
|
||||||
|
|
||||||
return uriInput;
|
return uriInput;
|
||||||
|
|
||||||
} catch (ParseCancellationException e) {
|
} catch (ParseCancellationException e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause instanceof UriParserException) {
|
if (cause instanceof UriParserException) {
|
||||||
throw (UriParserException) cause;
|
throw (UriParserException) cause;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
throw new UriParserSyntaxException("unknown syntax error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OdataRelativeUriEOFContext parseInput(final String input, boolean onResource)
|
||||||
static private OdataRelativeUriEOFContext parseInput(final String input, boolean onResource)
|
|
||||||
throws UriParserSyntaxException {
|
throws UriParserSyntaxException {
|
||||||
UriParserParser parser = null;
|
UriParserParser parser = null;
|
||||||
UriLexer lexer = null;
|
UriLexer lexer = null;
|
||||||
@ -65,11 +68,11 @@ public class Parser {
|
|||||||
lexer = new UriLexer(new ANTLRInputStream(input));
|
lexer = new UriLexer(new ANTLRInputStream(input));
|
||||||
parser = new UriParserParser(new CommonTokenStream(lexer));
|
parser = new UriParserParser(new CommonTokenStream(lexer));
|
||||||
|
|
||||||
// TODO create better error collector
|
// Set error strategy
|
||||||
parser.addErrorListener(new ErrorCollector());
|
addStage1ErrorStategy(parser);
|
||||||
|
|
||||||
// bail out of parser at first syntax error. --> proceeds in catch block with step 2
|
// Set error collector
|
||||||
parser.setErrorHandler(new BailErrorStrategy());
|
addStage1ErrorListener(parser);
|
||||||
|
|
||||||
// user the faster LL parsing
|
// user the faster LL parsing
|
||||||
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
|
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
|
||||||
@ -80,13 +83,16 @@ public class Parser {
|
|||||||
} catch (ParseCancellationException hardException) {
|
} catch (ParseCancellationException hardException) {
|
||||||
// stage = 2
|
// stage = 2
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// create parser
|
// create parser
|
||||||
lexer = new UriLexer(new ANTLRInputStream(input));
|
lexer = new UriLexer(new ANTLRInputStream(input));
|
||||||
parser = new UriParserParser(new CommonTokenStream(lexer));
|
parser = new UriParserParser(new CommonTokenStream(lexer));
|
||||||
|
|
||||||
// Used default error strategy
|
// Set error strategy
|
||||||
parser.setErrorHandler(new DefaultErrorStrategy());
|
addStage2ErrorStategy(parser);
|
||||||
|
|
||||||
|
// Set error collector
|
||||||
|
addStage2ErrorListener(parser);
|
||||||
|
|
||||||
// Use the slower SLL parsing
|
// Use the slower SLL parsing
|
||||||
parser.getInterpreter().setPredictionMode(PredictionMode.LL);
|
parser.getInterpreter().setPredictionMode(PredictionMode.LL);
|
||||||
@ -106,4 +112,25 @@ public class Parser {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addStage1ErrorStategy(UriParserParser parser) {
|
||||||
|
// Throw exception at first syntax error
|
||||||
|
parser.setErrorHandler(new BailErrorStrategy());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addStage2ErrorStategy(UriParserParser parser) {
|
||||||
|
// Throw exception at first syntax error
|
||||||
|
parser.setErrorHandler(new BailErrorStrategy());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addStage1ErrorListener(UriParserParser parser) {
|
||||||
|
// No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy)
|
||||||
|
parser.removeErrorListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addStage2ErrorListener(UriParserParser parser) {
|
||||||
|
// No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy)
|
||||||
|
parser.removeErrorListeners();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,6 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.Crossjoi
|
|||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CustomQueryOptionContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CustomQueryOptionContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DateMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DateMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DayMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DayMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DistanceMethodCallExprContext;
|
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EndsWithMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EndsWithMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionCastContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionCastContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionContext;
|
||||||
@ -98,12 +97,13 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FilterCo
|
|||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FloorMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FloorMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FormatContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FormatContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FractionalsecondsMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FractionalsecondsMethodCallExprContext;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.GeoDistanceMethodCallExprContext;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.GeoIntersectsMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.GeoLengthMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.GeoLengthMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.HourMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.HourMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IdContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IdContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IndexOfMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IndexOfMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.InlinecountContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.InlinecountContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IntersectsMethodCallExprContext;
|
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IsofExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IsofExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.LengthMethodCallExprContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.LengthMethodCallExprContext;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.LevelsContext;
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.LevelsContext;
|
||||||
@ -186,9 +186,8 @@ import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.TypeLit
|
|||||||
* - Whenever it is possible to move edm validation to the AST classes then
|
* - Whenever it is possible to move edm validation to the AST classes then
|
||||||
* this should be done ( see visit {@link #visitSelectSegment} for example)
|
* this should be done ( see visit {@link #visitSelectSegment} for example)
|
||||||
*
|
*
|
||||||
* Not supported (TODO)
|
* Not supported
|
||||||
* <li>Parsing the context of $metadata
|
* <li>Parsing the context of $metadata
|
||||||
* <li>Evaluation of referential constrains for key predicates
|
|
||||||
*
|
*
|
||||||
* TODO
|
* TODO
|
||||||
* <li>clean up
|
* <li>clean up
|
||||||
@ -382,6 +381,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
UriResourcePart lastResource1 = contextUriInfo.getLastResourcePart();
|
UriResourcePart lastResource1 = contextUriInfo.getLastResourcePart();
|
||||||
|
|
||||||
if (lastResource1 == null) {
|
if (lastResource1 == null) {
|
||||||
|
if (contextTypes.size() == 0) {
|
||||||
|
throw wrap(new UriParserSemanticException("Invalid path segment"));
|
||||||
|
}
|
||||||
source = contextTypes.peek();
|
source = contextTypes.peek();
|
||||||
// sourceType = this.contextTypes.peek().type;
|
// sourceType = this.contextTypes.peek().type;
|
||||||
// sourceCollection = this.contextTypes.peek().isCollection;
|
// sourceCollection = this.contextTypes.peek().isCollection;
|
||||||
@ -735,8 +737,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
binary.setOperator(SupportedBinaryOperators.LT);
|
binary.setOperator(SupportedBinaryOperators.LT);
|
||||||
} else if (tokenIndex == UriLexer.LE) {
|
} else if (tokenIndex == UriLexer.LE) {
|
||||||
binary.setOperator(SupportedBinaryOperators.LE);
|
binary.setOperator(SupportedBinaryOperators.LE);
|
||||||
} else if (tokenIndex == UriLexer.ISOF) {
|
|
||||||
binary.setOperator(SupportedBinaryOperators.ISOF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||||
@ -785,7 +785,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
|
|
||||||
if (tokenIndex == UriLexer.EQ_ALPHA) {
|
if (tokenIndex == UriLexer.EQ_ALPHA) {
|
||||||
binary.setOperator(SupportedBinaryOperators.EQ);
|
binary.setOperator(SupportedBinaryOperators.EQ);
|
||||||
} else if (tokenIndex == UriLexer.NE) {
|
} else {
|
||||||
binary.setOperator(SupportedBinaryOperators.NE);
|
binary.setOperator(SupportedBinaryOperators.NE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,7 +830,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
binary.setOperator(SupportedBinaryOperators.MUL);
|
binary.setOperator(SupportedBinaryOperators.MUL);
|
||||||
} else if (tokenIndex == UriLexer.DIV) {
|
} else if (tokenIndex == UriLexer.DIV) {
|
||||||
binary.setOperator(SupportedBinaryOperators.DIV);
|
binary.setOperator(SupportedBinaryOperators.DIV);
|
||||||
} else if (tokenIndex == UriLexer.MOD) {
|
} else {
|
||||||
binary.setOperator(SupportedBinaryOperators.MOD);
|
binary.setOperator(SupportedBinaryOperators.MOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,9 +1061,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpressionImpl visitDistanceMethodCallExpr(final DistanceMethodCallExprContext ctx) {
|
public ExpressionImpl visitGeoDistanceMethodCallExpr(final GeoDistanceMethodCallExprContext ctx) {
|
||||||
return new MethodCallImpl()
|
return new MethodCallImpl()
|
||||||
.setMethod(SupportedMethodCalls.DISTANCE)
|
.setMethod(SupportedMethodCalls.GEODISTANCE)
|
||||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||||
}
|
}
|
||||||
@ -1349,9 +1349,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpressionImpl visitIntersectsMethodCallExpr(final IntersectsMethodCallExprContext ctx) {
|
public ExpressionImpl visitGeoIntersectsMethodCallExpr(final GeoIntersectsMethodCallExprContext ctx) {
|
||||||
return new MethodCallImpl()
|
return new MethodCallImpl()
|
||||||
.setMethod(SupportedMethodCalls.GEOLENGTH)
|
.setMethod(SupportedMethodCalls.GEOINTERSECTS)
|
||||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||||
}
|
}
|
||||||
@ -1470,12 +1470,17 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
|
|
||||||
// is single key predicate without a name
|
// is single key predicate without a name
|
||||||
String valueText = ctx.vVO.vV.getText();
|
String valueText = ctx.vVO.vV.getText();
|
||||||
ExpressionImpl expression = (ExpressionImpl) ctx.vVO.vV.accept(this);
|
ExpressionImpl expression = null;
|
||||||
|
try {
|
||||||
|
expression = (ExpressionImpl) ctx.vVO.vV.accept(this);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw wrap(new UriParserSemanticException("Invalid key value: " + valueText));
|
||||||
|
}
|
||||||
|
|
||||||
// get type of last resource part
|
// get type of last resource part
|
||||||
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
||||||
if (!(last instanceof UriResourceImplTyped)) {
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
throw wrap(new UriParserSyntaxException("Paramterslist on untyped resource path segement not allowed"));
|
throw wrap(new UriParserSemanticException("Paramterslist on untyped resource path segement not allowed"));
|
||||||
}
|
}
|
||||||
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
||||||
|
|
||||||
@ -1497,14 +1502,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
|
|
||||||
// for using referential constrains the last resource part must be a navigation property
|
// for using referential constrains the last resource part must be a navigation property
|
||||||
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
|
||||||
}
|
}
|
||||||
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
||||||
|
|
||||||
// get the partner of the navigation property
|
// get the partner of the navigation property
|
||||||
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
||||||
if (partner == null) {
|
if (partner == null) {
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the keylist
|
// create the keylist
|
||||||
@ -1522,7 +1527,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
missedKey = item;
|
missedKey = item;
|
||||||
} else {
|
} else {
|
||||||
// two of more keys are missing
|
// two of more keys are missing
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth referntial contrains defined"));
|
throw wrap(new UriParserSemanticException("Not enougth referntial contrains defined"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1538,23 +1543,25 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
for (ParseTree c : ctx.vNVL.vlNVP) {
|
for (ParseTree c : ctx.vNVL.vlNVP) {
|
||||||
list.add((UriParameterImpl) c.accept(this));
|
list.add((UriParameterImpl) c.accept(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contextReadingFunctionParameters){
|
if (contextReadingFunctionParameters) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
||||||
// if the last resource part is a function
|
// if the last resource part is a function
|
||||||
/*if (last instanceof UriResourceFunctionImpl) {
|
/*
|
||||||
UriResourceFunctionImpl function = (UriResourceFunctionImpl) last;
|
* if (last instanceof UriResourceFunctionImpl) {
|
||||||
if (!function.isParameterListFilled()) {
|
* UriResourceFunctionImpl function = (UriResourceFunctionImpl) last;
|
||||||
return list;
|
* if (!function.isParameterListFilled()) {
|
||||||
}
|
* return list;
|
||||||
}*/
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
// get type of last resource part
|
// get type of last resource part
|
||||||
if (!(last instanceof UriResourceImplTyped)) {
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
throw wrap(new UriParserSyntaxException("Parameterslist on untyped resource path segement not allowed"));
|
throw wrap(new UriParserSemanticException("Parameterslist on untyped resource path segement not allowed"));
|
||||||
}
|
}
|
||||||
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
||||||
|
|
||||||
@ -1570,14 +1577,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
|
|
||||||
// for using referential constrains the last resource part must be a navigation property
|
// for using referential constrains the last resource part must be a navigation property
|
||||||
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
|
||||||
}
|
}
|
||||||
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
||||||
|
|
||||||
// get the partner of the navigation property
|
// get the partner of the navigation property
|
||||||
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
||||||
if (partner == null) {
|
if (partner == null) {
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill missing keys from referential constrains
|
// fill missing keys from referential constrains
|
||||||
@ -1604,7 +1611,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
|
||||||
}
|
}
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
@ -1836,13 +1843,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
String odi = ctx.vODI.getText();
|
String odi = ctx.vODI.getText();
|
||||||
if (ctx.vNS == null) {
|
if (ctx.vNS == null) {
|
||||||
|
|
||||||
EdmType prevType = contextSelectItem.getType();
|
EdmType prevType = null;
|
||||||
if (prevType == null) {
|
if (contextSelectItem.getResourceInfo() == null) {
|
||||||
prevType = contextTypes.peek().type;
|
prevType = contextTypes.peek().type;
|
||||||
// add It to selectItem
|
} else {
|
||||||
// UriResourceItImpl it = new UriResourceItImpl();
|
UriInfoImpl uriInfo = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
// it.setType(prevType);
|
UriResourcePart last = uriInfo.getLastResourcePart();
|
||||||
// it.setCollection(this.contextTypes.peek().isCollection);
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
|
throw wrap(new UriParserSemanticException("prev segement typed"));
|
||||||
|
}
|
||||||
|
prevType = getLastType((UriResourceImplTyped) last);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(prevType instanceof EdmStructuralType)) {
|
if (!(prevType instanceof EdmStructuralType)) {
|
||||||
@ -1861,23 +1871,37 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
if (element instanceof EdmProperty) {
|
if (element instanceof EdmProperty) {
|
||||||
EdmProperty property = (EdmProperty) element;
|
EdmProperty property = (EdmProperty) element;
|
||||||
if (property.isPrimitive()) {
|
if (property.isPrimitive()) {
|
||||||
|
|
||||||
UriResourcePrimitivePropertyImpl simple = new UriResourcePrimitivePropertyImpl();
|
UriResourcePrimitivePropertyImpl simple = new UriResourcePrimitivePropertyImpl();
|
||||||
simple.setProperty(property);
|
simple.setProperty(property);
|
||||||
|
|
||||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
UriInfoImpl uriInfo = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
resourcePath.addResourcePart(simple);
|
if (uriInfo== null) {
|
||||||
|
uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||||
|
uriInfo.addResourcePart(simple);
|
||||||
|
contextSelectItem.setResourceInfo(uriInfo);
|
||||||
|
} else {
|
||||||
|
uriInfo.addResourcePart(simple);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
} else {
|
} else {
|
||||||
|
UriInfoImpl uriInfo = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
|
|
||||||
UriResourceComplexPropertyImpl complex = new UriResourceComplexPropertyImpl();
|
UriResourceComplexPropertyImpl complex = new UriResourceComplexPropertyImpl();
|
||||||
complex.setProperty(property);
|
complex.setProperty(property);
|
||||||
|
|
||||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
if (uriInfo== null) {
|
||||||
resourcePath.addResourcePart(complex);
|
uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||||
|
uriInfo.addResourcePart(complex);
|
||||||
|
contextSelectItem.setResourceInfo(uriInfo);
|
||||||
|
} else {
|
||||||
|
uriInfo.addResourcePart(complex);
|
||||||
|
}
|
||||||
|
return this ;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed"));
|
throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed"));
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String namespace = ctx.vNS.getText();
|
String namespace = ctx.vNS.getText();
|
||||||
namespace = namespace.substring(0, namespace.length() - 1);
|
namespace = namespace.substring(0, namespace.length() - 1);
|
||||||
@ -1885,63 +1909,112 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||||||
FullQualifiedName fullName = new FullQualifiedName(namespace, odi);
|
FullQualifiedName fullName = new FullQualifiedName(namespace, odi);
|
||||||
// contextSelectItem.addQualifiedThing(fullName);
|
// contextSelectItem.addQualifiedThing(fullName);
|
||||||
|
|
||||||
EdmType prevType = contextSelectItem.getType();
|
if (contextSelectItem.getResourceInfo() == null) {
|
||||||
if (prevType != null) { // context types required at least one property
|
EdmType prevType = contextTypes.peek().type;
|
||||||
|
|
||||||
|
// check for complex type cast
|
||||||
if (prevType instanceof EdmComplexType) {
|
if (prevType instanceof EdmComplexType) {
|
||||||
EdmComplexType ct = edm.getComplexType(fullName);
|
EdmComplexType ct = edm.getComplexType(fullName);
|
||||||
if (ct != null) {
|
if (ct != null) {
|
||||||
if (((EdmStructuralType) prevType).compatibleTo(ct)) {
|
if ((ct.compatibleTo((EdmStructuralType) prevType))) {
|
||||||
UriResourcePart lastSegment = ((UriInfoImpl) contextSelectItem.getResourceInfo()).getLastResourcePart();
|
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
|
||||||
if (lastSegment instanceof UriResourceImplKeyPred) {
|
resourcePart.setCollectionTypeFilter(ct);
|
||||||
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment;
|
|
||||||
lastKeyPred.setCollectionTypeFilter(ct);
|
|
||||||
} else if (lastSegment instanceof UriResourceImplTyped) {
|
|
||||||
{
|
|
||||||
UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastSegment;
|
|
||||||
lastTyped.setTypeFilter(ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||||
}
|
uriInfo.addResourcePart(resourcePart);
|
||||||
}
|
contextSelectItem.setResourceInfo(uriInfo);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prevType = contextTypes.peek().type;
|
|
||||||
if (prevType instanceof EdmEntityType) {
|
|
||||||
EdmEntityType et = edm.getEntityType(fullName);
|
|
||||||
if (((EdmStructuralType) prevType).compatibleTo(et)) {
|
|
||||||
contextSelectItem.setEntityTypeCast(et);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (prevType instanceof EdmEntityType) {
|
||||||
|
EdmEntityType et = edm.getEntityType(fullName);
|
||||||
|
if (et != null) {
|
||||||
|
if ((et.compatibleTo((EdmStructuralType) prevType))) {
|
||||||
|
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
|
||||||
|
resourcePart.setCollectionTypeFilter(et);
|
||||||
|
|
||||||
|
UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||||
|
uriInfo.addResourcePart(resourcePart);
|
||||||
|
contextSelectItem.setResourceInfo(uriInfo);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FullQualifiedName finalTypeName = new FullQualifiedName(prevType.getNamespace(), prevType.getName());
|
} else {
|
||||||
|
UriInfoImpl uriInfo = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
// check for action
|
UriResourcePart last = uriInfo.getLastResourcePart();
|
||||||
EdmAction action = edm.getAction(fullName, finalTypeName, null);
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
// TODO verify that null ignores if it is a collection
|
throw wrap(new UriParserSemanticException("prev segement typed"));
|
||||||
|
|
||||||
if (action != null) {
|
|
||||||
UriResourceActionImpl uriAction = new UriResourceActionImpl();
|
|
||||||
uriAction.setAction(action);
|
|
||||||
|
|
||||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
|
||||||
resourcePath.addResourcePart(uriAction);
|
|
||||||
}
|
}
|
||||||
|
EdmType prevType = getLastType((UriResourceImplTyped) last);
|
||||||
|
|
||||||
// check for function
|
if (prevType instanceof EdmComplexType) {
|
||||||
EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null);
|
EdmComplexType ct = edm.getComplexType(fullName);
|
||||||
// TODO verify that null ignores if it is a collection
|
if (ct != null) {
|
||||||
|
if ((ct.compatibleTo((EdmStructuralType) prevType))) {
|
||||||
|
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
|
||||||
|
resourcePart.setCollectionTypeFilter(ct);
|
||||||
|
|
||||||
if (function != null) {
|
uriInfo.addResourcePart(resourcePart);
|
||||||
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
|
return this;
|
||||||
uriFunction.setFunction(function);
|
}
|
||||||
|
}
|
||||||
|
} else if (prevType instanceof EdmEntityType) {
|
||||||
|
throw wrap(new UriParserSemanticException("Error"));
|
||||||
|
/*EdmEntityType et = edm.getEntityType(fullName);
|
||||||
|
if (et != null) {
|
||||||
|
if ((et.compatibleTo((EdmStructuralType) prevType))) {
|
||||||
|
UriResourceStartingTypeFilterImpl resourcePart = new UriResourceStartingTypeFilterImpl();
|
||||||
|
resourcePart.setEntryTypeFilter(et);
|
||||||
|
|
||||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
uriInfo.addResourcePart(resourcePart);
|
||||||
resourcePath.addResourcePart(uriFunction);
|
return this;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
} else {
|
||||||
|
throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EdmType prevType = null;
|
||||||
|
if (contextSelectItem.getResourceInfo() == null) {
|
||||||
|
prevType = contextTypes.peek().type;
|
||||||
|
} else {
|
||||||
|
UriInfoImpl uriInfo = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
|
UriResourcePart last = uriInfo.getLastResourcePart();
|
||||||
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
|
throw wrap(new UriParserSemanticException("prev segement typed"));
|
||||||
|
}
|
||||||
|
prevType = getLastType((UriResourceImplTyped) last);
|
||||||
|
}
|
||||||
|
|
||||||
|
FullQualifiedName finalTypeName = new FullQualifiedName(prevType.getNamespace(), prevType.getName());
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
uriAction.setAction(action);
|
||||||
|
|
||||||
|
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
|
resourcePath.addResourcePart(uriAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
uriFunction.setFunction(function);
|
||||||
|
|
||||||
|
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
|
||||||
|
resourcePath.addResourcePart(uriFunction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -37,44 +36,18 @@ public class SelectItemImpl implements SelectItem {
|
|||||||
|
|
||||||
private UriInfoResource path;
|
private UriInfoResource path;
|
||||||
|
|
||||||
private List<UriResourcePartImpl> parts = new ArrayList<UriResourcePartImpl>();
|
|
||||||
private boolean isStar;
|
private boolean isStar;
|
||||||
private FullQualifiedName addOperationsInSchemaNameSpace;
|
private FullQualifiedName addOperationsInSchemaNameSpace;
|
||||||
private EdmEntityType entityTypeCast;
|
|
||||||
|
|
||||||
public EdmType getType() {
|
@Override
|
||||||
UriInfoImpl uriInfo = (UriInfoImpl) path;
|
public UriInfoResource getResourceInfo() {
|
||||||
UriResourcePartImpl lastResourcePart = null;
|
|
||||||
if (uriInfo != null) {
|
|
||||||
lastResourcePart = (UriResourcePartImpl) uriInfo.getLastResourcePart();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastResourcePart instanceof UriResourceImplKeyPred) {
|
return path;
|
||||||
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastResourcePart;
|
|
||||||
if (lastKeyPred.getTypeFilterOnEntry() != null) {
|
|
||||||
return lastKeyPred.getTypeFilterOnEntry();
|
|
||||||
} else if (lastKeyPred.getTypeFilterOnCollection() != null) {
|
|
||||||
return lastKeyPred.getTypeFilterOnCollection();
|
|
||||||
}
|
|
||||||
return lastKeyPred.getType();
|
|
||||||
} else if (lastResourcePart instanceof UriResourceImplTyped) {
|
|
||||||
UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastResourcePart;
|
|
||||||
EdmType type = lastTyped.getTypeFilter();
|
|
||||||
if (type != null) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
return lastTyped.getType();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public SelectItemImpl setResourceInfo(UriInfoResource path) {
|
||||||
public UriInfoResource getResourceInfo() {
|
this.path = path;
|
||||||
if (this.path == null) {
|
return this;
|
||||||
this.path = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -104,15 +77,6 @@ public class SelectItemImpl implements SelectItem {
|
|||||||
public void addAllOperationsInSchema(final FullQualifiedName addOperationsInSchemaNameSpace) {
|
public void addAllOperationsInSchema(final FullQualifiedName addOperationsInSchemaNameSpace) {
|
||||||
this.addOperationsInSchemaNameSpace = addOperationsInSchemaNameSpace;
|
this.addOperationsInSchemaNameSpace = addOperationsInSchemaNameSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EdmEntityType getEntityTypeCast() {
|
|
||||||
return entityTypeCast;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SelectItemImpl setEntityTypeCast(final EdmEntityType entityTypeCast) {
|
|
||||||
this.entityTypeCast = entityTypeCast;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,17 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||||
|
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||||
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
|
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem;
|
||||||
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
|
||||||
|
|
||||||
public class ExpandValidator implements Validator {
|
public class ExpandValidator implements Validator {
|
||||||
private Edm edm;
|
private Edm edm;
|
||||||
@ -73,6 +76,21 @@ public class ExpandValidator implements Validator {
|
|||||||
.setUriInfoImplPath(uriInfo);
|
.setUriInfoImplPath(uriInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriResourceValidator goSelectItemPath(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
UriInfoImpl uriInfo = (UriInfoImpl) item.getResourceInfo();
|
||||||
|
|
||||||
|
return new UriResourceValidator()
|
||||||
|
.setUpValidator(this)
|
||||||
|
.setEdm(edm)
|
||||||
|
.setUriInfoImplPath(uriInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ExpandValidator goExpand() {
|
public ExpandValidator goExpand() {
|
||||||
ExpandValidator val = new ExpandValidator();
|
ExpandValidator val = new ExpandValidator();
|
||||||
@ -147,6 +165,23 @@ public class ExpandValidator implements Validator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExpandValidator isSelectItemStar(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(true, item.isStar());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpandValidator isSelectItemAllOp(final int index, FullQualifiedName fqn) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ExpandValidator isFilterText(final String text) {
|
public ExpandValidator isFilterText(final String text) {
|
||||||
QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
|
QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
|
||||||
assertEquals(text, option.getText());
|
assertEquals(text, option.getText());
|
||||||
|
@ -29,6 +29,7 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
|||||||
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
|
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriInfo;
|
import org.apache.olingo.odata4.producer.api.uri.UriInfo;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||||
|
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Member;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Member;
|
||||||
@ -39,6 +40,9 @@ import org.apache.olingo.odata4.producer.core.uri.Parser;
|
|||||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSemanticException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSyntaxException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl;
|
||||||
@ -60,6 +64,8 @@ public class FilterValidator implements Validator {
|
|||||||
|
|
||||||
private OrderByOptionImpl orderBy;
|
private OrderByOptionImpl orderBy;
|
||||||
|
|
||||||
|
private UriParserException exception;
|
||||||
|
|
||||||
// --- Setup ---
|
// --- Setup ---
|
||||||
public FilterValidator setUriResourcePathValidator(final UriResourceValidator uriResourcePathValidator) {
|
public FilterValidator setUriResourcePathValidator(final UriResourceValidator uriResourcePathValidator) {
|
||||||
invokedByValidator = uriResourcePathValidator;
|
invokedByValidator = uriResourcePathValidator;
|
||||||
@ -108,6 +114,11 @@ public class FilterValidator implements Validator {
|
|||||||
String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
|
String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
|
||||||
return runUriOrderBy(uri);
|
return runUriOrderBy(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterValidator runOrderByOnETTwoKeyNavEx(final String orderBy) throws UriParserException {
|
||||||
|
String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
|
||||||
|
return runUriOrderByEx(uri);
|
||||||
|
}
|
||||||
|
|
||||||
public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
|
public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
|
||||||
// TODO change to ESTwoKeyNav
|
// TODO change to ESTwoKeyNav
|
||||||
@ -115,6 +126,12 @@ public class FilterValidator implements Validator {
|
|||||||
return runUri(uri);
|
return runUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException {
|
||||||
|
// TODO change to ESTwoKeyNav
|
||||||
|
String uri = "SINav?$filter=" + filter.trim();
|
||||||
|
return runUriEx(uri);
|
||||||
|
}
|
||||||
|
|
||||||
public FilterValidator runOnETAllPrim(final String filter) throws UriParserException {
|
public FilterValidator runOnETAllPrim(final String filter) throws UriParserException {
|
||||||
String uri = "ESAllPrim(1)?$filter=" + filter.trim();
|
String uri = "ESAllPrim(1)?$filter=" + filter.trim();
|
||||||
return runUri(uri);
|
return runUri(uri);
|
||||||
@ -124,6 +141,11 @@ public class FilterValidator implements Validator {
|
|||||||
String uri = "ESKeyNav(1)?$filter=" + filter.trim();
|
String uri = "ESKeyNav(1)?$filter=" + filter.trim();
|
||||||
return runUri(uri);
|
return runUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterValidator runOnETKeyNavEx(final String filter) throws UriParserException {
|
||||||
|
String uri = "ESKeyNav(1)?$filter=" + filter.trim();
|
||||||
|
return runUriEx(uri);
|
||||||
|
}
|
||||||
|
|
||||||
public FilterValidator runOnCTTwoPrim(final String filter) throws UriParserException {
|
public FilterValidator runOnCTTwoPrim(final String filter) throws UriParserException {
|
||||||
String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim();
|
String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim();
|
||||||
@ -161,9 +183,30 @@ public class FilterValidator implements Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FilterValidator runUri(final String uri) throws UriParserException {
|
public FilterValidator runUri(final String uri) throws UriParserException {
|
||||||
|
Parser parser = new Parser();
|
||||||
UriInfo uriInfo = null;
|
UriInfo uriInfo = null;
|
||||||
|
|
||||||
uriInfo = Parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
uriInfo = parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
|
||||||
|
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||||
|
fail("Filtervalidator can only be used on resourcePaths");
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilter((FilterOptionImpl) uriInfo.getFilterOption());
|
||||||
|
curExpression = filter.getExpression();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterValidator runUriEx(final String uri) {
|
||||||
|
Parser parser = new Parser();
|
||||||
|
UriInfo uriInfo = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
uriInfo = parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
} catch (UriParserException e) {
|
||||||
|
this.exception = e;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||||
fail("Filtervalidator can only be used on resourcePaths");
|
fail("Filtervalidator can only be used on resourcePaths");
|
||||||
@ -175,9 +218,10 @@ public class FilterValidator implements Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FilterValidator runUriOrderBy(final String uri) throws UriParserException {
|
public FilterValidator runUriOrderBy(final String uri) throws UriParserException {
|
||||||
|
Parser parser = new Parser();
|
||||||
UriInfo uriInfo = null;
|
UriInfo uriInfo = null;
|
||||||
|
|
||||||
uriInfo = Parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
uriInfo = parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
|
||||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||||
fail("Filtervalidator can only be used on resourcePaths");
|
fail("Filtervalidator can only be used on resourcePaths");
|
||||||
@ -186,6 +230,26 @@ public class FilterValidator implements Validator {
|
|||||||
setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
|
setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterValidator runUriOrderByEx(final String uri) {
|
||||||
|
Parser parser = new Parser();
|
||||||
|
UriInfo uriInfo = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
uriInfo = parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
} catch (UriParserException e) {
|
||||||
|
this.exception = e;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||||
|
fail("Filtervalidator can only be used on resourcePaths");
|
||||||
|
}
|
||||||
|
|
||||||
|
setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- Navigation ---
|
// --- Navigation ---
|
||||||
|
|
||||||
@ -327,6 +391,7 @@ public class FilterValidator implements Validator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
|
public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
|
||||||
throws ExceptionVisitExpression, ODataApplicationException {
|
throws ExceptionVisitExpression, ODataApplicationException {
|
||||||
|
|
||||||
@ -415,4 +480,14 @@ public class FilterValidator implements Validator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FilterValidator isExSyntax(long errorID) {
|
||||||
|
assertEquals(UriParserSyntaxException.class, exception.getClass());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterValidator isExSemantic(long errorID) {
|
||||||
|
assertEquals(UriParserSemanticException.class, exception.getClass());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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.producer.core.testutil;
|
||||||
|
|
||||||
|
import org.antlr.v4.runtime.DefaultErrorStrategy;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.Parser;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
|
||||||
|
|
||||||
|
public class ParserTest extends Parser {
|
||||||
|
TestErrorLogger errorCollector1;
|
||||||
|
TestErrorLogger errorCollector2;
|
||||||
|
|
||||||
|
public ParserTest() {
|
||||||
|
errorCollector1 = new TestErrorLogger("Stage 1", 1);
|
||||||
|
errorCollector2 = new TestErrorLogger("Stage 2", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addStage2ErrorStategy(UriParserParser parser) {
|
||||||
|
// Don't throw an at first syntax error, so the error listener will be called
|
||||||
|
parser.setErrorHandler(new DefaultErrorStrategy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addStage1ErrorListener(UriParserParser parser) {
|
||||||
|
// Log error to console
|
||||||
|
parser.removeErrorListeners();
|
||||||
|
parser.addErrorListener(errorCollector1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addStage2ErrorListener(UriParserParser parser) {
|
||||||
|
// Log error to console
|
||||||
|
parser.removeErrorListeners();
|
||||||
|
parser.addErrorListener(errorCollector2);
|
||||||
|
}
|
||||||
|
}
|
@ -16,9 +16,8 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.apache.olingo.odata4.producer.core.uri;
|
package org.apache.olingo.odata4.producer.core.testutil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,11 +29,15 @@ import org.antlr.v4.runtime.Recognizer;
|
|||||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||||
import org.antlr.v4.runtime.dfa.DFA;
|
import org.antlr.v4.runtime.dfa.DFA;
|
||||||
|
|
||||||
class ErrorCollector implements ANTLRErrorListener {
|
class TestErrorLogger implements ANTLRErrorListener {
|
||||||
|
|
||||||
private List<Exception> exceptions = new ArrayList<Exception>();
|
private String prefix;
|
||||||
|
private int logLevel = 0;
|
||||||
|
|
||||||
// private ParserValidator tokenValidator;
|
public TestErrorLogger(String prefix, int logLevel) {
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.logLevel = logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
|
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
|
||||||
@ -42,12 +45,11 @@ class ErrorCollector implements ANTLRErrorListener {
|
|||||||
final String msg, final RecognitionException e) {
|
final String msg, final RecognitionException e) {
|
||||||
|
|
||||||
// Collect the exception
|
// Collect the exception
|
||||||
// TODO needs to be improved
|
if (logLevel > 0) {
|
||||||
exceptions.add(e);
|
System.out.println("\n" + prefix + " -- SyntaxError");
|
||||||
System.out.println("syntaxError");
|
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||||
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
}
|
||||||
|
|
||||||
// fail("syntaxError");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,7 +124,7 @@ class ErrorCollector implements ANTLRErrorListener {
|
|||||||
public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
|
public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
|
||||||
final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
|
final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
|
||||||
|
|
||||||
System.err.println("-");
|
System.out.println("Error message: " + msg);
|
||||||
// TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
|
// TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
|
||||||
|
|
||||||
printStack(recognizer);
|
printStack(recognizer);
|
||||||
@ -137,11 +139,36 @@ class ErrorCollector implements ANTLRErrorListener {
|
|||||||
} catch (ArrayIndexOutOfBoundsException es) {
|
} catch (ArrayIndexOutOfBoundsException es) {
|
||||||
lexerTokenName = "token error";
|
lexerTokenName = "token error";
|
||||||
}
|
}
|
||||||
System.err.println(" line " + line + ":" + charPositionInLine + " at " +
|
System.out.println(" line " + line + ":" + charPositionInLine + " at " +
|
||||||
offendingSymbol + "/" + lexerTokenName + ": " + msg);
|
offendingSymbol + "/" + lexerTokenName + ": " + msg);
|
||||||
} else {
|
} else {
|
||||||
System.err.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
|
System.out.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDecisionRule(Recognizer<?, ?> recognizer, int decision) {
|
||||||
|
if (recognizer == null || decision < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decision >= recognizer.getATN().decisionToState.size()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return recognizer.getATN().decisionToState.get(decision).ruleIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRuleDisplayName(Recognizer<?, ?> recognizer, int ruleIndex) {
|
||||||
|
if (recognizer == null || ruleIndex < 0) {
|
||||||
|
return Integer.toString(ruleIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] ruleNames = recognizer.getRuleNames();
|
||||||
|
if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
|
||||||
|
return Integer.toString(ruleIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ruleNames[ruleIndex];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -34,8 +34,8 @@ import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
|||||||
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
|
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
||||||
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.Parser;
|
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
||||||
@ -53,6 +53,7 @@ import org.apache.olingo.odata4.producer.core.uri.UriResourcePrimitivePropertyIm
|
|||||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceSingletonImpl;
|
import org.apache.olingo.odata4.producer.core.uri.UriResourceSingletonImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
|
||||||
|
|
||||||
public class UriResourceValidator implements Validator {
|
public class UriResourceValidator implements Validator {
|
||||||
@ -84,10 +85,11 @@ public class UriResourceValidator implements Validator {
|
|||||||
// --- Execution ---
|
// --- Execution ---
|
||||||
|
|
||||||
public UriResourceValidator run(final String uri) {
|
public UriResourceValidator run(final String uri) {
|
||||||
|
ParserTest testParser = new ParserTest();
|
||||||
UriInfoImpl uriInfoTmp = null;
|
UriInfoImpl uriInfoTmp = null;
|
||||||
uriPathInfo = null;
|
uriPathInfo = null;
|
||||||
try {
|
try {
|
||||||
uriInfoTmp = (UriInfoImpl) Parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
} catch (UriParserException e) {
|
} catch (UriParserException e) {
|
||||||
fail("Exception occured while parsing the URI: " + uri + "\n"
|
fail("Exception occured while parsing the URI: " + uri + "\n"
|
||||||
+ " Exception: " + e.getMessage());
|
+ " Exception: " + e.getMessage());
|
||||||
@ -146,6 +148,19 @@ public class UriResourceValidator implements Validator {
|
|||||||
assertEquals(var, actualVar);
|
assertEquals(var, actualVar);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriResourceValidator goSelectItemPath(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
|
||||||
|
|
||||||
|
return new UriResourceValidator()
|
||||||
|
.setUpValidator(this)
|
||||||
|
.setEdm(edm)
|
||||||
|
.setUriInfoImplPath(uriInfo1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ExpandValidator goExpand() {
|
public ExpandValidator goExpand() {
|
||||||
ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
|
ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
|
||||||
@ -369,6 +384,20 @@ public class UriResourceValidator implements Validator {
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriResourceValidator isParameterAlias(final int index, final String name, final String alias) {
|
||||||
|
if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
|
||||||
|
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
|
||||||
|
List<UriParameter> keyPredicates = info.getParameters();
|
||||||
|
assertEquals(name, keyPredicates.get(index).getName());
|
||||||
|
assertEquals(alias, keyPredicates.get(index).getAlias());
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public UriResourceValidator isKind(final UriInfoKind kind) {
|
public UriResourceValidator isKind(final UriInfoKind kind) {
|
||||||
assertEquals(kind, uriInfo.getKind());
|
assertEquals(kind, uriInfo.getKind());
|
||||||
@ -513,5 +542,21 @@ public class UriResourceValidator implements Validator {
|
|||||||
assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
|
assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriResourceValidator isSelectItemStar(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(true, item.isStar());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriResourceValidator isSelectItemAllOp(final int index, FullQualifiedName fqn) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,23 @@ import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
|||||||
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
||||||
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.Parser;
|
import org.apache.olingo.odata4.producer.core.uri.Parser;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSemanticException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSyntaxException;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
|
||||||
|
|
||||||
public class UriValidator implements Validator {
|
public class UriValidator implements Validator {
|
||||||
private Edm edm;
|
private Edm edm;
|
||||||
|
|
||||||
private UriInfoImpl uriInfo;
|
private UriInfoImpl uriInfo;
|
||||||
|
private Exception exception;
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
public UriValidator setEdm(final Edm edm) {
|
public UriValidator setEdm(final Edm edm) {
|
||||||
@ -48,10 +54,40 @@ public class UriValidator implements Validator {
|
|||||||
|
|
||||||
// Execution
|
// Execution
|
||||||
public UriValidator run(final String uri) {
|
public UriValidator run(final String uri) {
|
||||||
|
Parser parser = new Parser();
|
||||||
uriInfo = null;
|
uriInfo = null;
|
||||||
try {
|
try {
|
||||||
// uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
|
// uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
|
||||||
uriInfo = (UriInfoImpl) Parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
uriInfo = (UriInfoImpl) parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
} catch (UriParserException e) {
|
||||||
|
fail("Exception occured while parsing the URI: " + uri + "\n"
|
||||||
|
+ " Exception: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriValidator runEx(final String uri) {
|
||||||
|
Parser parser = new Parser();
|
||||||
|
uriInfo = null;
|
||||||
|
try {
|
||||||
|
// uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
|
||||||
|
uriInfo = (UriInfoImpl) parser.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
|
||||||
|
} catch (UriParserException e) {
|
||||||
|
exception = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriValidator log(final String uri) {
|
||||||
|
ParserTest parserTest = new ParserTest();
|
||||||
|
uriInfo = null;
|
||||||
|
try {
|
||||||
|
// uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
|
||||||
|
uriInfo = (UriInfoImpl) parserTest.parseUri(uri, new UriParseTreeVisitor(edm));
|
||||||
|
fail("Exception expected");
|
||||||
} catch (UriParserException e) {
|
} catch (UriParserException e) {
|
||||||
fail("Exception occured while parsing the URI: " + uri + "\n"
|
fail("Exception occured while parsing the URI: " + uri + "\n"
|
||||||
+ " Exception: " + e.getMessage());
|
+ " Exception: " + e.getMessage());
|
||||||
@ -80,6 +116,29 @@ public class UriValidator implements Validator {
|
|||||||
return new FilterValidator().setUriValidator(this).setFilter(filter);
|
return new FilterValidator().setUriValidator(this).setFilter(filter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExpandValidator goExpand() {
|
||||||
|
ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
|
||||||
|
if (expand == null) {
|
||||||
|
fail("invalid resource kind: " + uriInfo.getKind().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ExpandValidator().setGoUpValidator(this).setExpand(expand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public UriResourceValidator goSelectItemPath(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
|
||||||
|
|
||||||
|
return new UriResourceValidator()
|
||||||
|
.setUpValidator(this)
|
||||||
|
.setEdm(edm)
|
||||||
|
.setUriInfoImplPath(uriInfo1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
public UriValidator isKind(final UriInfoKind kind) {
|
public UriValidator isKind(final UriInfoKind kind) {
|
||||||
@ -116,36 +175,43 @@ public class UriValidator implements Validator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriValidator isExSyntax(long errorID) {
|
||||||
|
assertEquals(UriParserSyntaxException.class, exception.getClass());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriValidator isExSemantic(long errorID) {
|
||||||
|
assertEquals(UriParserSemanticException.class, exception.getClass());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public UriValidator isIdText(final String text) {
|
public UriValidator isIdText(final String text) {
|
||||||
assertEquals(text, uriInfo.getIdOption().getText());
|
assertEquals(text, uriInfo.getIdOption().getText());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UriValidator isExpandText(final String text) {
|
public UriValidator isExpandText(final String text) {
|
||||||
assertEquals(text, uriInfo.getExpandOption().getText());
|
assertEquals(text, uriInfo.getExpandOption().getText());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UriValidator isSelectText(final String text) {
|
public UriValidator isSelectText(final String text) {
|
||||||
assertEquals(text, uriInfo.getSelectOption().getText());
|
assertEquals(text, uriInfo.getSelectOption().getText());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UriValidator isFormatText(final String text) {
|
public UriValidator isFormatText(final String text) {
|
||||||
assertEquals(text, uriInfo.getFormatOption().getText());
|
assertEquals(text, uriInfo.getFormatOption().getText());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UriValidator isFragmentText(final String text) {
|
public UriValidator isFragmentText(final String text) {
|
||||||
if (uriInfo.getKind() != UriInfoKind.metadata) {
|
if (uriInfo.getKind() != UriInfoKind.metadata) {
|
||||||
fail("invalid resource kind: " + uriInfo.getKind().toString());
|
fail("invalid resource kind: " + uriInfo.getKind().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(text, uriInfo.getFragment());
|
assertEquals(text, uriInfo.getFragment());
|
||||||
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,5 +227,21 @@ public class UriValidator implements Validator {
|
|||||||
private String fullName(final EdmEntityType type) {
|
private String fullName(final EdmEntityType type) {
|
||||||
return type.getNamespace() + "." + type.getName();
|
return type.getNamespace() + "." + type.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UriValidator isSelectItemStar(final int index) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(true, item.isStar());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriValidator isSelectItemAllOp(final int index, FullQualifiedName fqn) {
|
||||||
|
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||||
|
|
||||||
|
SelectItem item = select.getSelectItems().get(index);
|
||||||
|
assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.apache.olingo.odata4.producer.core.uri.antlr;
|
package org.apache.olingo.odata4.producer.core.uri.antlr;
|
||||||
|
|
||||||
// sync 20.1.2014
|
import java.net.URISyntaxException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||||
@ -36,6 +36,8 @@ import org.apache.olingo.odata4.producer.core.testutil.FilterValidator;
|
|||||||
import org.apache.olingo.odata4.producer.core.testutil.UriResourceValidator;
|
import org.apache.olingo.odata4.producer.core.testutil.UriResourceValidator;
|
||||||
import org.apache.olingo.odata4.producer.core.testutil.UriValidator;
|
import org.apache.olingo.odata4.producer.core.testutil.UriValidator;
|
||||||
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSemanticException;
|
||||||
|
import org.apache.olingo.odata4.producer.core.uri.UriParserSyntaxException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestFullResourcePath {
|
public class TestFullResourcePath {
|
||||||
@ -52,16 +54,7 @@ public class TestFullResourcePath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {}
|
||||||
testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath()
|
|
||||||
.at(0)
|
|
||||||
.isUriPathInfoKind(UriResourceKind.entitySet)
|
|
||||||
.isType(EdmTechProvider.nameETTwoKeyNav)
|
|
||||||
.isCollection(true)
|
|
||||||
.at(1)
|
|
||||||
.isUriPathInfoKind(UriResourceKind.function)
|
|
||||||
.isType(EdmTechProvider.nameETTwoKeyNav);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFunctionBound_varOverloading() {
|
public void testFunctionBound_varOverloading() {
|
||||||
@ -96,8 +89,6 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameETTwoKeyNav);
|
.isType(EdmTechProvider.nameETTwoKeyNav);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DONE
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runBfuncBnCpropCastRtEs() {
|
public void runBfuncBnCpropCastRtEs() {
|
||||||
|
|
||||||
@ -915,11 +906,10 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runCrossjoinError() {
|
public void runCrossjoinError() {
|
||||||
// testUri.run("$crossjoin");
|
testUri.runEx("$crossjoin").isExSyntax(0);
|
||||||
// testUri.run("$crossjoin/error");
|
testUri.runEx("$crossjoin/error").isExSyntax(0);
|
||||||
// testUri.run("$crossjoin()");
|
testUri.runEx("$crossjoin()").isExSyntax(0);
|
||||||
// testUri.run("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid");
|
testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0);
|
||||||
// testUri.run("$crossjoin(invalidEntitySet)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -935,12 +925,10 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runEntityIdError() {
|
public void runEntityIdError() {
|
||||||
// entity_id_error
|
testUri.runEx("$entity").isExSyntax(0);
|
||||||
|
testUri.runEx("$entity?$idfalse=ESKeyNav(1)").isExSyntax(0);
|
||||||
// testUri.run("$entity");
|
testUri.runEx("$entity/com.sap.odata.test1.invalidType?$id=ESKeyNav(1)").isExSemantic(0);
|
||||||
// testUri.run("$entity?$idfalse=ESKeyNav(1)");
|
testUri.runEx("$entity/invalid?$id=ESKeyNav(1)").isExSyntax(0);
|
||||||
// testUri.run("$entity/com.sap.odata.test1.invalidType?$id=ESKeyNav(1)");
|
|
||||||
// testUri.run("$entity/invalid?$id=ESKeyNav(1)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -963,27 +951,43 @@ public class TestFullResourcePath {
|
|||||||
@Test
|
@Test
|
||||||
public void runEsNameError() {
|
public void runEsNameError() {
|
||||||
|
|
||||||
// testUri.run("ESAllPrim/$count/$ref");
|
testUri.runEx("ESAllPrim/$count/$ref").isExSyntax(0);
|
||||||
// testUri.run("ESAllPrim/$ref/$count");
|
testUri.runEx("ESAllPrim/$ref/$count").isExSyntax(0);
|
||||||
// testUri.run("ESAllPrim/$ref/invalid");
|
testUri.runEx("ESAllPrim/$ref/invalid").isExSyntax(0);
|
||||||
// testUri.run("ESAllPrim/$count/invalid");
|
testUri.runEx("ESAllPrim/$count/invalid").isExSyntax(0);
|
||||||
// testUri.run("ESAllPrim(1)/whatever");
|
testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(0);
|
||||||
// testUri.run("ESAllPrim(PropertyInt16='1')");
|
testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0);
|
||||||
// testUri.run("ESAllPrim(PropertyInt16)");
|
testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(0);
|
||||||
// testUri.run("ESAllPrim(PropertyInt16=)");
|
testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(0);
|
||||||
// testUri.run("ESAllPrim(PropertyInt16=1,Invalid='1')");
|
testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(0);
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
|
||||||
// +"/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim");
|
testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETAllKey");
|
+ "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim").isExSemantic(0);
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim('1')/com.sap.odata.test1.ETAllKey");
|
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETAllKey")
|
||||||
// +"/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim");
|
.isExSemantic(0);
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
|
||||||
// +"/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim(1)");
|
testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim('1')/com.sap.odata.test1.ETAllKey")
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETAllKey");
|
.isExSemantic(0);
|
||||||
// testUri.run("ETBaseTwoKeyTwoPrim()");
|
|
||||||
// testUri.run("ESAllNullable(1)/CollPropertyString/$value");
|
testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
||||||
// testUri.run("ETMixPrimCollComp(1)/ComplexProperty/$value");
|
+ "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim")
|
||||||
|
.isExSemantic(0);
|
||||||
|
|
||||||
|
testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
|
||||||
|
+ "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim(1)")
|
||||||
|
.isExSemantic(0);
|
||||||
|
|
||||||
|
testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETAllKey")
|
||||||
|
.isExSemantic(0);
|
||||||
|
|
||||||
|
testUri.runEx("ETBaseTwoKeyTwoPrim()")
|
||||||
|
.isExSemantic(0);
|
||||||
|
|
||||||
|
testUri.runEx("ESAllNullable(1)/CollPropertyString/$value")
|
||||||
|
.isExSemantic(0);
|
||||||
|
|
||||||
|
testUri.runEx("ETMixPrimCollComp(1)/ComplexProperty/$value").isExSemantic(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1107,9 +1111,15 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runEsNameKeyCast() {
|
public void runEsNameKeyCast() {
|
||||||
// testUri.run("xESTwoPrim(1)/com.sap.odata.test1.ETBase(1)");
|
|
||||||
// testUri.run("xESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)");
|
testUri.runEx("xESTwoPrim(1)/com.sap.odata.test1.ETBase(1)")
|
||||||
// testUri.run("xESBase/com.sap.odata.test1.ETTwoPrim(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.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase")
|
testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase")
|
||||||
.isKind(UriInfoKind.resource).goPath()
|
.isKind(UriInfoKind.resource).goPath()
|
||||||
@ -1801,11 +1811,8 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runFunctionImpError() {
|
public void runFunctionImpError() {
|
||||||
/*
|
testUri.runEx("FICRTCollCTTwoPrimParam()").isExSemantic(0);
|
||||||
* testUri.run("FICRTCollCTTwoPrimParam()");
|
testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)").isExSemantic(0);
|
||||||
* testUri.run("FICRTCollCTTwoPrimParam(invalidParam=2)");
|
|
||||||
* testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16='1',ParameterString='2')");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -2244,7 +2251,8 @@ public class TestFullResourcePath {
|
|||||||
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true)
|
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true)
|
||||||
.isType(EdmTechProvider.nameETKeyNav, true)
|
.isType(EdmTechProvider.nameETKeyNav, true)
|
||||||
.goUpExpandValidator()
|
.goUpExpandValidator()
|
||||||
.isSelectText("PropertyString");
|
.isSelectText("PropertyString")
|
||||||
|
.goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETTwoKeyNavOne)")
|
testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETTwoKeyNavOne)")
|
||||||
.isKind(UriInfoKind.resource).goPath().goExpand()
|
.isKind(UriInfoKind.resource).goPath().goExpand()
|
||||||
@ -2284,7 +2292,8 @@ public class TestFullResourcePath {
|
|||||||
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true)
|
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true)
|
||||||
.isType(EdmTechProvider.nameETKeyNav, true)
|
.isType(EdmTechProvider.nameETKeyNav, true)
|
||||||
.goUpExpandValidator()
|
.goUpExpandValidator()
|
||||||
.isSelectText("PropertyString");
|
.isSelectText("PropertyString")
|
||||||
|
.goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=max)")
|
testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=max)")
|
||||||
.isKind(UriInfoKind.resource).goPath().goExpand()
|
.isKind(UriInfoKind.resource).goPath().goExpand()
|
||||||
@ -2427,7 +2436,8 @@ public class TestFullResourcePath {
|
|||||||
.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
||||||
.isType(EdmTechProvider.nameETTwoKeyNav)
|
.isType(EdmTechProvider.nameETTwoKeyNav)
|
||||||
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav)
|
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav)
|
||||||
.goUpExpandValidator(); // TODO check select
|
.goUpExpandValidator()
|
||||||
|
.goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($expand=NavPropertyETKeyNavMany("
|
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($expand=NavPropertyETKeyNavMany("
|
||||||
+ "$expand=NavPropertyETKeyNavOne))")
|
+ "$expand=NavPropertyETKeyNavOne))")
|
||||||
@ -2455,8 +2465,9 @@ public class TestFullResourcePath {
|
|||||||
.goPath().first()
|
.goPath().first()
|
||||||
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
|
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
|
||||||
.isType(EdmTechProvider.nameETKeyNav)
|
.isType(EdmTechProvider.nameETKeyNav)
|
||||||
.goUpExpandValidator();
|
.goUpExpandValidator()
|
||||||
// .isSelectText("PropertyInt16") //TODO check select
|
.isSelectText("PropertyInt16")
|
||||||
|
.goSelectItemPath(0).isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false);
|
||||||
|
|
||||||
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyComplex/PropertyInt16)")
|
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyComplex/PropertyInt16)")
|
||||||
.isKind(UriInfoKind.resource)
|
.isKind(UriInfoKind.resource)
|
||||||
@ -2465,8 +2476,8 @@ public class TestFullResourcePath {
|
|||||||
.goPath().first()
|
.goPath().first()
|
||||||
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
|
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
|
||||||
.isType(EdmTechProvider.nameETKeyNav)
|
.isType(EdmTechProvider.nameETKeyNav)
|
||||||
.goUpExpandValidator();
|
.goUpExpandValidator()
|
||||||
// .isSelectText("PropertyInt16")//TODO check select
|
.isSelectText("PropertyComplex/PropertyInt16");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -2517,7 +2528,8 @@ public class TestFullResourcePath {
|
|||||||
testUri.run("ESAllPrim?$count=false")
|
testUri.run("ESAllPrim?$count=false")
|
||||||
.isKind(UriInfoKind.resource).goPath()
|
.isKind(UriInfoKind.resource).goPath()
|
||||||
.isInlineCountText("false");
|
.isInlineCountText("false");
|
||||||
// testUri.run("ESAllPrim?$count=foo");
|
|
||||||
|
testUri.runEx("ESAllPrim?$count=foo").isExSyntax(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -2756,12 +2768,6 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSpecial() {
|
|
||||||
// testFilter.runOnETKeyNav("any()");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilter() throws UriParserException {
|
public void testFilter() throws UriParserException {
|
||||||
|
|
||||||
@ -2804,9 +2810,24 @@ public class TestFullResourcePath {
|
|||||||
.root().right()
|
.root().right()
|
||||||
.isLiteral("1");
|
.isLiteral("1");
|
||||||
|
|
||||||
// testFilter
|
testFilter.runOnETTwoKeyNav("NavPropertyETKeyNavMany(1)/NavPropertyETTwoKeyNavMany(PropertyString='2')/"
|
||||||
// .runOnETTwoKeyNav(
|
+ "PropertyString eq 'SomeString'")
|
||||||
// "NavPropertyETKeyNavMany(1)/NavPropertyETTwoKeyNavMany(PropertyString='2')/PropertyString eq 'SomeString'");
|
.is("<<NavPropertyETKeyNavMany/NavPropertyETTwoKeyNavMany/PropertyString> eq <'SomeString'>>")
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameString)
|
||||||
|
.isMember().goPath()
|
||||||
|
.first()
|
||||||
|
.isNavProperty("NavPropertyETKeyNavMany", EdmTechTestProvider.nameETKeyNav, false)
|
||||||
|
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||||
|
.n()
|
||||||
|
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechTestProvider.nameETTwoKeyNav, false)
|
||||||
|
.isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
|
||||||
|
.isKeyPredicate(1, "PropertyString", "'2'")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false)
|
||||||
|
.goUpFilterValidator()
|
||||||
|
.root().right();
|
||||||
|
|
||||||
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate eq 2013-11-12")
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate eq 2013-11-12")
|
||||||
.is("<<com.sap.odata.test1.ETTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate> eq <2013-11-12>>")
|
.is("<<com.sap.odata.test1.ETTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate> eq <2013-11-12>>")
|
||||||
.root().left()
|
.root().left()
|
||||||
@ -2847,16 +2868,30 @@ public class TestFullResourcePath {
|
|||||||
.root().right()
|
.root().right()
|
||||||
.isLiteral("'SomeString'");
|
.isLiteral("'SomeString'");
|
||||||
|
|
||||||
/*
|
testFilter.runOnETTwoKeyNavEx("invalid").isExSemantic(0);
|
||||||
* Xinvalid
|
testFilter.runOnETTwoKeyNavEx("PropertyComplex/invalid").isExSemantic(0);
|
||||||
* XPropertyComplex/invalid
|
testFilter.runOnETTwoKeyNavEx("concat('a','b')/invalid").isExSyntax(0);
|
||||||
* Xconcat('a','b')/invalid
|
testFilter.runOnETTwoKeyNavEx("PropertyComplex/concat('a','b')").isExSyntax(0);
|
||||||
* XPropertyComplex/concat('a','b')
|
testFilter.runOnETTwoKeyNavEx("PropertyComplexAllPrim/PropertyInt16 eq '1'").isExSemantic(0);
|
||||||
* XPropertyComplexAllPrim/PropertyInt16 eq '1'
|
testFilter.runOnETTwoKeyNavEx("PropertyComplexAllPrim/PropertyDate eq 1").isExSemantic(0);
|
||||||
* XPropertyComplexAllPrim/PropertyDate eq 1
|
testFilter.runOnETTwoKeyNavEx("PropertyComplexAllPrim/PropertyString eq 1").isExSemantic(0);
|
||||||
* XPropertyComplexAllPrim/PropertyString eq 1
|
testFilter.runOnETTwoKeyNavEx("PropertyComplexAllPrim/PropertyDate eq 1").isExSemantic(0);
|
||||||
* XPropertyComplexAllPrim/PropertyDate eq 1
|
|
||||||
*/
|
testFilter.runOnETAllPrim("PropertySByte eq PropertySByte")
|
||||||
|
.is("<<PropertySByte> eq <PropertySByte>>")
|
||||||
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameSByte)
|
||||||
|
.root().right()
|
||||||
|
.isType(EdmTechProvider.nameSByte);
|
||||||
|
|
||||||
|
testFilter.runOnETAllPrim("PropertySByte ne PropertySByte")
|
||||||
|
.is("<<PropertySByte> ne <PropertySByte>>")
|
||||||
|
.isBinary(SupportedBinaryOperators.NE)
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameSByte)
|
||||||
|
.root().right()
|
||||||
|
.isType(EdmTechProvider.nameSByte);
|
||||||
|
|
||||||
testFilter.runOnETAllPrim("PropertySByte add PropertySByte")
|
testFilter.runOnETAllPrim("PropertySByte add PropertySByte")
|
||||||
.is("<<PropertySByte> add <PropertySByte>>")
|
.is("<<PropertySByte> add <PropertySByte>>")
|
||||||
@ -2865,7 +2900,6 @@ public class TestFullResourcePath {
|
|||||||
.root().right()
|
.root().right()
|
||||||
.isType(EdmTechProvider.nameSByte);
|
.isType(EdmTechProvider.nameSByte);
|
||||||
|
|
||||||
/**/
|
|
||||||
testFilter.runOnETAllPrim("PropertyByte add PropertyByte")
|
testFilter.runOnETAllPrim("PropertyByte add PropertyByte")
|
||||||
.is("<<PropertyByte> add <PropertyByte>>")
|
.is("<<PropertyByte> add <PropertyByte>>")
|
||||||
.root().left()
|
.root().left()
|
||||||
@ -3173,8 +3207,13 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameByte)
|
.isType(EdmTechProvider.nameByte)
|
||||||
.root().right()
|
.root().right()
|
||||||
.isType(EdmTechProvider.nameSByte);
|
.isType(EdmTechProvider.nameSByte);
|
||||||
// testFilter.runOnETAllPrim("PropertyByte div 0");
|
|
||||||
// testFilter.runOnETAllPrim("0 div 0");
|
testFilter.runOnETAllPrim("PropertyByte div 0")
|
||||||
|
.is("<<PropertyByte> div <0>>");
|
||||||
|
|
||||||
|
testFilter.runOnETAllPrim("0 div 0")
|
||||||
|
.is("<<0> div <0>>");
|
||||||
|
|
||||||
testFilter.runOnETAllPrim("PropertySByte mod PropertySByte")
|
testFilter.runOnETAllPrim("PropertySByte mod PropertySByte")
|
||||||
.is("<<PropertySByte> mod <PropertySByte>>")
|
.is("<<PropertySByte> mod <PropertySByte>>")
|
||||||
.root().left()
|
.root().left()
|
||||||
@ -3223,54 +3262,187 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameDecimal)
|
.isType(EdmTechProvider.nameDecimal)
|
||||||
.root().right()
|
.root().right()
|
||||||
.isType(EdmTechProvider.nameDecimal);
|
.isType(EdmTechProvider.nameDecimal);
|
||||||
|
|
||||||
|
// DODO not synced
|
||||||
|
testFilter.runOnETAllPrim("PropertyDecimal ge PropertyDecimal")
|
||||||
|
.is("<<PropertyDecimal> ge <PropertyDecimal>>")
|
||||||
|
.isBinary(SupportedBinaryOperators.GE)
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameDecimal)
|
||||||
|
.root().right()
|
||||||
|
.isType(EdmTechProvider.nameDecimal);
|
||||||
|
testFilter.runOnETAllPrim("PropertyDecimal lt PropertyDecimal")
|
||||||
|
.is("<<PropertyDecimal> lt <PropertyDecimal>>")
|
||||||
|
.isBinary(SupportedBinaryOperators.LT)
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameDecimal)
|
||||||
|
.root().right()
|
||||||
|
.isType(EdmTechProvider.nameDecimal);
|
||||||
|
testFilter.runOnETAllPrim("PropertyDecimal le PropertyDecimal")
|
||||||
|
.is("<<PropertyDecimal> le <PropertyDecimal>>")
|
||||||
|
.isBinary(SupportedBinaryOperators.LE)
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameDecimal)
|
||||||
|
.root().right()
|
||||||
|
.isType(EdmTechProvider.nameDecimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilterProperties() throws UriParserException {
|
public void testFilterProperties() throws UriParserException {
|
||||||
// testFilter.runOnETAllPrim("XPropertyByte mod 0");
|
testFilter.runOnETAllPrim("PropertyByte mod 0")
|
||||||
// testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTETTwoKeyNavParamCTTwoPrim(ParameterCTTwoPrim=@ParamAlias)");
|
.is("<<PropertyByte> mod <0>>");
|
||||||
|
|
||||||
testFilter
|
testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTETTwoKeyNavParamCTTwoPrim(ParameterCTTwoPrim=@ParamAlias)")
|
||||||
.runOnETTwoKeyNav("PropertyComplex"
|
.is("<UFCRTETTwoKeyNavParamCTTwoPrim>")
|
||||||
+ "/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam"
|
.goPath()
|
||||||
+ "(ParameterString=PropertyComplex/PropertyComplex/PropertyString)(PropertyInt16=1,PropertyString='2')"
|
.first()
|
||||||
+ "/PropertyString eq 'SomeString'");
|
.isFunction("UFCRTETTwoKeyNavParamCTTwoPrim")
|
||||||
testFilter
|
.isParameterAlias(0, "ParameterCTTwoPrim", "ParamAlias");
|
||||||
.runOnETTwoKeyNav("PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTETTwoKeyNavParam(ParameterString=null)"
|
|
||||||
+ "/PropertyString eq 'SomeString'");
|
|
||||||
testFilter
|
|
||||||
.runOnETTwoKeyNav("NavPropertyETTwoKeyNavMany/com.sap.odata.test1.BFCESTwoKeyNavRTString() eq 'SomeString'");
|
|
||||||
testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'"
|
|
||||||
);
|
|
||||||
// testFilter.runOnETTwoKeyNav("com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'");
|
|
||||||
testFilter
|
|
||||||
.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()"
|
|
||||||
+ "/PropertyComplex/PropertyComplex/PropertyString eq 'Walldorf'");
|
|
||||||
testFilter
|
|
||||||
.runOnETTwoKeyNav("PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam(ParameterString='1')"
|
|
||||||
+ "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
|
|
||||||
+ "/PropertyString eq 'SomeString'");
|
|
||||||
testFilter
|
|
||||||
.runOnETTwoKeyNav("PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam(ParameterString='a=1')"
|
|
||||||
+ "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
|
|
||||||
+ "/PropertyString eq 'SomeString'");
|
|
||||||
testFilter
|
|
||||||
.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase"
|
|
||||||
+ "/PropertyString eq 'SomeString'");
|
|
||||||
|
|
||||||
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=1)/PropertyInt16 eq 2");
|
testFilter.runOnETTwoKeyNav("PropertyComplex"
|
||||||
|
+ "/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam"
|
||||||
|
+ "(ParameterString=PropertyComplex/PropertyComplex/PropertyString)(PropertyInt16=1,PropertyString='2')"
|
||||||
|
+ "/PropertyString eq 'SomeString'")
|
||||||
|
.is("<<PropertyComplex/BFCCTPrimCompRTESTwoKeyNavParam/PropertyString> eq <'SomeString'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCCTPrimCompRTESTwoKeyNavParam")
|
||||||
|
.isParameter(0, "ParameterString", "PropertyComplex/PropertyComplex/PropertyString")
|
||||||
|
// TODO go into parameter
|
||||||
|
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||||
|
.isKeyPredicate(1, "PropertyString", "'2'")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
testFilter
|
testFilter.runOnETTwoKeyNav("PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTETTwoKeyNavParam"
|
||||||
.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=@Param1Alias)/PropertyInt16 eq 2");
|
+ "(ParameterString=null)/PropertyString eq 'SomeString'")
|
||||||
testFilter
|
.is("<<PropertyComplex/BFCCTPrimCompRTETTwoKeyNavParam/PropertyString> eq <'SomeString'>>")
|
||||||
.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=1)/PropertyComplex"
|
.root().left().goPath()
|
||||||
+ "/PropertyComplex/PropertyString eq 'SomeString'");
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCCTPrimCompRTETTwoKeyNavParam")
|
||||||
|
// TODO go into parameter
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
testFilter
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavMany/com.sap.odata.test1.BFCESTwoKeyNavRTString()"
|
||||||
.runOnETTwoKeyNav(
|
+ " eq 'SomeString'")
|
||||||
"com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=PropertyInt16)/PropertyComplex"
|
.is("<<NavPropertyETTwoKeyNavMany/BFCESTwoKeyNavRTString> eq <'SomeString'>>")
|
||||||
+ "/PropertyComplex/PropertyString eq 'SomeString'"
|
.root().left().goPath()
|
||||||
);
|
.first()
|
||||||
|
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechTestProvider.nameETTwoKeyNav, true)
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCESTwoKeyNavRTString");
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'")
|
||||||
|
.is("<<$it/BFCETTwoKeyNavRTETTwoKeyNav/PropertyString> eq <'SomeString'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isIt()
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCETTwoKeyNavRTETTwoKeyNav")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'")
|
||||||
|
.is("<<BFCETTwoKeyNavRTETTwoKeyNav/PropertyString> eq <'SomeString'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isFunction("BFCETTwoKeyNavRTETTwoKeyNav")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()"
|
||||||
|
+ "/PropertyComplex/PropertyComplex/PropertyString eq 'Walldorf'")
|
||||||
|
.is("<<NavPropertyETTwoKeyNavOne/BFCETTwoKeyNavRTETTwoKeyNav/PropertyComplex/PropertyComplex/PropertyString> "
|
||||||
|
+ "eq <'Walldorf'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isNavProperty("NavPropertyETTwoKeyNavOne", EdmTechTestProvider.nameETTwoKeyNav, false)
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCETTwoKeyNavRTETTwoKeyNav")
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTAllPrim, false)
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam"
|
||||||
|
+ "(ParameterString='1')"
|
||||||
|
+ "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
|
||||||
|
+ "/PropertyString eq 'SomeString'")
|
||||||
|
.is("<<PropertyComplex/BFCCTPrimCompRTESTwoKeyNavParam/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyString> "
|
||||||
|
+ "eq <'SomeString'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCCTPrimCompRTESTwoKeyNavParam")
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameETBaseTwoKeyNav)
|
||||||
|
.isKeyPredicate(0, "PropertyInt16", "2")
|
||||||
|
.isKeyPredicate(1, "PropertyString", "'3'")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase"
|
||||||
|
+ "/PropertyString eq 'SomeString'")
|
||||||
|
.is("<<$it/BFCETTwoKeyNavRTCTTwoPrim/com.sap.odata.test1.CTBase/PropertyString> eq <'SomeString'>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isIt()
|
||||||
|
.n()
|
||||||
|
.isFunction("BFCETTwoKeyNavRTCTTwoPrim")
|
||||||
|
.isTypeFilterOnEntry(EdmTechTestProvider.nameCTBase)
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=1)/PropertyInt16 eq 2")
|
||||||
|
.is("<<UFCRTETTwoKeyNavParam/PropertyInt16> eq <2>>")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isFunction("UFCRTETTwoKeyNavParam")
|
||||||
|
.isParameter(0, "ParameterInt16", "1")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=@Param1Alias)"
|
||||||
|
+ "/PropertyInt16 eq 2")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isFunction("UFCRTETTwoKeyNavParam")
|
||||||
|
.isParameterAlias(0, "ParameterInt16", "Param1Alias")
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=1)"
|
||||||
|
+ "/PropertyComplex/PropertyComplex/PropertyString eq 'SomeString'")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isFunction("UFCRTETTwoKeyNavParam")
|
||||||
|
.isParameter(0, "ParameterInt16", "1")
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTAllPrim, false)
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.UFCRTETTwoKeyNavParam(ParameterInt16=PropertyInt16)"
|
||||||
|
+ "/PropertyComplex/PropertyComplex/PropertyString eq 'SomeString'")
|
||||||
|
.root().left().goPath()
|
||||||
|
.first()
|
||||||
|
.isFunction("UFCRTETTwoKeyNavParam")
|
||||||
|
.isParameter(0, "ParameterInt16", "PropertyInt16") // TODO
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTAllPrim, false)
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3886,25 +4058,26 @@ public class TestFullResourcePath {
|
|||||||
.goUpFilterValidator().root()
|
.goUpFilterValidator().root()
|
||||||
.goParameter(1).isTypedLiteral(EdmTechProvider.nameETKeyPrimNav);
|
.goParameter(1).isTypedLiteral(EdmTechProvider.nameETKeyPrimNav);
|
||||||
|
|
||||||
// testFilter.runOnETKeyNav("Xcast(NavPropertyETKeyPrimNavOne,com.sap.odata.test1.ETKeyNav)");
|
testFilter.runOnETKeyNavEx("cast(NavPropertyETKeyPrimNavOne,com.sap.odata.test1.ETKeyNav)").isExSemantic(0);
|
||||||
// testFilter.runOnETKeyNav("any()");
|
testFilter.runOnETKeyNav("any()")
|
||||||
|
.isMember().goPath().first().isUriPathInfoKind(UriResourceKind.lambdaAny);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runLamdbaFunctions() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
public void runLamdbaFunctions() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
||||||
/*
|
|
||||||
* testFilter.runOnETKeyNav("any(d:d/PropertyInt16 eq 1)")
|
testFilter.runOnETKeyNav("any(d:d/PropertyInt16 eq 1)")
|
||||||
* .is("<<ANY;<<d/PropertyInt16> eq <1>>>>")
|
.is("<<ANY;<<d/PropertyInt16> eq <1>>>>")
|
||||||
* .root().goPath()
|
.root().goPath()
|
||||||
* .first().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
||||||
* .goLambdaExpression()
|
.goLambdaExpression()
|
||||||
* .isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
* .left().goPath()
|
.left().goPath()
|
||||||
* .first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
* .isType(EdmTechProvider.nameETKeyNav, false)
|
.isType(EdmTechProvider.nameETKeyNav, false)
|
||||||
* .n().isSimple("PropertyInt16");
|
.n().isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false);
|
||||||
*/
|
|
||||||
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyString eq 'SomeString')")
|
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyString eq 'SomeString')")
|
||||||
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<d/PropertyString> eq <'SomeString'>>>>")
|
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<d/PropertyString> eq <'SomeString'>>>>")
|
||||||
.root().goPath()
|
.root().goPath()
|
||||||
@ -3917,7 +4090,8 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
.n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false);
|
.n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false);
|
||||||
|
|
||||||
// testFilter.runOnETKeyNav("XNavPropertyETTwoKeyNavOne/any(d:d/PropertyString eq 'SomeString')");
|
// TODO lambda does not check if the previous path segment is a collection
|
||||||
|
// testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavOne/any(d:d/PropertyString eq 'SomeString')");
|
||||||
|
|
||||||
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any()")
|
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any()")
|
||||||
.is("<NavPropertyETTwoKeyNavMany/<ANY;>>");
|
.is("<NavPropertyETTwoKeyNavMany/<ANY;>>");
|
||||||
@ -3949,51 +4123,43 @@ public class TestFullResourcePath {
|
|||||||
.n().isComplex("PropertyComplex")
|
.n().isComplex("PropertyComplex")
|
||||||
.n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
|
.n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
|
||||||
|
|
||||||
// should throw an error
|
// 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"
|
||||||
* testFilter
|
+ "(e:e/CollPropertyString eq 'SomeString'))")
|
||||||
* .runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyInt16 eq 1 or d/any"
|
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<<d/PropertyInt16> eq <1>> or "
|
||||||
* + "(e:e/CollPropertyString eq 'SomeString'))")
|
+ "<d/<ANY;<<e/CollPropertyString> eq <'SomeString'>>>>>>>")
|
||||||
* .is("<NavPropertyETTwoKeyNavMany/<ANY;<<<d/PropertyInt16> eq <1>> or "
|
.root().goPath()
|
||||||
* + "<d/<ANY;<<e/CollPropertyString> eq <'SomeString'>>>>>>>")
|
.first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechTestProvider.nameETTwoKeyNav, true)
|
||||||
* .root().goPath()
|
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
||||||
* .first().isNavProperty("NavPropertyETTwoKeyNavMany")
|
.goLambdaExpression()
|
||||||
* .n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
.root().isBinary(SupportedBinaryOperators.OR)
|
||||||
*
|
.root().left()
|
||||||
* .goLambdaExpression()
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
*
|
.left()
|
||||||
* .root().isBinary(SupportedBinaryOperators.OR)
|
.goPath()
|
||||||
* .root().left()
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
* .isBinary(SupportedBinaryOperators.EQ)
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
* .left()
|
.n().isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false)
|
||||||
* .goPath()
|
.goUpFilterValidator()
|
||||||
* .first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.root().right()
|
||||||
* .isType(EdmTechProvider.nameETTwoKeyNav, false)
|
.goPath()
|
||||||
* .n().isSimple("PropertyInt16")
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
* .goUpFilterValidator()
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
*
|
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
||||||
* .root().right()
|
.goLambdaExpression()
|
||||||
* .goPath()
|
.root().left().goPath()
|
||||||
* .first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
* .isType(EdmTechProvider.nameETTwoKeyNav, false)
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
* .n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
.n().isPrimitiveProperty("CollPropertyString", EdmTechTestProvider.nameString, true);
|
||||||
* .goLambdaExpression()
|
|
||||||
* .root().left().goPath()
|
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyInt16 eq 1 or d/CollPropertyString/any"
|
||||||
* .first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
+ "(e:e eq 'SomeString'))")
|
||||||
* .isType(EdmTechProvider.nameETTwoKeyNav, false)
|
|
||||||
* .n().isSimple("CollPropertyString").isCollection(true);
|
|
||||||
*/
|
|
||||||
testFilter
|
|
||||||
.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyInt16 eq 1 or d/CollPropertyString/any"
|
|
||||||
+ "(e:e eq 'SomeString'))")
|
|
||||||
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<<d/PropertyInt16> eq <1>> or "
|
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<<d/PropertyInt16> eq <1>> or "
|
||||||
+ "<d/CollPropertyString/<ANY;<<e> eq <'SomeString'>>>>>>>")
|
+ "<d/CollPropertyString/<ANY;<<e> eq <'SomeString'>>>>>>>")
|
||||||
.root().goPath()
|
.root().goPath()
|
||||||
.first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
.first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
||||||
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
||||||
|
|
||||||
.goLambdaExpression()
|
.goLambdaExpression()
|
||||||
|
|
||||||
.root().isBinary(SupportedBinaryOperators.OR)
|
.root().isBinary(SupportedBinaryOperators.OR)
|
||||||
.root().left()
|
.root().left()
|
||||||
.isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
@ -4003,7 +4169,6 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
.n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false)
|
.n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false)
|
||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
|
|
||||||
.root().right()
|
.root().right()
|
||||||
.goPath()
|
.goPath()
|
||||||
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
@ -4023,9 +4188,7 @@ public class TestFullResourcePath {
|
|||||||
.root().goPath()
|
.root().goPath()
|
||||||
.first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
.first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
|
||||||
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
.n().isUriPathInfoKind(UriResourceKind.lambdaAny)
|
||||||
|
|
||||||
.goLambdaExpression()
|
.goLambdaExpression()
|
||||||
|
|
||||||
.root().isBinary(SupportedBinaryOperators.AND)
|
.root().isBinary(SupportedBinaryOperators.AND)
|
||||||
.root().left()
|
.root().left()
|
||||||
.isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
@ -4035,7 +4198,6 @@ public class TestFullResourcePath {
|
|||||||
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
.isType(EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
.n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false)
|
.n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false)
|
||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
|
|
||||||
.root().right()
|
.root().right()
|
||||||
.goPath()
|
.goPath()
|
||||||
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
@ -4045,7 +4207,6 @@ public class TestFullResourcePath {
|
|||||||
.goLambdaExpression()
|
.goLambdaExpression()
|
||||||
.root().left().goPath()
|
.root().left().goPath()
|
||||||
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
.first().isUriPathInfoKind(UriResourceKind.lambdaVariable)
|
||||||
|
|
||||||
.isType(EdmTechProvider.nameString, false)
|
.isType(EdmTechProvider.nameString, false)
|
||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
.root().right().goPath()
|
.root().right().goPath()
|
||||||
@ -4188,54 +4349,54 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHas() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
public void testHas() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
||||||
/*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String1'")
|
testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String1'")
|
||||||
* .is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String1>>>")
|
.is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String1>>>")
|
||||||
* .isBinary(SupportedBinaryOperators.HAS)
|
.isBinary(SupportedBinaryOperators.HAS)
|
||||||
* .root().left().goPath().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
.root().left().goPath().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
||||||
* .goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
* .root().right().isEnumLiteral(EdmTechProvider.nameENString, Arrays.asList("String1"));
|
.root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1"));
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2'")
|
testFilter.runOnETTwoKeyNav("PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2'")
|
||||||
* .is("<<PropertyComplexEnum/PropertyEnumString> has <com.sap.odata.test1.ENString<String2>>>")
|
.is("<<PropertyComplexEnum/PropertyEnumString> has <com.sap.odata.test1.ENString<String2>>>")
|
||||||
* .isBinary(SupportedBinaryOperators.HAS)
|
.isBinary(SupportedBinaryOperators.HAS)
|
||||||
* .root().left().goPath()
|
.root().left().goPath()
|
||||||
* .first().isComplex("PropertyComplexEnum")
|
.first().isComplex("PropertyComplexEnum")
|
||||||
* .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
.n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
||||||
* .isType(EdmTechProvider.nameENString)
|
.isType(EdmTechProvider.nameENString)
|
||||||
* .goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
* .root().right().isEnumLiteral(EdmTechProvider.nameENString, Arrays.asList("String2"));
|
.root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String2"));
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav(
|
testFilter.runOnETTwoKeyNav(
|
||||||
* "PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2' eq true")
|
"PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2' eq true")
|
||||||
* .is("<<<PropertyComplexEnum/PropertyEnumString> has <com.sap.odata.test1.ENString<String2>>> eq <true>>")
|
.is("<<<PropertyComplexEnum/PropertyEnumString> has <com.sap.odata.test1.ENString<String2>>> eq <true>>")
|
||||||
* .isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
* .root().left()
|
.root().left()
|
||||||
* .isBinary(SupportedBinaryOperators.HAS)
|
.isBinary(SupportedBinaryOperators.HAS)
|
||||||
* .root().left().left().goPath()
|
.root().left().left().goPath()
|
||||||
* .first().isComplex("PropertyComplexEnum")
|
.first().isComplex("PropertyComplexEnum")
|
||||||
* .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
.n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
||||||
* .goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
* .root().left().right().isEnumLiteral(EdmTechProvider.nameENString, Arrays.asList("String2"));
|
.root().left().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String2"));
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String3'")
|
testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String3'")
|
||||||
* .is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String3>>>")
|
.is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String3>>>")
|
||||||
* .isBinary(SupportedBinaryOperators.HAS)
|
.isBinary(SupportedBinaryOperators.HAS)
|
||||||
* .root().left().goPath()
|
.root().left().goPath()
|
||||||
* .first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
.first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
||||||
* .isType(EdmTechProvider.nameENString)
|
.isType(EdmTechProvider.nameENString)
|
||||||
* .goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
* .root().right().isEnumLiteral(EdmTechProvider.nameENString, Arrays.asList("String3"));
|
.root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String3"));
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String,String3'")
|
testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String,String3'")
|
||||||
* .is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String,String3>>>")
|
.is("<<PropertyEnumString> has <com.sap.odata.test1.ENString<String,String3>>>")
|
||||||
* .isBinary(SupportedBinaryOperators.HAS)
|
.isBinary(SupportedBinaryOperators.HAS)
|
||||||
* .root().left().goPath()
|
.root().left().goPath()
|
||||||
* .first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
.first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString)
|
||||||
* .isType(EdmTechProvider.nameENString)
|
.isType(EdmTechProvider.nameENString)
|
||||||
* .goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
* .root().right().isEnumLiteral(EdmTechProvider.nameENString, Arrays.asList("String","String3"));
|
.root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String", "String3"));
|
||||||
*/
|
|
||||||
testFilter.runOnETTwoKeyNav("PropertyEnumString has null")
|
testFilter.runOnETTwoKeyNav("PropertyEnumString has null")
|
||||||
.is("<<PropertyEnumString> has <null>>")
|
.is("<<PropertyEnumString> has <null>>")
|
||||||
.root()
|
.root()
|
||||||
@ -4337,7 +4498,12 @@ public class TestFullResourcePath {
|
|||||||
.left().isMethod(SupportedMethodCalls.CONTAINS, 2)
|
.left().isMethod(SupportedMethodCalls.CONTAINS, 2)
|
||||||
.goParameter(0).isLiteral("'Walldorf'")
|
.goParameter(0).isLiteral("'Walldorf'")
|
||||||
.root().left().goParameter(1).isLiteral("'Wall'");
|
.root().left().goParameter(1).isLiteral("'Wall'");
|
||||||
// testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTCTTwoPrimParam(ParameterInt16=null,ParameterString=null)");
|
|
||||||
|
testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTCTTwoPrimParam(ParameterInt16=null,ParameterString=null)")
|
||||||
|
.goPath()
|
||||||
|
.isFunction("UFCRTCTTwoPrimParam")
|
||||||
|
.isParameter(0, "ParameterInt16", "null")
|
||||||
|
.isParameter(1, "ParameterString", "null");
|
||||||
|
|
||||||
testFilter.runOnETAllPrim("PropertyBoolean eq true")
|
testFilter.runOnETAllPrim("PropertyBoolean eq true")
|
||||||
.is("<<PropertyBoolean> eq <true>>")
|
.is("<<PropertyBoolean> eq <true>>")
|
||||||
@ -4346,7 +4512,9 @@ public class TestFullResourcePath {
|
|||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
.root().right().isConstant(SupportedConstants.TRUE);
|
.root().right().isConstant(SupportedConstants.TRUE);
|
||||||
|
|
||||||
// testFilter.runOnETAllPrim("XPropertyBoolean eq 2");
|
testFilter.runOnETAllPrim("PropertyBoolean eq 2")
|
||||||
|
.is("<<PropertyBoolean> eq <2>>");
|
||||||
|
|
||||||
testFilter.runOnETAllPrim("PropertyDecimal eq 1.25")
|
testFilter.runOnETAllPrim("PropertyDecimal eq 1.25")
|
||||||
.is("<<PropertyDecimal> eq <1.25>>")
|
.is("<<PropertyDecimal> eq <1.25>>")
|
||||||
.isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
@ -4482,28 +4650,28 @@ public class TestFullResourcePath {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrderby() throws UriParserException {
|
public void testOrderby() throws UriParserException {
|
||||||
/*
|
|
||||||
* testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
||||||
* + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString'")
|
+ "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString'")
|
||||||
* .isSortOrder(0, false)
|
.isSortOrder(0, false)
|
||||||
* .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
.goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
||||||
* .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
.first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
||||||
* .goOrder(0).right().isLiteral("'SomeString'");
|
.goOrder(0).right().isLiteral("'SomeString'");
|
||||||
*
|
|
||||||
* testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
||||||
* + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' asc")
|
+ "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' asc")
|
||||||
* .isSortOrder(0, false)
|
.isSortOrder(0, false)
|
||||||
* .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
.goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
||||||
* .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
.first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
||||||
* .goOrder(0).right().isLiteral("'SomeString'");
|
.goOrder(0).right().isLiteral("'SomeString'");
|
||||||
*
|
|
||||||
* testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
||||||
* + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc")
|
+ "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc")
|
||||||
* .isSortOrder(0, true)
|
.isSortOrder(0, true)
|
||||||
* .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
.goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath()
|
||||||
* .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
.first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator()
|
||||||
* .goOrder(0).right().isLiteral("'SomeString'");
|
.goOrder(0).right().isLiteral("'SomeString'");
|
||||||
*/
|
|
||||||
testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam("
|
||||||
+ "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc"
|
+ "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc"
|
||||||
+ ", PropertyString eq '1'")
|
+ ", PropertyString eq '1'")
|
||||||
@ -4625,17 +4793,19 @@ public class TestFullResourcePath {
|
|||||||
.goOrder(0).left().goPath().isPrimitiveProperty("PropertyBoolean", EdmTechProvider.nameBoolean, false)
|
.goOrder(0).left().goPath().isPrimitiveProperty("PropertyBoolean", EdmTechProvider.nameBoolean, false)
|
||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
.goOrder(0).right().isConstant(SupportedConstants.TRUE);
|
.goOrder(0).right().isConstant(SupportedConstants.TRUE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38")
|
* testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38")
|
||||||
* .isSortOrder(0, false)
|
* .isSortOrder(0, false)
|
||||||
* .goOrder(0).left().goPath().isSimple("PropertyDouble").goUpFilterValidator()
|
* .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false)
|
||||||
|
* .goUpFilterValidator()
|
||||||
* .goOrder(0).right().isLiteral("3.5E+38");
|
* .goOrder(0).right().isLiteral("3.5E+38");
|
||||||
*
|
*
|
||||||
* testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38 desc").isSortOrder(0, true)
|
* testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38 desc").isSortOrder(0, true)
|
||||||
* .goOrder(0).left().goPath().isSimple("PropertyDouble").goUpFilterValidator()
|
* .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false)
|
||||||
|
* .goUpFilterValidator()
|
||||||
* .goOrder(0).right().isLiteral("3.5E+38");
|
* .goOrder(0).right().isLiteral("3.5E+38");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
testFilter.runOrderByOnETAllPrim("PropertySingle eq 1.5")
|
testFilter.runOrderByOnETAllPrim("PropertySingle eq 1.5")
|
||||||
.isSortOrder(0, false)
|
.isSortOrder(0, false)
|
||||||
.goOrder(0).left().goPath().isPrimitiveProperty("PropertySingle", EdmTechProvider.nameSingle, false)
|
.goOrder(0).left().goPath().isPrimitiveProperty("PropertySingle", EdmTechProvider.nameSingle, false)
|
||||||
@ -4804,10 +4974,9 @@ public class TestFullResourcePath {
|
|||||||
.goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
|
.goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
|
||||||
.goOrder(0).right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1"));
|
.goOrder(0).right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1"));
|
||||||
|
|
||||||
// XPropertyInt16 1
|
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1").isExSyntax(0);
|
||||||
// XPropertyInt16, PropertyInt32 PropertyDuration
|
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16, PropertyInt32 PropertyDuration").isExSyntax(0);
|
||||||
// XPropertyInt16 PropertyInt32, PropertyDuration desc
|
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 PropertyInt32, PropertyDuration desc").isExSyntax(0);
|
||||||
// XPropertyInt16 asc, PropertyInt32 PropertyDuration desc
|
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 asc, PropertyInt32 PropertyDuration desc").isExSyntax(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,7 +937,7 @@ public class TestParser {
|
|||||||
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
|
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
|
||||||
+ "queryOption(systemQueryOption("
|
+ "queryOption(systemQueryOption("
|
||||||
+ "filter($filter = commonExpr(methodCallExpr("
|
+ "filter($filter = commonExpr(methodCallExpr("
|
||||||
+ "distanceMethodCallExpr("
|
+ "geoDistanceMethodCallExpr("
|
||||||
+ "geo.distance( "
|
+ "geo.distance( "
|
||||||
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
|
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
|
||||||
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , "
|
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , "
|
||||||
@ -1108,15 +1108,6 @@ public class TestParser {
|
|||||||
+ "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) "
|
+ "filter($filter = commonExpr(commonExpr(primitiveLiteral(1)) "
|
||||||
+ "le commonExpr(primitiveLiteral(2)))))))) <EOF>)");
|
+ "le commonExpr(primitiveLiteral(2)))))))) <EOF>)");
|
||||||
|
|
||||||
test.aAM().aFC().aCS().run("ODI?$filter=ODI isof Model.Employee").isText("odataRelativeUriEOF(odataRelativeUri("
|
|
||||||
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
|
|
||||||
+ "queryOption(systemQueryOption("
|
|
||||||
+ "filter($filter = commonExpr(commonExpr(memberExpr(pathSegments(pathSegment(odataIdentifier(ODI))))) "
|
|
||||||
+ "isof commonExpr(memberExpr("
|
|
||||||
+ "pathSegments(pathSegment("
|
|
||||||
+ "namespace(odataIdentifier(Model) .) "
|
|
||||||
+ "odataIdentifier(Employee))))))))))) <EOF>)");
|
|
||||||
|
|
||||||
test.aAM().aFC().aCS().run("ODI?$filter=true and false").isText("odataRelativeUriEOF(odataRelativeUri("
|
test.aAM().aFC().aCS().run("ODI?$filter=true and false").isText("odataRelativeUriEOF(odataRelativeUri("
|
||||||
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
|
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
|
||||||
+ "queryOption(systemQueryOption("
|
+ "queryOption(systemQueryOption("
|
||||||
|
@ -23,9 +23,12 @@ package org.apache.olingo.odata4.producer.core.uri.antlr;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||||
|
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
|
||||||
|
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||||
import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl;
|
import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||||
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
|
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
|
||||||
|
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||||
import org.apache.olingo.odata4.producer.core.testutil.EdmTechProvider;
|
import org.apache.olingo.odata4.producer.core.testutil.EdmTechProvider;
|
||||||
import org.apache.olingo.odata4.producer.core.testutil.EdmTechTestProvider;
|
import org.apache.olingo.odata4.producer.core.testutil.EdmTechTestProvider;
|
||||||
import org.apache.olingo.odata4.producer.core.testutil.FilterValidator;
|
import org.apache.olingo.odata4.producer.core.testutil.FilterValidator;
|
||||||
@ -304,14 +307,15 @@ public class TestUriParserImpl {
|
|||||||
.isKind(UriInfoKind.entityId)
|
.isKind(UriInfoKind.entityId)
|
||||||
.isEntityType(EdmTechProvider.nameETBase)
|
.isEntityType(EdmTechProvider.nameETBase)
|
||||||
.isIdText("ESTwoPrim")
|
.isIdText("ESTwoPrim")
|
||||||
.isSelectText("*");
|
.isSelectItemStar(0);
|
||||||
|
|
||||||
// simple entity set; with qualifiedentityTypeName; with expand
|
// simple entity set; with qualifiedentityTypeName; with expand
|
||||||
testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$expand=*")
|
testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$expand=*")
|
||||||
.isKind(UriInfoKind.entityId)
|
.isKind(UriInfoKind.entityId)
|
||||||
.isEntityType(EdmTechProvider.nameETBase)
|
.isEntityType(EdmTechProvider.nameETBase)
|
||||||
.isIdText("ESTwoPrim")
|
.isIdText("ESTwoPrim")
|
||||||
.isExpandText("*");
|
.isExpandText("*")
|
||||||
|
.goExpand().first().isSegmentStar(0);
|
||||||
|
|
||||||
// simple entity set; with qualifiedentityTypeName; with 2xformat(before and after), expand, filter
|
// simple entity set; with qualifiedentityTypeName; with 2xformat(before and after), expand, filter
|
||||||
testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?"
|
testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?"
|
||||||
@ -319,7 +323,8 @@ public class TestUriParserImpl {
|
|||||||
.isFormatText("atom")
|
.isFormatText("atom")
|
||||||
.isCustomParameter(0, "abc", "123")
|
.isCustomParameter(0, "abc", "123")
|
||||||
.isIdText("ESBase")
|
.isIdText("ESBase")
|
||||||
.isCustomParameter(1, "xyz", "987");
|
.isCustomParameter(1, "xyz", "987")
|
||||||
|
.isSelectItemStar(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1062,4 +1067,76 @@ public class TestUriParserImpl {
|
|||||||
.goFilter().is("<<ANY;>>");
|
.goFilter().is("<<ANY;>>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCustomQueryOption() {
|
||||||
|
testUri.run("ESTwoKeyNav?custom")
|
||||||
|
.isCustomParameter(0, "custom", null);
|
||||||
|
testUri.run("ESTwoKeyNav?custom=ABC")
|
||||||
|
.isCustomParameter(0, "custom", "ABC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGeo() throws UriParserException {
|
||||||
|
// TODO sync
|
||||||
|
testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)")
|
||||||
|
.is("<geo.distance(<PropertySByte>,<PropertySByte>)>")
|
||||||
|
.isMethod(SupportedMethodCalls.GEODISTANCE, 2);
|
||||||
|
testFilter.runOnETAllPrim("geo.length(PropertySByte)")
|
||||||
|
.is("<geo.length(<PropertySByte>)>")
|
||||||
|
.isMethod(SupportedMethodCalls.GEOLENGTH, 1);
|
||||||
|
testFilter.runOnETAllPrim("geo.intersects(PropertySByte,PropertySByte)")
|
||||||
|
.is("<geo.intersects(<PropertySByte>,<PropertySByte>)>")
|
||||||
|
.isMethod(SupportedMethodCalls.GEOINTERSECTS, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSelect() {
|
||||||
|
testUri.run("ESTwoKeyNav?$select=*")
|
||||||
|
.isSelectItemStar(0);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.*")
|
||||||
|
.isSelectItemAllOp(0, new FullQualifiedName("com.sap.odata.test1", "*"));
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=PropertyString")
|
||||||
|
.goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechTestProvider.nameString, false);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=PropertyComplex")
|
||||||
|
.goSelectItemPath(0).isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyInt16")
|
||||||
|
.goSelectItemPath(0)
|
||||||
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isPrimitiveProperty("PropertyInt16", EdmTechTestProvider.nameInt16, false);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyComplex")
|
||||||
|
.goSelectItemPath(0)
|
||||||
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTPrimComp, false)
|
||||||
|
.n()
|
||||||
|
.isComplexProperty("PropertyComplex", EdmTechTestProvider.nameCTAllPrim, false);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav")
|
||||||
|
.goSelectItemPath(0)
|
||||||
|
.first()
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameETBaseTwoKeyNav);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav")
|
||||||
|
.goSelectItemPath(0)
|
||||||
|
.first()
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameCTTwoBasePrimCompNav);
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav")
|
||||||
|
.goSelectItemPath(0)
|
||||||
|
.first()
|
||||||
|
.isComplexProperty("PropertyComplexNav", EdmTechTestProvider.nameCTBasePrimCompNav, false)
|
||||||
|
.n()
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameCTTwoBasePrimCompNav);
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -239,53 +239,8 @@ public class QueryOptionTest {
|
|||||||
|
|
||||||
EdmEntityType entityType = edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
EdmEntityType entityType = edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
||||||
|
|
||||||
// UriResourceImplTyped
|
|
||||||
UriInfoImpl resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
EdmAction action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
|
||||||
option = new SelectItemImpl();
|
|
||||||
UriInfoImpl infoImpl = (UriInfoImpl) option.getResourceInfo();
|
|
||||||
infoImpl.addResourcePart(new UriResourceActionImpl().setAction(action)).asUriInfoResource();
|
|
||||||
assertEquals(action.getReturnType().getType(), option.getType());
|
|
||||||
|
|
||||||
// UriResourceImplTyped with filter
|
|
||||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
|
||||||
option = new SelectItemImpl();
|
|
||||||
infoImpl = (UriInfoImpl) option.getResourceInfo();
|
|
||||||
infoImpl.addResourcePart(new UriResourceActionImpl().setAction(action).setTypeFilter(entityType));
|
|
||||||
assertEquals(entityType, option.getType());
|
|
||||||
|
|
||||||
// UriResourceImplKeyPred
|
|
||||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
EdmFunction function = edm.getFunction(EdmTechProvider.nameUFCRTETKeyNav, null, null, null);
|
|
||||||
option = new SelectItemImpl();
|
|
||||||
infoImpl = (UriInfoImpl) option.getResourceInfo();
|
|
||||||
infoImpl.addResourcePart(new UriResourceFunctionImpl().setFunction(function));
|
|
||||||
assertEquals(function.getReturnType().getType(), option.getType());
|
|
||||||
|
|
||||||
// UriResourceImplKeyPred typeFilter on entry
|
|
||||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
|
||||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
|
||||||
Arrays.asList(("ParameterInt16")));
|
|
||||||
option = new SelectItemImpl();
|
|
||||||
infoImpl = (UriInfoImpl) option.getResourceInfo();
|
|
||||||
infoImpl.addResourcePart(new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType));
|
|
||||||
assertEquals(entityBaseType, option.getType());
|
|
||||||
|
|
||||||
// UriResourceImplKeyPred typeFilter on entry
|
|
||||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
|
||||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
|
||||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
|
||||||
Arrays.asList(("ParameterInt16")));
|
|
||||||
infoImpl = (UriInfoImpl) option.getResourceInfo();
|
|
||||||
infoImpl.addResourcePart(new UriResourceFunctionImpl()
|
|
||||||
.setFunction(function).setCollectionTypeFilter(entityBaseType));
|
|
||||||
assertEquals(entityBaseType, option.getType());
|
|
||||||
|
|
||||||
// no typed collection else case ( e.g. if not path is added)
|
// no typed collection else case ( e.g. if not path is added)
|
||||||
option = new SelectItemImpl();
|
option = new SelectItemImpl();
|
||||||
assertEquals(null, option.getType());
|
|
||||||
|
|
||||||
option = new SelectItemImpl();
|
option = new SelectItemImpl();
|
||||||
assertEquals(false, option.isStar());
|
assertEquals(false, option.isStar());
|
||||||
@ -299,11 +254,6 @@ public class QueryOptionTest {
|
|||||||
assertEquals(true, option.isAllOperationsInSchema());
|
assertEquals(true, option.isAllOperationsInSchema());
|
||||||
assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
|
assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
|
||||||
|
|
||||||
option = new SelectItemImpl();
|
|
||||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
|
||||||
option.setEntityTypeCast(entityBaseType);
|
|
||||||
assertEquals(entityBaseType, option.getEntityTypeCast());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user