[OLINGO-63] Uri Parser: add evalation of referential contrains
This commit is contained in:
parent
3e0798675a
commit
71ea12382c
|
@ -18,6 +18,8 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.apache.olingo.odata4.commons.api.edm;
|
package org.apache.olingo.odata4.commons.api.edm;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A CSDL NavigationProperty element
|
* A CSDL NavigationProperty element
|
||||||
* <p>EdmNavigationProperty allows navigation from one entity type to another via a relationship.
|
* <p>EdmNavigationProperty allows navigation from one entity type to another via a relationship.
|
||||||
|
|
|
@ -30,4 +30,6 @@ public interface UriParameter {
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
public String getRefencedProperty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ END_OBJECT : WS* ( '}' / '%7D' ) WS*;
|
||||||
|
|
||||||
BEGIN_ARRAY : WS* ( '[' / '%5B' ) WS*;
|
BEGIN_ARRAY : WS* ( '[' / '%5B' ) WS*;
|
||||||
END_ARRAY : WS* ( ']' / '%5D' ) WS*;
|
END_ARRAY : WS* ( ']' / '%5D' ) WS*;
|
||||||
NAME_SEPARATOR : WS* COLON WS*;
|
|
||||||
|
|
||||||
//alpha stuff
|
//alpha stuff
|
||||||
fragment ALPHA : 'a'..'z' | 'A'..'Z';
|
fragment ALPHA : 'a'..'z' | 'A'..'Z';
|
||||||
|
|
|
@ -380,7 +380,7 @@ json_value : jsonPrimitiv
|
||||||
|
|
||||||
json_object : BEGIN_OBJECT
|
json_object : BEGIN_OBJECT
|
||||||
STRING_IN_JSON
|
STRING_IN_JSON
|
||||||
NAME_SEPARATOR
|
WSP? COLON WSP?
|
||||||
json_value
|
json_value
|
||||||
END_OBJECT;
|
END_OBJECT;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class UriParameterImpl implements UriParameter {
|
||||||
private String text;
|
private String text;
|
||||||
private String alias;
|
private String alias;
|
||||||
private Expression expression;
|
private Expression expression;
|
||||||
|
private String referencedProperty;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -61,7 +62,6 @@ public class UriParameterImpl implements UriParameter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression getExression() {
|
public Expression getExression() {
|
||||||
|
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,4 +69,14 @@ public class UriParameterImpl implements UriParameter {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRefencedProperty() {
|
||||||
|
return this.referencedProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UriParameterImpl setRefencedProperty(String referencedProperty) {
|
||||||
|
this.referencedProperty = referencedProperty;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||||
*/
|
*/
|
||||||
private UriInfoImpl contextUriInfo;
|
private UriInfoImpl contextUriInfo;
|
||||||
|
|
||||||
|
private boolean contextReadingFunctionParameters = false;
|
||||||
|
|
||||||
// --- class ---
|
// --- class ---
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -353,11 +355,24 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||||
if (edmFunctionImport != null) {
|
if (edmFunctionImport != null) {
|
||||||
|
|
||||||
// read the URI parameters
|
// read the URI parameters
|
||||||
|
this.contextReadingFunctionParameters = true;
|
||||||
List<UriParameterImpl> parameters = (List<UriParameterImpl>) ctx.vlNVO.get(0).accept(this);
|
List<UriParameterImpl> parameters = (List<UriParameterImpl>) ctx.vlNVO.get(0).accept(this);
|
||||||
|
this.contextReadingFunctionParameters = false;
|
||||||
ctx.vlNVO.remove(0); // parameters are consumed
|
ctx.vlNVO.remove(0); // parameters are consumed
|
||||||
|
|
||||||
UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl();
|
UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl();
|
||||||
uriResource.setFunctionImport(edmFunctionImport, parameters);
|
uriResource.setFunctionImport(edmFunctionImport, parameters);
|
||||||
|
/* get function from function import */
|
||||||
|
List<String> names = new ArrayList<String>();
|
||||||
|
for (UriParameterImpl item : parameters) {
|
||||||
|
names.add(item.getName());
|
||||||
|
}
|
||||||
|
EdmFunction function = edmFunctionImport.getFunction(names);
|
||||||
|
if (function == null) {
|
||||||
|
throw wrap(new UriParserSemanticException("Function via function import not found"));
|
||||||
|
}
|
||||||
|
uriResource.setFunction(edmFunctionImport.getFunction(names));
|
||||||
|
|
||||||
contextUriInfo.addResourcePart(uriResource);
|
contextUriInfo.addResourcePart(uriResource);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -565,8 +580,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||||
throw wrap(new UriParserSemanticException("Expected function parameters"));
|
throw wrap(new UriParserSemanticException("Expected function parameters"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.contextReadingFunctionParameters = true;
|
||||||
List<UriParameterImpl> parameters = (List<UriParameterImpl>) ctx.vlNVO.get(0).accept(this);
|
List<UriParameterImpl> parameters = (List<UriParameterImpl>) ctx.vlNVO.get(0).accept(this);
|
||||||
|
this.contextReadingFunctionParameters = false;
|
||||||
// get names of function parameters
|
// get names of function parameters
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<String>();
|
||||||
for (UriParameterImpl item : parameters) {
|
for (UriParameterImpl item : parameters) {
|
||||||
|
@ -624,7 +640,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||||
public Object visitAllExpr(final AllExprContext ctx) {
|
public Object visitAllExpr(final AllExprContext ctx) {
|
||||||
UriResourceLambdaAllImpl all = new UriResourceLambdaAllImpl();
|
UriResourceLambdaAllImpl all = new UriResourceLambdaAllImpl();
|
||||||
|
|
||||||
// TODO
|
|
||||||
UriResourcePart obj = contextUriInfo.getLastResourcePart();
|
UriResourcePart obj = contextUriInfo.getLastResourcePart();
|
||||||
if (!(obj instanceof UriResourceImplTyped)) {
|
if (!(obj instanceof UriResourceImplTyped)) {
|
||||||
throw wrap(new UriParserSemanticException("any only allowed on typed path segments"));
|
throw wrap(new UriParserSemanticException("any only allowed on typed path segments"));
|
||||||
|
@ -1451,51 +1466,147 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitNameValueOptList(final NameValueOptListContext ctx) {
|
public Object visitNameValueOptList(final NameValueOptListContext ctx) {
|
||||||
|
|
||||||
// is key predicate
|
|
||||||
if (ctx.vVO != null) {
|
if (ctx.vVO != null) {
|
||||||
|
|
||||||
|
// 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 = (ExpressionImpl) ctx.vVO.vV.accept(this);
|
||||||
|
|
||||||
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceImplTyped)) {
|
// get type of last resource part
|
||||||
|
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
||||||
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
throw wrap(new UriParserSyntaxException("Paramterslist on untyped resource path segement not allowed"));
|
throw wrap(new UriParserSyntaxException("Paramterslist on untyped resource path segement not allowed"));
|
||||||
}
|
}
|
||||||
|
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
||||||
|
|
||||||
EdmEntityType entityType =
|
// get list of keys for lastType
|
||||||
(EdmEntityType) ((UriResourceImplTyped) contextUriInfo.getLastResourcePart()).getType();
|
List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
|
||||||
|
|
||||||
List<String> keyPredicates = entityType.getKeyPredicateNames();
|
// if there is exactly one key defined in the EDM, then this key the the key written in the URI,
|
||||||
if (keyPredicates.size() == 1) {
|
// so fill the keylist with this key and return
|
||||||
String keyName = keyPredicates.get(0);
|
if (lastKeyPredicates.size() == 1) {
|
||||||
|
String keyName = lastKeyPredicates.get(0);
|
||||||
List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
|
List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
|
||||||
list.add(new UriParameterImpl().setName(keyName).setText(valueText).setExpression(expression));
|
list.add(new UriParameterImpl().setName(keyName).setText(valueText).setExpression(expression));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is only a single key in the URI but there are more than one keys defined in the EDM, then reduce
|
// There are more keys defined in the EDM, but only one is written in the URI. This is allowed only if
|
||||||
// The keylist with the keys defined as referential constrained.
|
// referential constrains are defined on this navigation property which can be used to will up all required
|
||||||
// TODO add support vor using refential constrains
|
// key.
|
||||||
/*
|
|
||||||
* if (contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl) {
|
|
||||||
* UriResourceNavigationPropertyImpl nav =
|
|
||||||
* (UriResourceNavigationPropertyImpl) contextUriInfo.getLastResourcePart();
|
|
||||||
* nav.getNavigationProperty();
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
throw wrap(new UriParserSyntaxException(
|
// for using referential constrains the last resource part must be a navigation property
|
||||||
"for using a value only keyPredicate there must be exact ONE defined keyProperty"));
|
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
||||||
|
}
|
||||||
|
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
||||||
|
|
||||||
} else {
|
// get the partner of the navigation property
|
||||||
|
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
||||||
|
if (partner == null) {
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the keylist
|
||||||
List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
|
List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
|
||||||
if (ctx.vNVL != null) {
|
|
||||||
|
// find the key not filled by referential constrains and collect the other keys filled by
|
||||||
|
// referential constrains
|
||||||
|
String missedKey = null;
|
||||||
|
for (String item : lastKeyPredicates) {
|
||||||
|
String property = partner.getReferencingPropertyName(item);
|
||||||
|
if (property != null) {
|
||||||
|
list.add(new UriParameterImpl().setName(item).setRefencedProperty(property));
|
||||||
|
} else {
|
||||||
|
if (missedKey == null) {
|
||||||
|
missedKey = item;
|
||||||
|
} else {
|
||||||
|
// two of more keys are missing
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth referntial contrains defined"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the missing key is the one which is defined in the URI
|
||||||
|
list.add(new UriParameterImpl().setName(missedKey).setText(valueText).setExpression(expression));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
} else if (ctx.vNVL != null) {
|
||||||
|
|
||||||
|
List<UriParameterImpl> list = new ArrayList<UriParameterImpl>();
|
||||||
|
|
||||||
for (ParseTree c : ctx.vNVL.vlNVP) {
|
for (ParseTree c : ctx.vNVL.vlNVP) {
|
||||||
list.add((UriParameterImpl) c.accept(this));
|
list.add((UriParameterImpl) c.accept(this));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return list;
|
|
||||||
|
|
||||||
|
if (contextReadingFunctionParameters){
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UriResourcePart last = contextUriInfo.getLastResourcePart();
|
||||||
|
// if the last resource part is a function
|
||||||
|
/*if (last instanceof UriResourceFunctionImpl) {
|
||||||
|
UriResourceFunctionImpl function = (UriResourceFunctionImpl) last;
|
||||||
|
if (!function.isParameterListFilled()) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// get type of last resource part
|
||||||
|
if (!(last instanceof UriResourceImplTyped)) {
|
||||||
|
throw wrap(new UriParserSyntaxException("Parameterslist on untyped resource path segement not allowed"));
|
||||||
|
}
|
||||||
|
EdmEntityType lastType = (EdmEntityType) ((UriResourceImplTyped) last).getType();
|
||||||
|
|
||||||
|
// get list of keys for lastType
|
||||||
|
List<String> lastKeyPredicates = lastType.getKeyPredicateNames();
|
||||||
|
|
||||||
|
// check if all key are filled from the URI
|
||||||
|
if (list.size() == lastKeyPredicates.size()) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not, check if the missing key predicates can be satisfied with help of the defined referential constrains
|
||||||
|
|
||||||
|
// for using referential constrains the last resource part must be a navigation property
|
||||||
|
if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
||||||
|
}
|
||||||
|
UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
|
||||||
|
|
||||||
|
// get the partner of the navigation property
|
||||||
|
EdmNavigationProperty partner = lastNav.getProperty().getPartner();
|
||||||
|
if (partner == null) {
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill missing keys from referential constrains
|
||||||
|
for (String key : lastKeyPredicates) {
|
||||||
|
boolean found = false;
|
||||||
|
for (UriParameterImpl item : list) {
|
||||||
|
if (item.getName().equals(key)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
String property = partner.getReferencingPropertyName(key);
|
||||||
|
if (property != null) {
|
||||||
|
// store the key name as referenced property
|
||||||
|
list.add(0, new UriParameterImpl().setName(key).setRefencedProperty(property));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check again if all keyPredicate are filled from the URI
|
||||||
|
if (list.size() == lastKeyPredicates.size()) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw wrap(new UriParserSyntaxException("Not enougth keyproperties defined"));
|
||||||
|
}
|
||||||
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
|
||||||
protected List<UriParameterImpl> parameters;
|
protected List<UriParameterImpl> parameters;
|
||||||
protected EdmFunction function;
|
protected EdmFunction function;
|
||||||
protected EdmFunctionImport functionImport;
|
protected EdmFunctionImport functionImport;
|
||||||
|
private boolean isParameterListFilled = false;
|
||||||
|
|
||||||
public UriResourceFunctionImpl() {
|
public UriResourceFunctionImpl() {
|
||||||
super(UriResourceKind.function);
|
super(UriResourceKind.function);
|
||||||
|
@ -51,6 +52,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
|
||||||
}
|
}
|
||||||
|
|
||||||
public UriResourceFunctionImpl setParameters(final List<UriParameterImpl> parameters) {
|
public UriResourceFunctionImpl setParameters(final List<UriParameterImpl> parameters) {
|
||||||
|
isParameterListFilled = true;
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -73,14 +75,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
|
||||||
public UriResourceFunctionImpl setFunctionImport(final EdmFunctionImport edmFI,
|
public UriResourceFunctionImpl setFunctionImport(final EdmFunctionImport edmFI,
|
||||||
final List<UriParameterImpl> parameters) {
|
final List<UriParameterImpl> parameters) {
|
||||||
functionImport = edmFI;
|
functionImport = edmFI;
|
||||||
this.parameters = parameters;
|
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>();
|
|
||||||
for (UriParameterImpl item : parameters) {
|
|
||||||
names.add(item.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
setFunction(edmFI.getFunction(names));
|
|
||||||
setParameters(parameters);
|
setParameters(parameters);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -109,4 +104,8 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isParameterListFilled() {
|
||||||
|
return isParameterListFilled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1188,7 +1188,7 @@ public class EdmTechProvider extends EdmProvider {
|
||||||
.setCollection(true)
|
.setCollection(true)
|
||||||
));
|
));
|
||||||
|
|
||||||
} else if (entityTypeName.equals(nameETCompMixPrimCollComp)) {
|
} else if (entityTypeName.equals(nameETFourKeyAlias)) {
|
||||||
return new EntityType()
|
return new EntityType()
|
||||||
.setName("ETFourKeyAlias")
|
.setName("ETFourKeyAlias")
|
||||||
.setKey(Arrays.asList(
|
.setKey(Arrays.asList(
|
||||||
|
@ -1480,6 +1480,17 @@ public class EdmTechProvider extends EdmProvider {
|
||||||
.setReturnType(
|
.setReturnType(
|
||||||
new ReturnType().setType(nameCTTwoPrim))
|
new ReturnType().setType(nameCTTwoPrim))
|
||||||
);
|
);
|
||||||
|
} else if (functionName.equals(nameUFCRTCollCTTwoPrimParam)) {
|
||||||
|
return Arrays.asList(
|
||||||
|
new Function()
|
||||||
|
.setName("UFCRTCollCTTwoPrimParam")
|
||||||
|
.setParameters(Arrays.asList(
|
||||||
|
new Parameter().setName("ParameterString").setType(nameString),
|
||||||
|
new Parameter().setName("ParameterInt16").setType(nameInt16)))
|
||||||
|
.setComposable(true)
|
||||||
|
.setReturnType(
|
||||||
|
new ReturnType().setType(nameCTTwoPrim).setCollection(true))
|
||||||
|
);
|
||||||
|
|
||||||
} else if (functionName.equals(nameUFCRTCTTwoPrim)) {
|
} else if (functionName.equals(nameUFCRTCTTwoPrim)) {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
|
|
|
@ -82,6 +82,7 @@ public class FilterValidator implements Validator {
|
||||||
if (filter.getExpression() == null) {
|
if (filter.getExpression() == null) {
|
||||||
fail("FilterValidator: no filter found");
|
fail("FilterValidator: no filter found");
|
||||||
}
|
}
|
||||||
|
setExpression(filter.getExpression());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +364,7 @@ public class FilterValidator implements Validator {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterValidator isMemberExpression() {
|
public FilterValidator isMember() {
|
||||||
if (!(curExpression instanceof MemberImpl)) {
|
if (!(curExpression instanceof MemberImpl)) {
|
||||||
fail("Current expression not a member");
|
fail("Current expression not a member");
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,8 @@ public class UriResourceValidator implements Validator {
|
||||||
public UriResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
|
public UriResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
|
||||||
|
|
||||||
if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
|
if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
|
||||||
uriPathInfo.getKind() != UriResourceKind.singleton) {
|
uriPathInfo.getKind() != UriResourceKind.singleton &&
|
||||||
|
uriPathInfo.getKind() != UriResourceKind.startingTypeFilter) {
|
||||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,6 +331,19 @@ public class UriResourceValidator implements Validator {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public UriResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
|
||||||
|
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
|
||||||
|
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
UriResourceImplKeyPred info = (UriResourceImplKeyPred) uriPathInfo;
|
||||||
|
List<UriParameter> keyPredicates = info.getKeyPredicates();
|
||||||
|
assertEquals(name, keyPredicates.get(index).getName());
|
||||||
|
assertEquals(refencedProperty, keyPredicates.get(index).getRefencedProperty());
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
public UriResourceValidator isKeyPredicate(final int index, final String name, final String text) {
|
public UriResourceValidator isKeyPredicate(final int index, final String name, final String text) {
|
||||||
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
|
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
|
||||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||||
|
|
|
@ -210,9 +210,7 @@ public class UriParameterImplTest {
|
||||||
impl = new UriResourceFunctionImpl();
|
impl = new UriResourceFunctionImpl();
|
||||||
EdmFunctionImport functionImport = edm.getEntityContainer(null).getFunctionImport("FINRTInt16");
|
EdmFunctionImport functionImport = edm.getEntityContainer(null).getFunctionImport("FINRTInt16");
|
||||||
impl.setFunctionImport(functionImport, new ArrayList<UriParameterImpl>());
|
impl.setFunctionImport(functionImport, new ArrayList<UriParameterImpl>());
|
||||||
|
|
||||||
assertEquals(functionImport, impl.getFunctionImport());
|
assertEquals(functionImport, impl.getFunctionImport());
|
||||||
assertEquals(functionImport.getFunction(new ArrayList<String>()), impl.getFunction());
|
|
||||||
assertEquals("FINRTInt16", impl.toString());
|
assertEquals("FINRTInt16", impl.toString());
|
||||||
|
|
||||||
// function collection
|
// function collection
|
||||||
|
@ -221,8 +219,10 @@ public class UriParameterImplTest {
|
||||||
assertNotNull(function);
|
assertNotNull(function);
|
||||||
UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
|
UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
|
||||||
impl.setFunctionImport(functionImport, Arrays.asList(parameter));
|
impl.setFunctionImport(functionImport, Arrays.asList(parameter));
|
||||||
|
|
||||||
assertEquals("FICRTESTwoKeyNavParam", impl.toString());
|
assertEquals("FICRTESTwoKeyNavParam", impl.toString());
|
||||||
|
|
||||||
|
|
||||||
|
impl.setFunction(functionImport.getFunction(Arrays.asList("ParameterInt16")));
|
||||||
assertEquals(true, impl.isCollection());
|
assertEquals(true, impl.isCollection());
|
||||||
impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
|
impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
|
||||||
assertEquals(false, impl.isCollection());
|
assertEquals(false, impl.isCollection());
|
||||||
|
|
|
@ -53,18 +53,14 @@ public class TestFullResourcePath {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
/*
|
testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath()
|
||||||
* testUri.run("ESTwoKeyNav?"
|
.at(0)
|
||||||
* + "$expand=com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany")
|
.isUriPathInfoKind(UriResourceKind.entitySet)
|
||||||
* .isKind(UriInfoKind.resource).goPath().first()
|
.isType(EdmTechProvider.nameETTwoKeyNav)
|
||||||
* .goExpand().first()
|
.isCollection(true)
|
||||||
* .goPath().first()
|
.at(1)
|
||||||
* .isUriPathInfoKind(UriResourceKind.it)
|
.isUriPathInfoKind(UriResourceKind.function)
|
||||||
* .isType(EdmTechProvider.nameETTwoKeyNav)
|
.isType(EdmTechProvider.nameETTwoKeyNav);
|
||||||
* .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
|
|
||||||
* .n()
|
|
||||||
* .isNavProperty("NavPropertyETKeyNavMany");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -100,8 +96,6 @@ public class TestFullResourcePath {
|
||||||
.isType(EdmTechProvider.nameETTwoKeyNav);
|
.isType(EdmTechProvider.nameETTwoKeyNav);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//DONE
|
//DONE
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1530,13 +1524,28 @@ public class TestFullResourcePath {
|
||||||
.isKeyPredicate(1, "PropertyString", "'5'")
|
.isKeyPredicate(1, "PropertyString", "'5'")
|
||||||
.n()
|
.n()
|
||||||
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true);
|
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runEsNamePpNpRc() {
|
public void runEsNamePpNpRc() {
|
||||||
// testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany('2')");
|
// checks for using referential constrains to fill missing keys
|
||||||
// testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETTwoKeyNavMany(PropertyString='2')");
|
testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany('2')").goPath()
|
||||||
|
.first()
|
||||||
|
.isEntitySet("ESKeyNav")
|
||||||
|
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||||
|
.n()
|
||||||
|
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
|
.isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
|
||||||
|
.isKeyPredicate(1, "PropertyString", "'2'");
|
||||||
|
|
||||||
|
testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETTwoKeyNavMany(PropertyString='2')").goPath()
|
||||||
|
.first()
|
||||||
|
.isEntitySet("ESKeyNav")
|
||||||
|
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||||
|
.n()
|
||||||
|
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, false)
|
||||||
|
.isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
|
||||||
|
.isKeyPredicate(1, "PropertyString", "'2'");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2499,7 +2508,6 @@ public class TestFullResourcePath {
|
||||||
.isFormatText("Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27");
|
.isFormatText("Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runCount() {
|
public void runCount() {
|
||||||
// count
|
// count
|
||||||
|
@ -2755,72 +2763,82 @@ public class TestFullResourcePath {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void TestFilter() throws UriParserException {
|
public void testFilter() throws UriParserException {
|
||||||
/*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyString")
|
testFilter.runOnETTwoKeyNav("PropertyString")
|
||||||
* .is("<$it/PropertyString>")
|
.is("<PropertyString>")
|
||||||
* .isType(EdmTechProvider.nameString);
|
.isType(EdmTechProvider.nameString);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyComplex/PropertyInt16")
|
testFilter.runOnETTwoKeyNav("PropertyComplex/PropertyInt16")
|
||||||
* .is("<$it/PropertyComplex/PropertyInt16>")
|
.is("<PropertyComplex/PropertyInt16>")
|
||||||
* .isType(EdmTechProvider.nameInt16);
|
.isType(EdmTechProvider.nameInt16);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("PropertyComplex/PropertyComplex/PropertyDate")
|
testFilter.runOnETTwoKeyNav("PropertyComplex/PropertyComplex/PropertyDate")
|
||||||
* .is("<$it/PropertyComplex/PropertyComplex/PropertyDate>")
|
.is("<PropertyComplex/PropertyComplex/PropertyDate>")
|
||||||
* .isType(EdmTechProvider.nameDate);
|
.isType(EdmTechProvider.nameDate);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne")
|
||||||
* .is("<$it/NavPropertyETTwoKeyNavOne>")
|
.is("<NavPropertyETTwoKeyNavOne>")
|
||||||
* .isType(EdmTechProvider.nameETTwoKeyNav);
|
.isType(EdmTechProvider.nameETTwoKeyNav);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyString")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyString")
|
||||||
* .is("<$it/NavPropertyETTwoKeyNavOne/PropertyString>")
|
.is("<NavPropertyETTwoKeyNavOne/PropertyString>")
|
||||||
* .isType(EdmTechProvider.nameString);
|
.isType(EdmTechProvider.nameString);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex")
|
||||||
* .is("<$it/NavPropertyETTwoKeyNavOne/PropertyComplex>")
|
.is("<NavPropertyETTwoKeyNavOne/PropertyComplex>")
|
||||||
* .isType(EdmTechProvider.nameCTPrimComp);
|
.isType(EdmTechProvider.nameCTPrimComp);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex")
|
||||||
* .is("<$it/NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex>")
|
.is("<NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex>")
|
||||||
* .isType(EdmTechProvider.nameCTAllPrim);
|
.isType(EdmTechProvider.nameCTAllPrim);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16")
|
||||||
* .is("<$it/NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16>")
|
.is("<NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16>")
|
||||||
* .isType(EdmTechProvider.nameInt16);
|
.isType(EdmTechProvider.nameInt16);
|
||||||
*
|
|
||||||
* testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16 eq 1")
|
testFilter.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16 eq 1")
|
||||||
* .is("<<$it/NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16> eq <1>>")
|
.is("<<NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyInt16> eq <1>>")
|
||||||
* .root().left()
|
.root().left()
|
||||||
* .isType(EdmTechProvider.nameInt16)
|
.isType(EdmTechProvider.nameInt16)
|
||||||
* .root().right()
|
.root().right()
|
||||||
* .isLiteral("1");
|
.isLiteral("1");
|
||||||
*
|
|
||||||
* // testFilter
|
// testFilter
|
||||||
* // .runOnETTwoKeyNav(
|
// .runOnETTwoKeyNav(
|
||||||
* // "NavPropertyETKeyNavMany(1)/NavPropertyETTwoKeyNavMany(PropertyString='2')/PropertyString eq 'SomeString'");
|
// "NavPropertyETKeyNavMany(1)/NavPropertyETTwoKeyNavMany(PropertyString='2')/PropertyString eq 'SomeString'");
|
||||||
* 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("<<$it/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()
|
||||||
* .isType(EdmTechProvider.nameDate)
|
.isType(EdmTechProvider.nameDate)
|
||||||
* .root().right()
|
.isMember().goPath()
|
||||||
* .isLiteral("2013-11-12");
|
.first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
*
|
.isType(EdmTechTestProvider.nameETTwoKeyNav).isTypeFilterOnEntry(EdmTechTestProvider.nameETBaseTwoKeyNav)
|
||||||
* testFilter.runOnCTTwoPrim("com.sap.odata.test1.CTBase/AdditionalPropString eq 'SomeString'")
|
.n().isPrimitiveProperty("PropertyDate", EdmTechTestProvider.nameDate, false)
|
||||||
* .is("<<$it/com.sap.odata.test1.CTBase/AdditionalPropString> eq <'SomeString'>>")
|
.goUpFilterValidator()
|
||||||
* .root().left()
|
.root().right()
|
||||||
* .isType(EdmTechProvider.nameString)
|
.isLiteral("2013-11-12");
|
||||||
* .root().right()
|
|
||||||
* .isLiteral("'SomeString'");
|
testFilter.runOnCTTwoPrim("com.sap.odata.test1.CTBase/AdditionalPropString eq 'SomeString'")
|
||||||
*
|
.is("<<com.sap.odata.test1.CTTwoPrim/com.sap.odata.test1.CTBase/AdditionalPropString> eq <'SomeString'>>")
|
||||||
* testFilter
|
.root().left()
|
||||||
* .runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate eq 2013-11-12")
|
.isType(EdmTechProvider.nameString)
|
||||||
* .is("<<$it/NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate> eq <2013-11-12>>")
|
.isMember().goPath()
|
||||||
* .root().left()
|
.first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
* .isType(EdmTechProvider.nameDate)
|
.isType(EdmTechTestProvider.nameCTTwoPrim).isTypeFilterOnEntry(EdmTechTestProvider.nameCTBase)
|
||||||
* .root().right()
|
.n().isPrimitiveProperty("AdditionalPropString", EdmTechTestProvider.nameString, false)
|
||||||
* .isLiteral("2013-11-12");
|
.goUpFilterValidator()
|
||||||
*/
|
.root().right()
|
||||||
|
.isLiteral("'SomeString'");
|
||||||
|
|
||||||
|
testFilter
|
||||||
|
.runOnETTwoKeyNav("NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate eq 2013-11-12")
|
||||||
|
.is("<<NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate> eq <2013-11-12>>")
|
||||||
|
.root().left()
|
||||||
|
.isType(EdmTechProvider.nameDate)
|
||||||
|
.root().right()
|
||||||
|
.isLiteral("2013-11-12");
|
||||||
|
|
||||||
testFilter
|
testFilter
|
||||||
.runOnETTwoKeyNav("PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase/AdditionalPropString eq 'SomeString'")
|
.runOnETTwoKeyNav("PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase/AdditionalPropString eq 'SomeString'")
|
||||||
.is("<<PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase/AdditionalPropString> eq <'SomeString'>>")
|
.is("<<PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase/AdditionalPropString> eq <'SomeString'>>")
|
||||||
|
@ -3208,7 +3226,7 @@ public class TestFullResourcePath {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void TestFilterProperties() throws UriParserException {
|
public void testFilterProperties() throws UriParserException {
|
||||||
// testFilter.runOnETAllPrim("XPropertyByte mod 0");
|
// testFilter.runOnETAllPrim("XPropertyByte mod 0");
|
||||||
// testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTETTwoKeyNavParamCTTwoPrim(ParameterCTTwoPrim=@ParamAlias)");
|
// testFilter.runOnETAllPrim("com.sap.odata.test1.UFCRTETTwoKeyNavParamCTTwoPrim(ParameterCTTwoPrim=@ParamAlias)");
|
||||||
|
|
||||||
|
@ -3257,7 +3275,7 @@ public class TestFullResourcePath {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void TestFilterPMethods() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
public void testFilterPMethods() throws ExceptionVisitExpression, ODataApplicationException, UriParserException {
|
||||||
|
|
||||||
testFilter.runOnETKeyNav("indexof(PropertyString,'47') eq 5")
|
testFilter.runOnETKeyNav("indexof(PropertyString,'47') eq 5")
|
||||||
.is("<<indexof(<PropertyString>,<'47'>)> eq <5>>")
|
.is("<<indexof(<PropertyString>,<'47'>)> eq <5>>")
|
||||||
|
@ -4169,7 +4187,7 @@ 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>>>")
|
||||||
|
@ -4395,7 +4413,8 @@ public class TestFullResourcePath {
|
||||||
testFilter.runOnETAllPrim("PropertyDateTimeOffset eq 2013-09-25T12:34:56.123456789012-10:24")
|
testFilter.runOnETAllPrim("PropertyDateTimeOffset eq 2013-09-25T12:34:56.123456789012-10:24")
|
||||||
.is("<<PropertyDateTimeOffset> eq <2013-09-25T12:34:56.123456789012-10:24>>")
|
.is("<<PropertyDateTimeOffset> eq <2013-09-25T12:34:56.123456789012-10:24>>")
|
||||||
.isBinary(SupportedBinaryOperators.EQ)
|
.isBinary(SupportedBinaryOperators.EQ)
|
||||||
.root().left().goPath().isPrimitiveProperty("PropertyDateTimeOffset", EdmTechProvider.nameDateTimeOffset, false)
|
.root().left().goPath()
|
||||||
|
.isPrimitiveProperty("PropertyDateTimeOffset", EdmTechProvider.nameDateTimeOffset, false)
|
||||||
.goUpFilterValidator()
|
.goUpFilterValidator()
|
||||||
.root().right().isLiteral("2013-09-25T12:34:56.123456789012-10:24");
|
.root().right().isLiteral("2013-09-25T12:34:56.123456789012-10:24");
|
||||||
|
|
||||||
|
@ -4462,7 +4481,7 @@ 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'")
|
||||||
|
@ -4784,6 +4803,7 @@ public class TestFullResourcePath {
|
||||||
.isSortOrder(0, true)
|
.isSortOrder(0, true)
|
||||||
.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
|
// XPropertyInt16 1
|
||||||
// XPropertyInt16, PropertyInt32 PropertyDuration
|
// XPropertyInt16, PropertyInt32 PropertyDuration
|
||||||
// XPropertyInt16 PropertyInt32, PropertyDuration desc
|
// XPropertyInt16 PropertyInt32, PropertyDuration desc
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class TestLexer {
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
//test.log(1).run("$metadata?$format=atom#asdfaf");
|
//test.log(1).run("ESTwoKeyNav?$filter=CollPropertyComplex/all( l :true)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
// ;------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1365,28 +1365,5 @@ public class TestParser {
|
||||||
+ "searchExpr(searchWord(abc)))))))))) <EOF>)");
|
+ "searchExpr(searchWord(abc)))))))))) <EOF>)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 2. Query Options
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 4. Expressions
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 5. JSON format for function parameters
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 6. Names and identifiers
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 7. Literal Data Values
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
// ; 0. misc
|
|
||||||
// ;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,4 +994,72 @@ public class TestUriParserImpl {
|
||||||
testUri.run("ESAllPrim(1)/PropertyString/$value");
|
testUri.run("ESAllPrim(1)/PropertyString/$value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMemberStartingWithCast() {
|
||||||
|
// on EntityType entry
|
||||||
|
// TODO inform OTTO
|
||||||
|
testUri.run("ESTwoKeyNav(ParameterInt16=1,PropertyString='ABC')?"
|
||||||
|
+ "$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
|
||||||
|
.goFilter().root().isMember().goPath()
|
||||||
|
.at(0)
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isType(EdmTechTestProvider.nameETTwoKeyNav, false)
|
||||||
|
.isTypeFilterOnEntry(EdmTechTestProvider.nameETBaseTwoKeyNav)
|
||||||
|
.at(1).isType(EdmTechTestProvider.nameDate);
|
||||||
|
|
||||||
|
// on EntityType collection
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
|
||||||
|
.goFilter().root().isMember().goPath()
|
||||||
|
.at(0)
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isType(EdmTechTestProvider.nameETTwoKeyNav, true)
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameETBaseTwoKeyNav)
|
||||||
|
.at(1).isType(EdmTechTestProvider.nameDate);
|
||||||
|
|
||||||
|
testUri.run("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
|
||||||
|
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
|
||||||
|
.goFilter().root().isMember().goPath()
|
||||||
|
.at(0)
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isType(EdmTechTestProvider.nameCTTwoPrim, false)
|
||||||
|
.isTypeFilterOnEntry(EdmTechTestProvider.nameCTBase)
|
||||||
|
.at(1).isType(EdmTechTestProvider.nameString);
|
||||||
|
|
||||||
|
// on Complex collection
|
||||||
|
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
|
||||||
|
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
|
||||||
|
.goFilter().root().isMember().goPath()
|
||||||
|
.at(0)
|
||||||
|
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
|
||||||
|
.isType(EdmTechTestProvider.nameCTTwoPrim, true)
|
||||||
|
.isTypeFilterOnCollection(EdmTechTestProvider.nameCTBase)
|
||||||
|
.at(1).isType(EdmTechTestProvider.nameString);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testComplexTypeCastFollowingAsCollection() {
|
||||||
|
// TODO inform OTTO
|
||||||
|
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/com.sap.odata.test1.CTBase");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLambda() {
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/all( l : true )")
|
||||||
|
.goFilter().is("<CollPropertyComplex/<ALL;<true>>>");
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( l : true )")
|
||||||
|
.goFilter().is("<CollPropertyComplex/<ANY;<true>>>");
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( )")
|
||||||
|
.goFilter().is("<CollPropertyComplex/<ANY;>>");
|
||||||
|
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=all( l : true )")
|
||||||
|
.goFilter().is("<<ALL;<true>>>");
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=any( l : true )")
|
||||||
|
.goFilter().is("<<ANY;<true>>>");
|
||||||
|
testUri.run("ESTwoKeyNav?$filter=any( )")
|
||||||
|
.goFilter().is("<<ANY;>>");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue