Merge from origin/master

This commit is contained in:
Francesco Chicchiriccò 2014-02-21 17:27:52 +01:00
commit 7f76d8a7bc
21 changed files with 183 additions and 1835 deletions

View File

@ -20,6 +20,6 @@ package org.apache.olingo.odata4.server.api.uri.queryoption;
public interface FormatOption extends SystemQueryOption {
// TODO planned: define best representation for format
// TODO planned: define best representation for format to enable plugging in custom formats
String getFormat();
}

View File

@ -23,7 +23,7 @@ public enum SupportedQueryOptions {
FORMAT("$format"),
EXPAND("$expand"),
ID("$id"),
INLINECOUNT("$inlinecount"),
COUNT("$count"),
ORDERBY("$orderby"),
SEARCH("$search"),
SELECT("$select"),

View File

@ -81,14 +81,12 @@ value : VALUE;
//; 2. Query Options
//;------------------------------------------------------------------------------
queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;
queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;//TODO can this be removed
queryOption : systemQueryOption
| AT_Q aliasAndValue;
queryOption : systemQueryOption;
systemQueryOption : expand
| filter
| format
| inlinecount
| orderBy
| search
@ -148,7 +146,7 @@ orderByItem : vC=commonExpr ( WSP ( vA=ASC | vD=DESC ) )?;
skip : SKIP EQ INT;
top : TOP EQ INT;
format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
//format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
inlinecount : COUNT EQ booleanNonCase;

View File

@ -256,7 +256,7 @@ public class UriInfoImpl implements UriInfo {
formatOption = (FormatOptionImpl) systemOption;
} else if (systemOption.getKind() == SupportedQueryOptions.ID) {
idOption = (IdOptionImpl) systemOption;
} else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) {
} else if (systemOption.getKind() == SupportedQueryOptions.COUNT) {
inlineCountOption = (CountOptionImpl) systemOption;
} else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) {
orderByOption = (OrderByOptionImpl) systemOption;

View File

@ -195,12 +195,6 @@ public class Parser {
idOption.setText(option.value);
idOption.setValue(option.value);
context.contextUriInfo.setSystemQueryOption(idOption);
} else if (option.name.equals("$inlinecount")) {
CountOptionImpl inlineCountOption = new CountOptionImpl();
inlineCountOption.setName(option.name);
inlineCountOption.setText(option.value);
inlineCountOption.setValue(option.value.equals("true") ? true : false);
context.contextUriInfo.setSystemQueryOption(inlineCountOption);
} else if (option.name.equals("$orderby")) {
OrderByEOFContext ctxFilterExpression =
(OrderByEOFContext) parseRule(option.value, ParserEntryRules.Orderby);
@ -243,20 +237,8 @@ public class Parser {
inlineCountOption.setName(option.name);
inlineCountOption.setText(option.value);
inlineCountOption.setValue(option.value.equals("true") ? true : false);
context.contextUriInfo.setSystemQueryOption(inlineCountOption);
} else if (option.name.equals("$level")) {
LevelsOptionImpl inlineCountOption = new LevelsOptionImpl();
inlineCountOption.setName(option.name);
inlineCountOption.setText(option.value);
if (option.value.equals("max")) {
inlineCountOption.setMax();
} else {
inlineCountOption.setValue(Integer.parseInt(option.value));
}
context.contextUriInfo.setSystemQueryOption(inlineCountOption);
}
}
}

View File

@ -96,10 +96,8 @@ public class UriDecoder {
public static void splittPath(final RawUri rawUri, int scipSegments) {
List<String> list = splitt(rawUri.path, '/');
if (list.size() > 0) {
if (list.get(0).length() == 0) {
scipSegments++;
}
if (list.get(0).length() == 0) {
scipSegments++;
}
if (scipSegments > 0) {
@ -121,9 +119,9 @@ public class UriDecoder {
start = end + 1;
}
if (end == -1) {
list.add(input.substring(start));
}
list.add(input.substring(start));
return list;
}

View File

@ -106,7 +106,6 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.ExpandRefO
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FilterContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FilterExpressionEOFContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FloorMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FormatContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.FractionalsecondsMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.GeoDistanceMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.GeoIntersectsMethodCallExprContext;
@ -187,22 +186,16 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.TypeLiter
/**
* UriVisitor
*
* Converts the URI parse tree from the generate URI parser into an internal representation
* which maybe (TODO) given to the application.
* While converting the tree is validated against the EDM.
* Converts the URI parse tree the generated by ANTLR into an internal representation
* which maybe is given to the application.
* While converting the tree is only validated against the EDM if necessary.
*
* Attention:
* <li> This UriVisitor is at some point more lax than the original ABNF:
* <li> This UriVisitor is at somes point more lax than the original ABNF
* <li> It is more tolerable against additional white spaces
* - Whenever it is possible to move edm validation to the AST classes then
* this should be done ( see visit {@link #visitSelectSegment} for example)
*
* Not supported
* <li>Parsing the context of $metadata
*
* TODO planned
* <li>Overview testcases
* <li>search
* Currently not supported
* <li>Parsing the context of $metadata</li>
* <li>Parsing $search</li>
*/
public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@ -216,7 +209,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
public TypeInformation() {
// TODO Auto-generated constructor stub
}
}
@ -226,14 +218,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// --- class ---
public void setContext(final UriContext context) {
this.context = context;
}
public UriInfoImpl getUriInfo() {
return context.contextUriInfo;
}
public UriParseTreeVisitor(final Edm edm, final UriContext context) {
this.edm = edm;
this.context = context;
@ -639,15 +623,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return type.getNamespace() + "." + type.getName();
}
@Override
public Object visitAliasAndValue(final AliasAndValueContext ctx) {
AliasQueryOptionImpl alias = new AliasQueryOptionImpl();
alias.setName(ctx.vODI.getText());
alias.setText(ctx.vV.getText());
alias.setAliasValue((ExpressionImpl) ctx.vV.accept(this));
return alias;
}
@Override
public Object visitAllEOF(final AllEOFContext ctx) {
UriInfoImpl crossJoin = new UriInfoImpl().setKind(UriInfoKind.all);
@ -1009,7 +984,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (type instanceof EdmEntityType) {
context.contextUriInfo.addResourcePart(new UriResourceRefImpl());
} else {
throw wrap(new UriParserSemanticException("$ref only allowd on endity types"));
throw wrap(new UriParserSemanticException("$ref only allowed on endity types"));
}
} else {
throw wrap(new UriParserSemanticException("$ref only allowed on typed properties"));
@ -1120,7 +1095,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
levels.setText(ctx.vM.getText());
expandItem.setSystemQueryOption(levels);
} else if (ctx.vL != null) {
// TODO set value as integer
LevelsOptionImpl levels = new LevelsOptionImpl();
String text = ctx.vL.getText();
levels.setText(text);
@ -1253,35 +1227,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public Object visitFormat(final FormatContext ctx) {
FormatOptionImpl format = new FormatOptionImpl();
TerminalNodeImpl c2 = (TerminalNodeImpl) ctx.children.get(2);
if (c2.symbol.getType() == UriLexer.ATOM) {
format.setFormat("atom");
} else if (c2.symbol.getType() == UriLexer.JSON) {
format.setFormat("json");
} else if (c2.symbol.getType() == UriLexer.XML) {
format.setFormat("xml");
} else if (c2.symbol.getType() == UriLexer.PCHARS) {
if (ctx.getChildCount() == 2) {
format.setFormat(c2.getText());
} else {
format.setFormat(c2.getText() + "/" + ctx.children.get(4).getText());
}
}
String text = ctx.children.get(2).getText();
if (ctx.getChildCount() > 4) {
text += ctx.children.get(3).getText();
text += ctx.children.get(4).getText();
}
format.setText(text);
return format;
}
@Override
public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) {
return new MethodCallImpl()
@ -1363,9 +1308,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (text.equals("max")) {
levels.setMax();
} else {
levels.setValue(Integer.parseInt(text));
}
levels.setText(text);
// TODO set value as integer
return levels;
@ -2034,7 +1981,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// check for action
EdmAction action = edm.getAction(fullName, finalTypeName, null);
// TODO verify that null ignores if it is a collection
if (action != null) {
UriResourceActionImpl uriAction = new UriResourceActionImpl();
@ -2046,7 +1992,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// check for function
EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null);
// TODO verify that null ignores if it is a collection
if (function != null) {
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
@ -2151,11 +2096,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
}
@Override
public Object visitUnary(final UnaryContext ctx) {
// TODO implement
return super.visitUnary(ctx);
}
@Override
public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) {

View File

@ -18,7 +18,6 @@
*/
package org.apache.olingo.odata4.server.core.uri.parser;
//TODO Check name of this exception when implementing proper error handling
public class UriParserException extends Exception {
/**
*

View File

@ -18,12 +18,8 @@
*/
package org.apache.olingo.odata4.server.core.uri.parser;
//TODO Check name of this exception when implementing proper error handling
public class UriParserSemanticException extends UriParserException {
/**
*
*/
private static final long serialVersionUID = 1L;
public UriParserSemanticException(final String message, final Throwable cause) {

View File

@ -26,7 +26,7 @@ public class CountOptionImpl extends SystemQueryOptionImpl implements CountOptio
private boolean count;
public CountOptionImpl() {
setKind(SupportedQueryOptions.INLINECOUNT);
setKind(SupportedQueryOptions.COUNT);
}
@Override

View File

@ -59,7 +59,7 @@ public class ExpandItemImpl implements ExpandItem {
expandOption = (ExpandOptionImpl) sysItem;
} else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
filterOption = (FilterOptionImpl) sysItem;
} else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
} else if (sysItem.getKind() == SupportedQueryOptions.COUNT) {
inlineCountOption = (CountOptionImpl) sysItem;
} else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
orderByOption = (OrderByOptionImpl) sysItem;

View File

@ -22,7 +22,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
import org.apache.olingo.odata4.server.api.uri.queryoption.search.SearchExpression;
// TODO $search is not supported yet
// TODO planned: support $search
public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOption {
public SearchOptionImpl() {
@ -31,7 +31,6 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt
@Override
public SearchExpression getSearchExpression() {
// TODO $search is not supported yet
return null;
}

View File

@ -124,16 +124,17 @@ public class RawUriTest {
checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("entitySet"));
}
/*
* @Test
* public void testSplitt() {
* UriRawParser.splitt("", '/');
* UriRawParser.splitt("a", '/');
* UriRawParser.splitt("a/", '/');
* UriRawParser.splitt("/a", '/');
* UriRawParser.splitt("a/a", '/');
* }
*/
@Test
public void testSplitt() {
UriDecoder.splitt("", '/');
UriDecoder.splitt("/", '/');
UriDecoder.splitt("a", '/');
UriDecoder.splitt("a/", '/');
UriDecoder.splitt("/a", '/');
UriDecoder.splitt("a/a", '/');
}
private void checkPath(final RawUri rawUri, final String path, final List<String> list) {
assertEquals(path, rawUri.path);

View File

@ -46,7 +46,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.Expressio
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl;
import org.junit.Test;
public class UriParameterImplTest {
public class UriResourceImplTest {
Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
@Test
@ -200,10 +200,12 @@ public class UriParameterImplTest {
.getFunction(new ArrayList<String>());
assertNotNull(function);
impl.setFunction(function);
assertEquals(function, impl.getFunction());
assertEquals("UFNRTInt16", impl.toString());
assertEquals(function.getReturnType().getType(), impl.getType());
assertEquals(false,impl.isParameterListFilled());
// function import
impl = new UriResourceFunctionImpl();
@ -226,6 +228,7 @@ public class UriParameterImplTest {
assertEquals(false, impl.isCollection());
assertEquals(parameter, impl.getParameters().get(0));
assertEquals(true,impl.isParameterListFilled());
}
@Test
@ -476,7 +479,7 @@ public class UriParameterImplTest {
assertEquals(true, impl.isCollection());
}
/*
@Test
public void testUriResourceStartingTypeFilterImpl() {
UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl();
@ -498,5 +501,5 @@ public class UriParameterImplTest {
impl.setKeyPredicates(keyPredicates);
assertEquals(false, impl.isCollection());
}*/
}
}

View File

@ -18,17 +18,12 @@
*/
package org.apache.olingo.odata4.server.core.uri.antlr;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
@ -38,7 +33,6 @@ import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
import org.apache.olingo.odata4.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.UriValidator;
@ -68,8 +62,7 @@ public class TestFullResourcePath {
testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav);
@ -78,8 +71,7 @@ public class TestFullResourcePath {
testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav);
@ -88,8 +80,7 @@ public class TestFullResourcePath {
testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav);
@ -807,8 +798,7 @@ public class TestFullResourcePath {
.goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETAllPrim)
.isCollection(false)
.isType(EdmTechProvider.nameETAllPrim, false)
.at(1)
.isUriPathInfoKind(UriResourceKind.primitiveProperty)
.isType(EdmTechProvider.nameString);
@ -818,8 +808,7 @@ public class TestFullResourcePath {
.goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETCollAllPrim)
.isCollection(false)
.isType(EdmTechProvider.nameETCollAllPrim, false)
.at(1)
.isUriPathInfoKind(UriResourceKind.primitiveProperty)
.isType(EdmTechProvider.nameString);
@ -830,8 +819,7 @@ public class TestFullResourcePath {
.goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(false)
.isType(EdmTechProvider.nameETTwoKeyNav, false)
.at(1)
.isUriPathInfoKind(UriResourceKind.complexProperty)
.at(2)
@ -843,8 +831,7 @@ public class TestFullResourcePath {
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.at(1)
.isType(EdmTechProvider.nameCTPrimComp)
.isCollection(true)
.isType(EdmTechProvider.nameCTPrimComp, true)
.at(2)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETAllPrim);
@ -855,8 +842,7 @@ public class TestFullResourcePath {
.goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(false)
.isType(EdmTechProvider.nameETTwoKeyNav, false)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav);
@ -866,8 +852,7 @@ public class TestFullResourcePath {
.goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1).isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav);
}
@ -1118,15 +1103,16 @@ public class TestFullResourcePath {
@Test
public void runEsNameKeyCast() {
testUri.runEx("xESTwoPrim(1)/com.sap.odata.test1.ETBase(1)")
.isExSemantic(0);
testUri.runEx("xESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)")
.isExSemantic(0);
testUri.runEx("xESBase/com.sap.odata.test1.ETTwoPrim(1)")
.isExSemantic(0);
/*
* testUri.runEx("ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)")
* .isExSemantic(0);
*
* testUri.runEx("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)")
* .isExSemantic(0);
*
* testUri.runEx("ESBase/com.sap.odata.test1.ETTwoPrim(1)")
* .isExSemantic(0);
*/
testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase")
.isKind(UriInfoKind.resource).goPath()
@ -2365,9 +2351,9 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?"
@ -2378,9 +2364,9 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav"
@ -2391,9 +2377,9 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav);
@ -2402,9 +2388,9 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isComplex("PropertyComplexNav")
.isType(EdmTechProvider.nameCTBasePrimCompNav)
.n()
@ -2416,9 +2402,9 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isComplex("PropertyComplexNav")
.isType(EdmTechProvider.nameCTBasePrimCompNav)
.n()
@ -2448,10 +2434,10 @@ public class TestFullResourcePath {
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
// .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
// .n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav)
.goUpExpandValidator()
@ -2475,7 +2461,7 @@ public class TestFullResourcePath {
.goPath().first()
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
.isType(EdmTechProvider.nameETKeyNav);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$select=com.sap.odata.test1.ETBaseTwoKeyNav"
+ "/PropertyInt16")
.isKind(UriInfoKind.resource).goPath()
@ -2485,7 +2471,7 @@ public class TestFullResourcePath {
.isSelectStartType(0, EdmTechProvider.nameETBaseTwoKeyNav)
.goSelectItem(0)
.first()
.isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
.isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyInt16)")
.isKind(UriInfoKind.resource)
@ -4170,7 +4156,6 @@ public class TestFullResourcePath {
.n().isComplex("PropertyComplex")
.n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
// TODO lambda does not check if the previous path segment is a collection
testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyInt16 eq 1 or d/any"
+ "(e:e/CollPropertyString eq 'SomeString'))")
.is("<NavPropertyETTwoKeyNavMany/<ANY;<<<d/PropertyInt16> eq <1>> or "
@ -4381,7 +4366,6 @@ public class TestFullResourcePath {
.goUpFilterValidator()
.root().goParameter(1).isTypedLiteral(EdmTechProvider.nameString);
// TODO cross check with abap coding
testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyString,Edm.Guid)")
.is("<isof(<PropertyComplex/PropertyComplex/PropertyString>,<Edm.Guid>)>")
.root()
@ -5020,7 +5004,6 @@ public class TestFullResourcePath {
.goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
.goOrder(0).right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1"));
// TODO
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1").isExSyntax(0);
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16, PropertyInt32 PropertyDuration").isExSyntax(0);
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 PropertyInt32, PropertyDuration desc").isExSyntax(0);
@ -5062,6 +5045,57 @@ public class TestFullResourcePath {
testUri.run("ESTwoKeyNav?$search= abc AND (def ghi)");
}
@Test
public void testErrors() {
testUri.runEx("FICRTString(wrong1='ABC')/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0);
testUri.runEx("FICRTString(wrong1='ABC', wrong2=1)/com.sap.odata.test1.BFCStringRTESTwoKeyNav()").isExSemantic(0);
// type filter for entity incompatible
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBase").isExSemantic(0);
// type filter for entity double on entry
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
+ "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0);
// type filter for entity double on collection
testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav")
.isExSemantic(0);
// type filter for entity double on non key pred
testUri.runEx("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav").isExSemantic(0);
// type filter for complex incompatible
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim"
+ "/com.sap.odata.test1.CTCollAllPrim").isExSemantic(0);
// type filter for complex double on entry
testUri.runEx("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
+ "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
// type filter for complex double on collection
testUri.runEx("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')"
+ "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
// type filter for complex double on non key pred
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim"
+ "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav").isExSemantic(0);
// $ref
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$ref").isExSemantic(0);
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$count").isExSemantic(0);
}
@Test
public void testAlias() {
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString=@A)?@A='2'").goPath()
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicateAlias(1, "PropertyString", "A")
.goUpUriValidator()
.isCustomParameter(0, "@A", "'2'");
}
public static String encode(final String decoded) throws UnsupportedEncodingException {
return URLEncoder.encode(decoded, "UTF-8");

View File

@ -68,29 +68,20 @@ public class TestLexer {
test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP);
test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP);
// TODO check and add error handling
// test.run("$skip=A").isExType(LexerNoViableAltException.class);
test.run("$top=1").isAllText("$top=1").isType(UriLexer.TOP);
test.run("$top=2").isAllText("$top=2").isType(UriLexer.TOP);
test.run("$top=123").isAllText("$top=123").isType(UriLexer.TOP);
// TODO check and add error handling
// test.run("$top=A").isExType(LexerNoViableAltException.class);
test.run("$levels=1").isAllText("$levels=1").isType(UriLexer.LEVELS);
test.run("$levels=2").isAllText("$levels=2").isType(UriLexer.LEVELS);
test.run("$levels=123").isAllText("$levels=123").isType(UriLexer.LEVELS);
test.run("$levels=max").isAllText("$levels=max").isType(UriLexer.LEVELS);
// TODO check and add error handling
// test.run("$levels=A").isExType(LexerNoViableAltException.class);
test.run("$format=atom").isAllText("$format=atom").isType(UriLexer.FORMAT);
test.run("$format=json").isAllText("$format=json").isType(UriLexer.FORMAT);
test.run("$format=xml").isAllText("$format=xml").isType(UriLexer.FORMAT);
test.run("$format=abc/def").isAllText("$format=abc/def").isType(UriLexer.FORMAT);
// TODO check and add error handling
// test.run("$format=abc").isExType(LexerNoViableAltException.class);
test.run("$id=123").isAllText("$id=123").isType(UriLexer.ID);
test.run("$id=ABC").isAllText("$id=ABC").isType(UriLexer.ID);
@ -108,11 +99,8 @@ public class TestLexer {
@Test
public void testQueryExpressions() {
test.globalMode(Lexer.DEFAULT_MODE);
// assertEquals("expected","actual");
test.run("$it").isText("$it").isType(UriLexer.IT);
// TODO check and add error handling
// test.run("$itabc").isText("$it").isType(UriLexer.IMPLICIT_VARIABLE_EXPR);
test.run("$filter=contains(").at(2).isText("contains(").isType(UriLexer.CONTAINS_WORD);
@ -131,106 +119,6 @@ public class TestLexer {
}
// ;------------------------------------------------------------------------------
// ; 5. JSON format for function parameters
// ;------------------------------------------------------------------------------
@Test
public void testQueryJSON_and_otheres() {
// QUOTATION_MARK
// test.run("\"").isText("\"").isType(UriLexer.QUOTATION_MARK);
// test.run("%22").isText("%22").isType(UriLexer.QUOTATION_MARK);
// Lexer rule QCHAR_UNESCAPED
test.run("\"abc\"").isText("\"abc\"").isType(UriLexer.STRING_IN_JSON);
// Lexer rule QCHAR_JSON_SPECIAL
/*
* test.run("\"" + cQCHAR_JSON_SPECIAL + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
*
* // Lexer rule CHAR_IN_JSON
* test.run("\"" + cQCHAR_UNESCAPED + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cQCHAR_JSON_SPECIAL + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
*
* // Lexer rule ESCAPE CHAR_IN_JSON
* test.run("\"" + cESCAPE + cQUOTATION_MARK + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + cESCAPE + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "/" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "%2F" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "b" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "f" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "n" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "r" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "t" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
* test.run("\"" + cESCAPE + "u12AB" + "\"").isInput().isType(UriLexer.STRING_IN_JSON);
*/
}
// ;------------------------------------------------------------------------------
// ; 6. Names and identifiers
// ;------------------------------------------------------------------------------
@Test
public void testNamesAndIdentifiers() {
/*
* test.run("Binary").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Boolean").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Byte").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Date").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("DateTimeOffset").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Decimal").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Double").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Duration").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Guid").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Int16").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Int32").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Int64").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("SByte").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Single").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Stream").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("String").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("TimeOfDay").isInput().isType(UriLexer.PRIMITIVETYPENAME);
*
* test.run("Geography").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run("Geometry").isInput().isType(UriLexer.PRIMITIVETYPENAME);
*
* String g = "Geography";
* test.run(g ).isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Collection").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiLineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiPoint").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiPolygon").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Point").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Polygon").isInput().isType(UriLexer.PRIMITIVETYPENAME);
*
* g = "Geometry";
* test.run(g ).isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Collection").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiLineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiPoint").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "MultiPolygon").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Point").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "LineString").isInput().isType(UriLexer.PRIMITIVETYPENAME);
* test.run(g + "Polygon").isInput().isType(UriLexer.PRIMITIVETYPENAME);
*/
}
@Test
public void testNameClaches() {
/*
* test.run("Collection").isInput().isType(UriLexer.COLLECTION_CS_FIX);
* test.run("LineString").isInput().isType(UriLexer.LINESTRING_CS_FIX);
* test.run("MultiLineString").isInput().isType(UriLexer.MULTILINESTRING_CS_FIX);
* test.run("MultiPoint").isInput().isType(UriLexer.MULTIPOINT_CS_FIX);
* test.run("MultiPolygon").isInput().isType(UriLexer.MULTIPOLYGON_CS_FIX);
* test.run("Point").isInput().isType(UriLexer.POINT_CS_FIX);
* test.run("Polygon").isInput().isType(UriLexer.POLYGON_CS_FIX);
* test.run("Srid").isInput().isType(UriLexer.SRID_CS);
*/
}
// ;------------------------------------------------------------------------------
// ; 7. Literal Data Values
@ -246,11 +134,6 @@ public class TestLexer {
test.run("binary'ABCD'").isInput().isType(UriLexer.BINARY);
test.run("BiNaRy'ABCD'").isInput().isType(UriLexer.BINARY);
// not a binary TODO add error handling
test.run("BiNaRy'ABCDA'")
.at(0).isText("BiNaRy").isType(UriLexer.ODATAIDENTIFIER)
.at(1).isText("'ABCDA'").isType(UriLexer.STRING);
// boolean
test.run("true").isInput().isType(UriLexer.TRUE);
test.run("false").isInput().isType(UriLexer.FALSE);
@ -342,28 +225,7 @@ public class TestLexer {
}
/*
* // ;------------------------------------------------------------------------------
* // ; 0. misc
* // ;------------------------------------------------------------------------------
*
* @Test
* public void testCriticalOrder() {
* // Test lexer rule STRING
* test.run("'abc'").isInput().isType(UriLexer.STRING);
*
* // Test lexer rule SEARCHWORD
* test.run("abc", true).isInput().isType(UriLexer.SEARCHWORD);
*
* // Test lexer rule SEARCHPHRASE
* test.run("\"abc\"", true).isInput().isType(UriLexer.SEARCHPHRASE);
*
* // Test lexer rule ODATAIDENTIFIER
* test.run("abc").isInput().isType(UriLexer.ODATAIDENTIFIER);
*
* test.run("\"abc\"").isInput().isType(UriLexer.STRING_IN_JSON);
* }
*/
@Test
public void testDelims() {
String reserved = "/";
@ -383,27 +245,6 @@ public class TestLexer {
// Test lexer rule PCHAR all
test.run("$format=" + cPCHAR + "/" + cPCHAR).isAllInput().isType(UriLexer.FORMAT);
/*
* test.run("$format=" + cPCHAR + "/" + cPCHAR + reserved)
* .isType(UriLexer.FORMAT).at(4)
* .isText(cPCHAR);
*/
// Test lexer rule QCHAR_NO_AMP
// String amp = "&";
// Test lexer rule UNRESERVED
// test.run("$id=" + cUNRESERVED).isAllInput().isType(UriLexer.ID);
// test.run("$id=" + cUNRESERVED + amp).isType(UriLexer.ID).at(2).isText(cUNRESERVED);
// Test lexer rule PCT_ENCODED
// test.run("$id=" + cPCT_ENCODED).isAllInput().isType(UriLexer.ID);
// test.run("$id=" + cPCT_ENCODED + amp).isType(UriLexer.ID).at(2).isText(cPCT_ENCODED);
// Test lexer rule OTHER_DELIMS
// test.run("$id=" + cOTHER_DELIMS).isAllInput().isType(UriLexer.ID);
// test.run("$id=" + cOTHER_DELIMS + amp).isType(UriLexer.ID).at(2).isText(cOTHER_DELIMS);
// Lexer rule QCHAR_NO_AMP rest
// test.run("$id=:@/?$'=").isAllText("$id=:@/?$'=").isType(UriLexer.ID);
// test.run("$id=:@/?$'=" + amp).isType(UriLexer.ID).at(2).isText(":@/?$'=");
}
}

View File

@ -104,69 +104,57 @@ public class TestUriParserImpl {
testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameString)
.isCollection(false);
.isType(EdmTechProvider.nameString, false);
// returning collection of primitive
testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameString)
.isCollection(true);
.isType(EdmTechProvider.nameString, true);
// returning single complex
testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameCTTwoPrim)
.isCollection(false);
.isType(EdmTechProvider.nameCTTwoPrim, false);
// returning collection of complex
testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameCTTwoPrim)
.isCollection(true);
.isType(EdmTechProvider.nameCTTwoPrim, true);
// returning single entity
testRes.run(
esTwoKeyNav + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isType(EdmTechProvider.nameETTwoKeyNav, false)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.isCollection(false)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(false);
.isType(EdmTechProvider.nameETTwoKeyNav, false);
// returning collection of entity (aka entitySet)
testRes.run(esTwoKeyNav + "/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(false)
.isType(EdmTechProvider.nameETTwoKeyNav, false)
.at(1)
.isUriPathInfoKind(UriResourceKind.function)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isCollection(true);
.isType(EdmTechProvider.nameETTwoKeyNav, true);
}
@Test
@ -212,8 +200,7 @@ public class TestUriParserImpl {
testRes.run("ESAllPrim/$count")
.at(0)
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETAllPrim)
.isCollection(true)
.isType(EdmTechProvider.nameETAllPrim,true)
.at(1)
.isUriPathInfoKind(UriResourceKind.count);
@ -517,10 +504,9 @@ public class TestUriParserImpl {
testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase")
.at(0)
.isEntitySet("ESTwoPrim")
.isType(EdmTechProvider.nameETTwoPrim)
.isType(EdmTechProvider.nameETTwoPrim,true)
.isTypeFilterOnCollection(EdmTechProvider.nameETBase)
.isTypeFilterOnEntry(null)
.isCollection(true);
.isTypeFilterOnEntry(null);
// filter before key predicate
testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)")
@ -531,10 +517,9 @@ public class TestUriParserImpl {
.isTypeFilterOnCollection(EdmTechProvider.nameETBase)
.isTypeFilterOnEntry(null)
.at(0)
.isType(EdmTechProvider.nameETTwoPrim)
.isKeyPredicate(0, "PropertyInt16", "1")
.isCollection(false);
.isType(EdmTechProvider.nameETTwoPrim,false)
.isKeyPredicate(0, "PropertyInt16", "1");
// filter before key predicate; property of sub type
testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)/AdditionalPropertyString_5")
.at(0)
@ -553,11 +538,10 @@ public class TestUriParserImpl {
.at(0)
.isEntitySet("ESTwoPrim")
.isUriPathInfoKind(UriResourceKind.entitySet)
.isType(EdmTechProvider.nameETTwoPrim)
.isType(EdmTechProvider.nameETTwoPrim,false)
.isTypeFilterOnCollection(null)
.isTypeFilterOnEntry(EdmTechProvider.nameETBase)
.isKeyPredicate(0, "PropertyInt16", "1")
.isCollection(false);
.isKeyPredicate(0, "PropertyInt16", "1");
// filter after key predicate; property of sub type
testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase/AdditionalPropertyString_5")
@ -1027,10 +1011,10 @@ public class TestUriParserImpl {
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameCTBase).goPath()
//.at(0)
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameCTTwoPrim, false)
//.isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
// .at(0)
// .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameCTTwoPrim, false)
// .isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
.at(0).isType(EdmTechProvider.nameString);
// on Complex collection
@ -1038,10 +1022,10 @@ public class TestUriParserImpl {
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameCTBase).goPath()
//.at(0)
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameCTTwoPrim, true)
//.isTypeFilterOnCollection(EdmTechProvider.nameCTBase)
// .at(0)
// .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameCTTwoPrim, true)
// .isTypeFilterOnCollection(EdmTechProvider.nameCTBase)
.at(0).isType(EdmTechProvider.nameString);
}
@ -1120,10 +1104,10 @@ public class TestUriParserImpl {
.isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false);
testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav")
.isSelectStartType(0,EdmTechProvider.nameETBaseTwoKeyNav);
.isSelectStartType(0, EdmTechProvider.nameETBaseTwoKeyNav);
testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav")
.isSelectStartType(0,EdmTechProvider.nameCTTwoBasePrimCompNav);
.isSelectStartType(0, EdmTechProvider.nameCTTwoBasePrimCompNav);
testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav")
.goSelectItemPath(0)

View File

@ -161,7 +161,7 @@ public class QueryOptionTest {
@Test
public void testInlineCountImpl() {
CountOptionImpl option = new CountOptionImpl();
assertEquals(SupportedQueryOptions.INLINECOUNT, option.getKind());
assertEquals(SupportedQueryOptions.COUNT, option.getKind());
assertEquals(false, option.getValue());
option.setValue(true);

View File

@ -26,7 +26,6 @@ import java.util.List;
import org.antlr.v4.runtime.ParserRuleContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser;
// TODO extend to test also exception which can occure while paring
public class ParserValidator {
private String input = null;
@ -55,7 +54,6 @@ public class ParserValidator {
}
/**
* TODO verify
* Used in fast LL Parsing:
* Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is
* required
@ -67,8 +65,6 @@ public class ParserValidator {
}
/**
*
* TODO verify
* Used in fast LL Parsing:
* Allows ContextSensitifity Errors which occur often when using the slower full context parsing
* and indicate that there is a context sensitivity ( which may not be an error).
@ -80,7 +76,6 @@ public class ParserValidator {
}
/**
* TODO verify
* Used in fast LL Parsing:
* Allows ambiguities
* @return
@ -164,80 +159,4 @@ public class ParserValidator {
return this;
}
// --- Helper ---
/*
* private OdataRelativeUriEOFContext parseInput(final String input) {
* UriParserParser parser = null;
* UriLexerWithTrace lexer = null;
* OdataRelativeUriEOFContext ret = null;
*
* // Use 2 stage approach to improve performance
* // see https://github.com/antlr/antlr4/issues/192
* // TODO verify this
*
* // stage= 1
* try {
* curException = null;
* exceptions.clear();
*
* // create parser
* lexer = new UriLexerWithTrace(new ANTLRInputStream(input), lexerLogLevel);
* parser = new UriParserParser(new CommonTokenStream(lexer));
*
* // write always a error message in case of syntax errors
* // parser.addErrorListener(new TestErrorHandler<Object>());
* // check error message if whether they are allowed or not
* // parser.addErrorListener(new ErrorCollector());
*
* // bail out of parser at first syntax error. --> proceed in catch block with step 2
* parser.setErrorHandler(new BailErrorStrategy());
*
* // user the faster SLL parsing
* parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
*
* // parse
* if (logLevel > 0) {
* System.out.println("Step 1");
* System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode());
* }
* ret = parser.odataRelativeUriEOF();
*
* } catch (Exception exception) {
* curException = exception;
* try {
* // clear status
* curException = null;
* exceptions.clear();
*
* // create parser
* lexer = new UriLexerWithTrace(new ANTLRInputStream(input), lexerLogLevel);
* parser = new UriParserParser(new CommonTokenStream(lexer));
*
* // write always a error message in case of syntax errors
* // parser.addErrorListener(new ErrorCollector(this));
* // check error message if whether they are allowed or not
* // parser.addErrorListener(new ErrorCollector(this));
*
* // Used default error strategy
* parser.setErrorHandler(new DefaultErrorStrategy());
*
* // User the slower SLL parsing
* parser.getInterpreter().setPredictionMode(PredictionMode.LL);
*
* // parse
* if (logLevel > 1) {
* System.out.println("Step 2");
* System.out.println(" PrectictionMode: " + parser.getInterpreter().getPredictionMode() + ")");
* }
* ret = parser.odataRelativeUriEOF();
*
* } catch (Exception exception1) {
* curException = exception1;
* // exceptionOnStage = 2;
* }
* }
*
* return ret;
* }
*/
}

View File

@ -327,7 +327,7 @@ public class ResourceValidator implements Validator {
}
// TODO remove
public ResourceValidator isCollection(final boolean isCollection) {
/*public ResourceValidator isCollection(final boolean isCollection) {
if (!(uriPathInfo instanceof UriResourcePartTyped)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
@ -339,7 +339,7 @@ public class ResourceValidator implements Validator {
}
assertEquals(isCollection, uriPathInfoTyped.isCollection());
return this;
}
}*/
public ResourceValidator isFilterString(final String expectedFilterTreeAsString) {
@ -368,6 +368,19 @@ public class ResourceValidator implements Validator {
return this;
}
public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
List<UriParameter> keyPredicates = info.getKeyPredicates();
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(alias, keyPredicates.get(index).getAlias());
return this;
}
public ResourceValidator isKeyPredicate(final int index, final String name, final String text) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {