diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionNode.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionNode.java deleted file mode 100644 index fefdfd332..000000000 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionNode.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.odata4.server.api.uri.optiontree; - -import java.util.List; - -import org.apache.olingo.odata4.server.api.uri.UriResourceProperty; -import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption; - -/** - * Contains the merged $expand and $select options - */ -public interface OptionNode { - - /** - * Contains the list of non navigation properties which should serialized at this expand level. - */ - List getPropertyChainList(); - - List getExpandetNavigationProperties(); - - /** - * Contains the filter which should be applied to this expand level. - */ - FilterOption getFilter(); - - /** - * Contains the search information which should be applied to this expand level. - */ - SearchOption getSearch(); - - /** - * Contains the orderBy information which should be applied to this expand level. - */ - OrderByOption getOrderBy(); - - /** - * Contains the information about how many output entities should be skipped at this - * expand level. - */ - SkipOption getSkip(); - - /** - * Contains the information about how many output items should be serialized at this - * expand level. - */ - TopOption getTop(); - - /** - * Contains the information whether the number of output items should be serialized - * at this expand level - */ - InlineCountOption getInlineCount(); - -} diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionProperty.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionProperty.java deleted file mode 100644 index 62be0197f..000000000 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/optiontree/OptionProperty.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.odata4.server.api.uri.optiontree; - -import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty; - -public interface OptionProperty { - EdmNavigationProperty getNavigationProperty(); - - OptionNode getOptionNode(); -} diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java index 9e78538b8..8ac5b7185 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/FormatOption.java @@ -20,6 +20,6 @@ package org.apache.olingo.odata4.server.api.uri.queryoption; public interface FormatOption extends SystemQueryOption { - // TODO Select best representation for format + // TODO planned: define best representation for format String getFormat(); } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/LevelsExpandOption.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/LevelsExpandOption.java index 3863813bb..b52d93bd1 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/LevelsExpandOption.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/LevelsExpandOption.java @@ -22,6 +22,6 @@ public interface LevelsExpandOption { boolean isMax(); - int getLevel(); + int getValue(); } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryExpression.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryExpression.java index db3d8aab5..ae1f1acbd 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryExpression.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryExpression.java @@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; public interface BinaryExpression extends Expression { - public SupportedBinaryOperators getOperator(); + public BinaryOperatorKind getOperator(); public Expression getLeftOperand(); diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedBinaryOperators.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryOperatorKind.java similarity index 84% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedBinaryOperators.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryOperatorKind.java index bfc794e66..8ec781c4c 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedBinaryOperators.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/BinaryOperatorKind.java @@ -18,7 +18,8 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; -public enum SupportedBinaryOperators { + +public enum BinaryOperatorKind { // enum HAS("has"), @@ -35,12 +36,12 @@ public enum SupportedBinaryOperators { private String syntax; - private SupportedBinaryOperators(final String syntax) { + private BinaryOperatorKind(final String syntax) { this.syntax = syntax; } - public static SupportedBinaryOperators get(final String operator) { - for (SupportedBinaryOperators op : SupportedBinaryOperators.values()) { + public static BinaryOperatorKind get(final String operator) { + for (BinaryOperatorKind op : BinaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Constant.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Constant.java deleted file mode 100644 index 85db5b761..000000000 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Constant.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.odata4.server.api.uri.queryoption.expression; - -import org.apache.olingo.odata4.commons.api.edm.EdmType; - -public interface Constant extends Expression { - - public boolean isNull(); - - public boolean isTrue(); - - public boolean isFalse(); - - public SupportedConstants getKind(); - - public EdmType getType(); - -} diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExceptionVisitExpression.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitException.java similarity index 94% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExceptionVisitExpression.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitException.java index 2f5b35d50..34926a704 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExceptionVisitExpression.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitException.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; -public class ExceptionVisitExpression extends Exception { +public class ExpressionVisitException extends Exception { private static final long serialVersionUID = 1L; diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitor.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitor.java index 068624d18..d4bfc9fab 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitor.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/ExpressionVisitor.java @@ -27,30 +27,31 @@ import org.apache.olingo.odata4.server.api.uri.UriInfoResource; public interface ExpressionVisitor { - T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right) - throws ExceptionVisitExpression, ODataApplicationException; + T visitBinaryOperator(BinaryOperatorKind operator, T left, T right) + throws ExpressionVisitException, ODataApplicationException; - T visitUnaryOperator(SupportedUnaryOperators operator, T operand) - throws ExceptionVisitExpression, ODataApplicationException; + T visitUnaryOperator(UnaryOperatorKind operator, T operand) + throws ExpressionVisitException, ODataApplicationException; + + + T visitMethodCall(MethodCallKind methodCall, List parameters) + throws ExpressionVisitException, ODataApplicationException; - T visitMethodCall(SupportedMethodCalls methodCall, List parameters) - throws ExceptionVisitExpression, ODataApplicationException; T visitLambdaExpression(String functionText, String variableText, Expression expression) - throws ExceptionVisitExpression, ODataApplicationException; + throws ExpressionVisitException, ODataApplicationException; - T visitLiteral(String literal) throws ExceptionVisitExpression, ODataApplicationException; + T visitLiteral(String literal) throws ExpressionVisitException, ODataApplicationException; - T visitMember(UriInfoResource member) throws ExceptionVisitExpression, ODataApplicationException; + T visitMember(UriInfoResource member) throws ExpressionVisitException, ODataApplicationException; - T visitAlias(String referenceName) throws ExceptionVisitExpression, ODataApplicationException; + T visitAlias(String referenceName) throws ExpressionVisitException, ODataApplicationException; - T visitTypeLiteral(EdmType type) throws ExceptionVisitExpression, ODataApplicationException; + T visitTypeLiteral(EdmType type) throws ExpressionVisitException, ODataApplicationException; - T visitLambdaReference(String variableText) throws ExceptionVisitExpression, ODataApplicationException; + T visitLambdaReference(String variableText) throws ExpressionVisitException, ODataApplicationException; - T visitEnum(EdmEnumType type, List enumValues) throws ExceptionVisitExpression, ODataApplicationException; + T visitEnum(EdmEnumType type, List enumValues) throws ExpressionVisitException, ODataApplicationException; - T visitConstant(SupportedConstants kind) throws ExceptionVisitExpression, ODataApplicationException; } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Literal.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Literal.java index 84fa46589..e83e37524 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Literal.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/Literal.java @@ -18,8 +18,12 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.edm.EdmType; + public interface Literal extends Expression { public String getText(); + public EdmType getType(); + } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCall.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCall.java index 58450d0a6..8b072ba62 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCall.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCall.java @@ -22,7 +22,7 @@ import java.util.List; public interface MethodCall extends Expression { - public SupportedMethodCalls getMethod(); + public MethodCallKind getMethod(); public List getParameters(); diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedMethodCalls.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCallKind.java similarity index 89% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedMethodCalls.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCallKind.java index d18fa49fb..ae2b6374a 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedMethodCalls.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/MethodCallKind.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; -public enum SupportedMethodCalls { +public enum MethodCallKind { CONTAINS("contains"), STARTSWITH("startswith"), ENDSWITH("endswith"), LENGTH("length"), INDEXOF("indexof"), SUBSTRING("substring"), TOLOWER("tolower"), TOUPPER("toupper"), TRIM("trim"), CONCAT("concat"), @@ -35,7 +35,7 @@ public enum SupportedMethodCalls { private String syntax; - private SupportedMethodCalls(final String syntax) { + private MethodCallKind(final String syntax) { this.syntax = syntax; } @@ -44,8 +44,10 @@ public enum SupportedMethodCalls { return syntax; } - public static SupportedMethodCalls get(final String method) { - for (SupportedMethodCalls op : SupportedMethodCalls.values()) { + + public static MethodCallKind get(final String method) { + for (MethodCallKind op : MethodCallKind.values()) { + if (op.toString().equals(method)) { return op; } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedConstants.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedConstants.java deleted file mode 100644 index 33aeacbbe..000000000 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedConstants.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.odata4.server.api.uri.queryoption.expression; - -public enum SupportedConstants { - - TRUE("true"), - FALSE("false"), - NULL("null"); - - private String syntax; - - private SupportedConstants(final String syntax) { - this.syntax = syntax; - } - - public static SupportedConstants get(final String operator) { - for (SupportedConstants op : SupportedConstants.values()) { - if (op.toString().equals(operator)) { - return op; - } - } - return null; - } - - @Override - public String toString() { - return syntax; - } - -} diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperator.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperator.java index 1b4cf8726..cf409b2e5 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperator.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperator.java @@ -22,6 +22,6 @@ public interface UnaryOperator extends Expression { public Expression getOperand(); - public SupportedUnaryOperators getOperator(); + public UnaryOperatorKind getOperator(); } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedUnaryOperators.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperatorKind.java similarity index 82% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedUnaryOperators.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperatorKind.java index 917938ed1..181fd59c3 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/SupportedUnaryOperators.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/UnaryOperatorKind.java @@ -18,12 +18,12 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.expression; -public enum SupportedUnaryOperators { +public enum UnaryOperatorKind { MINUS("-"), NOT("not"); private String syntax; - private SupportedUnaryOperators(final String syntax) { + private UnaryOperatorKind(final String syntax) { this.syntax = syntax; } @@ -32,8 +32,8 @@ public enum SupportedUnaryOperators { return syntax; } - public static SupportedUnaryOperators get(final String operator) { - for (SupportedUnaryOperators op : SupportedUnaryOperators.values()) { + public static UnaryOperatorKind get(final String operator) { + for (UnaryOperatorKind op : UnaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/VisitableExression.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/VisitableExression.java index c480aff21..b8a04f8c3 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/VisitableExression.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/expression/VisitableExression.java @@ -37,11 +37,11 @@ public interface VisitableExression { * expression node of the expression tree. * @return * Object of type T which should be passed to the processing algorithm of the parent expression node - * @throws ExceptionVisitExpression + * @throws ExpressionVisitException * Exception occurred the OData library while traversing the tree * @throws ODataApplicationException * Exception thrown by the application who implemented the visitor */ - T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException; + T accept(ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException; } \ No newline at end of file diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinary.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinary.java index 921ad9df1..f702effb0 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinary.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinary.java @@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.api.uri.queryoption.search; public interface SearchBinary extends SearchExpression { - SupportedSearchBinaryOperators getOperator(); + SearchBinaryOperatorKind getOperator(); SearchExpression getLeftOperand(); diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchBinaryOperators.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java similarity index 80% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchBinaryOperators.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java index eb0b65488..1ce795c9d 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchBinaryOperators.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java @@ -18,13 +18,13 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.search; -public enum SupportedSearchBinaryOperators { +public enum SearchBinaryOperatorKind { // and/or AND("and"), OR("or"); private String syntax; - private SupportedSearchBinaryOperators(final String syntax) { + private SearchBinaryOperatorKind(final String syntax) { this.syntax = syntax; } @@ -33,8 +33,8 @@ public enum SupportedSearchBinaryOperators { return syntax; } - public static SupportedSearchBinaryOperators get(final String operator) { - for (SupportedSearchBinaryOperators op : SupportedSearchBinaryOperators.values()) { + public static SearchBinaryOperatorKind get(final String operator) { + for (SearchBinaryOperatorKind op : SearchBinaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchUnaryOperators.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java similarity index 80% rename from odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchUnaryOperators.java rename to odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java index e6fa773ab..4f3effffd 100644 --- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SupportedSearchUnaryOperators.java +++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java @@ -18,12 +18,12 @@ */ package org.apache.olingo.odata4.server.api.uri.queryoption.search; -public enum SupportedSearchUnaryOperators { +public enum SearchUnaryOperatorKind { NOT("not"); private String syntax; - private SupportedSearchUnaryOperators(final String syntax) { + private SearchUnaryOperatorKind(final String syntax) { this.syntax = syntax; } @@ -32,8 +32,8 @@ public enum SupportedSearchUnaryOperators { return syntax; } - public static SupportedSearchUnaryOperators get(final String operator) { - for (SupportedSearchUnaryOperators op : SupportedSearchUnaryOperators.values()) { + public static SearchUnaryOperatorKind get(final String operator) { + for (SearchUnaryOperatorKind op : SearchUnaryOperatorKind.values()) { if (op.toString().equals(operator)) { return op; } diff --git a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriLexer.g4 b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriLexer.g4 index 33e729659..eee648602 100644 --- a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriLexer.g4 +++ b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriLexer.g4 @@ -134,8 +134,8 @@ BOOLEAN : T R U E | F A L S E; PLUS : '+'; SIGN : PLUS | '%2B' |'-'; INT : SIGN? DIGITS; -DECIMAL : INT '.' DIGITS ('e' SIGN? DIGITS)?; - +DECIMAL : INT '.' DIGITS (('e'|'E') SIGN? DIGITS)?; +NANINFINITY : 'NaN' | '-INF' | 'INF'; //primary types BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE; DATE : YEAR '-' MONTH '-' DAY; @@ -185,7 +185,6 @@ OR : 'or'; NOT : 'not'; MINUS :'-'; -NANINFINITY : 'NaN' | '-INF' | 'INF'; IT : '$it'; ITSLASH : '$it/'; @@ -391,7 +390,7 @@ fragment DIGIT_g : '0'..'9'; fragment DIGITS_g : DIGIT_g+; SIGN_g : ('+' | '%2B' |'-') -> type(SIGN); INT_g : SIGN_g? DIGITS_g -> type(INT); -DECIMAL_g : INT_g '.' DIGITS_g ('e' SIGN_g? DIGITS_g)? -> type(DECIMAL); +DECIMAL_g : 'SS' INT_g '.' DIGITS_g (('e'|'E') SIGN_g? DIGITS_g)? -> type(DECIMAL); COLLECTION_g : C_ O_ L_ L_ E_ C_ T_ I_ O_ N_ -> type(COLLECTION); LINESTRING : L_ I_ N_ E_ S_ T_ R_ I_ N_ G_ ; MULTILINESTRING : M_ U_ L_ T_ I_ L_ I_ N_ E_ S_ T_ R_ I_ N_ G_; diff --git a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 index c9c627b27..0b246cba9 100644 --- a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 +++ b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 @@ -347,6 +347,7 @@ odataIdentifier : ODATAIDENTIFIER; primitiveLiteral : nullrule | booleanNonCase | DECIMAL //includes double and single literals + | NANINFINITY | INT //includes int16/int32 and int64 literals | BINARY | DATE diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/apiimpl/UriInfoImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/apiimpl/UriInfoImpl.java index 574c2a67e..af1130a71 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/apiimpl/UriInfoImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/apiimpl/UriInfoImpl.java @@ -46,12 +46,12 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SkipTokenOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption; +import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.SearchOptionImpl; @@ -74,7 +74,7 @@ public class UriInfoImpl implements UriInfo { private FilterOptionImpl filterOption; private FormatOptionImpl formatOption; private IdOption idOption; - private InlineCountOptionImpl inlineCountOption; + private CountOptionImpl inlineCountOption; private OrderByOptionImpl orderByOption; private SearchOptionImpl searchOption; private SelectOptionImpl selectOption; @@ -257,7 +257,7 @@ public class UriInfoImpl implements UriInfo { } else if (systemOption.getKind() == SupportedQueryOptions.ID) { idOption = (IdOptionImpl) systemOption; } else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) { - inlineCountOption = (InlineCountOptionImpl) systemOption; + inlineCountOption = (CountOptionImpl) systemOption; } else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) { orderByOption = (OrderByOptionImpl) systemOption; } else if (systemOption.getKind() == SupportedQueryOptions.SEARCH) { diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/CheckFullContextListener.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/CheckFullContextListener.java new file mode 100644 index 000000000..bc68f7b2f --- /dev/null +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/CheckFullContextListener.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ******************************************************************************/ +package org.apache.olingo.odata4.server.core.uri.parser; + +import java.util.BitSet; + +import org.antlr.v4.runtime.DiagnosticErrorListener; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; +import org.antlr.v4.runtime.atn.ATNConfigSet; +import org.antlr.v4.runtime.dfa.DFA; + +class CheckFullContextListener extends DiagnosticErrorListener { + + @Override + public void syntaxError(final Recognizer recognizer, final Object offendingSymbol, final int line, + final int charPositionInLine, + final String msg, final RecognitionException e) { + // System.err.println("syntaxError detected"); + } + + @Override + public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex, + final boolean exact, + final BitSet ambigAlts, final ATNConfigSet configs) { + // System.err.println("reportAmbiguity detected"); + } + + @Override + public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex, + final int stopIndex, + final BitSet conflictingAlts, final ATNConfigSet configs) { + // System.err.println("reportAttemptingFullContext detected"); + } + + @Override + public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex, + final int stopIndex, final int prediction, + final ATNConfigSet configs) { + // System.err.println("reportContextSensitivity detected"); + } + +} \ No newline at end of file diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java index a13d3fd71..5f7b42a66 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/Parser.java @@ -50,12 +50,12 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.PathSegmen import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.SelectEOFContext; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl; +import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl; @@ -198,7 +198,7 @@ public class Parser { idOption.setValue(option.value); context.contextUriInfo.setSystemQueryOption(idOption); } else if (option.name.equals("$inlinecount")) { - InlineCountOptionImpl inlineCountOption = new InlineCountOptionImpl(); + CountOptionImpl inlineCountOption = new CountOptionImpl(); inlineCountOption.setName(option.name); inlineCountOption.setText(option.value); inlineCountOption.setValue(option.value.equals("true") ? true : false); @@ -212,7 +212,7 @@ public class Parser { context.contextUriInfo.setSystemQueryOption(filterOption); } else if (option.name.equals("$search")) { - // TODO not supported yet + // TODO $search is not supported yet } else if (option.name.equals("$select")) { SelectEOFContext ctxSelectEOF = (SelectEOFContext) parseRule(option.value, ParserEntryRules.Select); @@ -241,7 +241,7 @@ public class Parser { context.contextUriInfo.setSystemQueryOption(inlineCountOption); } else if (option.name.equals("$count")) { // todo create CountOption - InlineCountOptionImpl inlineCountOption = new InlineCountOptionImpl(); + CountOptionImpl inlineCountOption = new CountOptionImpl(); inlineCountOption.setName(option.name); inlineCountOption.setText(option.value); inlineCountOption.setValue(option.value.equals("true") ? true : false); @@ -253,7 +253,7 @@ public class Parser { if (option.value.equals("max")) { inlineCountOption.setMax(); } else { - inlineCountOption.setLevel(Integer.parseInt(option.value)); + inlineCountOption.setValue(Integer.parseInt(option.value)); } context.contextUriInfo.setSystemQueryOption(inlineCountOption); @@ -428,6 +428,8 @@ public class Parser { protected void addStage1ErrorListener(final UriParserParser parser) { // No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy) parser.removeErrorListeners(); + parser.addErrorListener(new CheckFullContextListener()); + } protected void addStage2ErrorListener(final UriParserParser parser) { diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java index 460705d6d..48f2fb110 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java @@ -45,9 +45,8 @@ import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeK import org.apache.olingo.odata4.server.api.uri.UriInfoKind; import org.apache.olingo.odata4.server.api.uri.UriResource; import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; import org.apache.olingo.odata4.server.core.uri.UriParserException; import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException; import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer; @@ -162,11 +161,11 @@ import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceTypedImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceValueImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.AliasQueryOptionImpl; +import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandItemImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByItemImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; @@ -178,7 +177,6 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.SkipTokenOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.SystemQueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.TopOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.BinaryImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ConstantImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.EnumerationImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl; @@ -202,8 +200,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.TypeLiter * Not supported *
  • Parsing the context of $metadata * - * TODO - *
  • clean up + * TODO planned *
  • Overview testcases *
  • search */ @@ -686,9 +683,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { int tokenIndex = ctx.vO.getType(); if (tokenIndex == UriLexer.ADD) { - binary.setOperator(SupportedBinaryOperators.ADD); + binary.setOperator(BinaryOperatorKind.ADD); } else if (tokenIndex == UriLexer.SUB) { - binary.setOperator(SupportedBinaryOperators.SUB); + binary.setOperator(BinaryOperatorKind.SUB); } binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); @@ -711,7 +708,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { public ExpressionImpl visitAltAnd(final AltAndContext ctx) { BinaryImpl binary = new BinaryImpl(); - binary.setOperator(SupportedBinaryOperators.AND); + binary.setOperator(BinaryOperatorKind.AND); binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this)); @@ -741,13 +738,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { int tokenIndex = ctx.vO.getType(); if (tokenIndex == UriLexer.GT) { - binary.setOperator(SupportedBinaryOperators.GT); + binary.setOperator(BinaryOperatorKind.GT); } else if (tokenIndex == UriLexer.GE) { - binary.setOperator(SupportedBinaryOperators.GE); + binary.setOperator(BinaryOperatorKind.GE); } else if (tokenIndex == UriLexer.LT) { - binary.setOperator(SupportedBinaryOperators.LT); + binary.setOperator(BinaryOperatorKind.LT); } else if (tokenIndex == UriLexer.LE) { - binary.setOperator(SupportedBinaryOperators.LE); + binary.setOperator(BinaryOperatorKind.LE); } binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); @@ -783,9 +780,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { int tokenIndex = ctx.vO.getType(); if (tokenIndex == UriLexer.EQ_ALPHA) { - binary.setOperator(SupportedBinaryOperators.EQ); + binary.setOperator(BinaryOperatorKind.EQ); } else { - binary.setOperator(SupportedBinaryOperators.NE); + binary.setOperator(BinaryOperatorKind.NE); } binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this)); @@ -797,7 +794,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { public Object visitAltHas(final AltHasContext ctx) { BinaryImpl binary = new BinaryImpl(); - binary.setOperator(SupportedBinaryOperators.HAS); + binary.setOperator(BinaryOperatorKind.HAS); binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this)); @@ -819,11 +816,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { int tokenIndex = ctx.vO.getType(); if (tokenIndex == UriLexer.MUL) { - binary.setOperator(SupportedBinaryOperators.MUL); + binary.setOperator(BinaryOperatorKind.MUL); } else if (tokenIndex == UriLexer.DIV) { - binary.setOperator(SupportedBinaryOperators.DIV); + binary.setOperator(BinaryOperatorKind.DIV); } else { - binary.setOperator(SupportedBinaryOperators.MOD); + binary.setOperator(BinaryOperatorKind.MOD); } binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this)); @@ -835,7 +832,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { public ExpressionImpl visitAltOr(final AltOrContext ctx) { BinaryImpl binary = new BinaryImpl(); - binary.setOperator(SupportedBinaryOperators.OR); + binary.setOperator(BinaryOperatorKind.OR); binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this)); binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this)); @@ -869,9 +866,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { String text = ctx.getText().toLowerCase(); if (text.equals("false")) { - return new ConstantImpl().setKind(SupportedConstants.FALSE); + return new LiteralImpl().setText("false").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance()); } - return new ConstantImpl().setKind(SupportedConstants.TRUE); + return new LiteralImpl().setText("true").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance()); } @Override @@ -888,7 +885,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { FullQualifiedName fullName = new FullQualifiedName(namespace, ctx.vODI.getText()); EdmType type = getType(fullName); - method.setMethod(SupportedMethodCalls.CAST); + method.setMethod(MethodCallKind.CAST); method.addParameter(new TypeLiteralImpl().setType(type)); return method; } @@ -926,14 +923,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitCeilingMethodCallExpr(final CeilingMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.CEILING) + .setMethod(MethodCallKind.CEILING) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitConcatMethodCallExpr(final ConcatMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.CONCAT) + .setMethod(MethodCallKind.CONCAT) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -988,7 +985,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitContainsMethodCallExpr(final ContainsMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.CONTAINS) + .setMethod(MethodCallKind.CONTAINS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -1008,21 +1005,21 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public Object visitDateMethodCallExpr(final DateMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.DATE) + .setMethod(MethodCallKind.DATE) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitDayMethodCallExpr(final DayMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.DAY) + .setMethod(MethodCallKind.DAY) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitGeoDistanceMethodCallExpr(final GeoDistanceMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.GEODISTANCE) + .setMethod(MethodCallKind.GEODISTANCE) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -1030,7 +1027,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public Object visitEndsWithMethodCallExpr(final EndsWithMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.ENDSWITH) + .setMethod(MethodCallKind.ENDSWITH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -1083,8 +1080,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { expandItem.setSystemQueryOption(levels); } else if (ctx.vL != null) { // TODO set value as integer - LevelsOptionImpl levels = new LevelsOptionImpl().setMax(); - levels.setText(ctx.vL.getText()); + LevelsOptionImpl levels = new LevelsOptionImpl(); + String text = ctx.vL.getText(); + levels.setText(text); + levels.setValue(Integer.parseInt(text)); expandItem.setSystemQueryOption(levels); } @@ -1204,7 +1203,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitFloorMethodCallExpr(final FloorMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.FLOOR) + .setMethod(MethodCallKind.FLOOR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -1240,45 +1239,45 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.FRACTIONALSECONDS) + .setMethod(MethodCallKind.FRACTIONALSECONDS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitGeoLengthMethodCallExpr(final GeoLengthMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.GEOLENGTH) + .setMethod(MethodCallKind.GEOLENGTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitHourMethodCallExpr(final HourMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.HOUR) + .setMethod(MethodCallKind.HOUR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitIndexOfMethodCallExpr(final IndexOfMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.INDEXOF) + .setMethod(MethodCallKind.INDEXOF) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override public Object visitInlinecount(final InlinecountContext ctx) { - InlineCountOptionImpl inlineCount = new InlineCountOptionImpl(); + CountOptionImpl inlineCount = new CountOptionImpl(); String text = ctx.children.get(2).getText(); - return inlineCount.setValue(text.equals("true") ? true : false).setText(text); + return inlineCount.setValue(text.toLowerCase().equals("true") ? true : false).setText(text); } @Override public ExpressionImpl visitGeoIntersectsMethodCallExpr(final GeoIntersectsMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.GEOINTERSECTS) + .setMethod(MethodCallKind.GEOINTERSECTS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -1296,7 +1295,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { FullQualifiedName fullName = new FullQualifiedName(namespace, ctx.vODI.getText()); EdmType type = getType(fullName); - method.setMethod(SupportedMethodCalls.ISOF); + method.setMethod(MethodCallKind.ISOF); method.addParameter(new TypeLiteralImpl().setType(type)); return method; @@ -1305,7 +1304,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitLengthMethodCallExpr(final LengthMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.LENGTH) + .setMethod(MethodCallKind.LENGTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -1329,7 +1328,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.MAXDATETIME); + .setMethod(MethodCallKind.MAXDATETIME); } @Override @@ -1373,20 +1372,20 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitMinDateTimeMethodCallExpr(final MinDateTimeMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.MINDATETIME); + .setMethod(MethodCallKind.MINDATETIME); } @Override public ExpressionImpl visitMinuteMethodCallExpr(final MinuteMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.MINUTE) + .setMethod(MethodCallKind.MINUTE) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitMonthMethodCallExpr(final MonthMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.MONTH) + .setMethod(MethodCallKind.MONTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -1560,12 +1559,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.NOW); + .setMethod(MethodCallKind.NOW); } @Override public Object visitNullrule(final NullruleContext ctx) { - return new ConstantImpl().setKind(SupportedConstants.NULL); + return new LiteralImpl().setText("null"); } /* @@ -1733,14 +1732,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitRoundMethodCallExpr(final RoundMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.ROUND) + .setMethod(MethodCallKind.ROUND) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitSecondMethodCallExpr(final SecondMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.SECOND) + .setMethod(MethodCallKind.SECOND) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -1997,7 +1996,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitStartsWithMethodCallExpr(final StartsWithMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.STARTSWITH) + .setMethod(MethodCallKind.STARTSWITH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @@ -2005,7 +2004,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitSubstringMethodCallExpr(final SubstringMethodCallExprContext ctx) { MethodCallImpl ret = new MethodCallImpl(); - ret.setMethod(SupportedMethodCalls.SUBSTRING); + ret.setMethod(MethodCallKind.SUBSTRING); ret.addParameter((ExpressionImpl) ctx.vE1.accept(this)); ret.addParameter((ExpressionImpl) ctx.vE2.accept(this)); @@ -2020,7 +2019,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitTimeMethodCallExpr(final TimeMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TIME) + .setMethod(MethodCallKind.TIME) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -2036,35 +2035,35 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitToLowerMethodCallExpr(final ToLowerMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TOLOWER) + .setMethod(MethodCallKind.TOLOWER) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(final TotalOffsetMinutesMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TOTALOFFSETMINUTES) + .setMethod(MethodCallKind.TOTALOFFSETMINUTES) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTotalsecondsMethodCallExpr(final TotalsecondsMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TOTALSECONDS) + .setMethod(MethodCallKind.TOTALSECONDS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitToUpperMethodCallExpr(final ToUpperMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TOUPPER) + .setMethod(MethodCallKind.TOUPPER) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTrimMethodCallExpr(final TrimMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.TRIM) + .setMethod(MethodCallKind.TRIM) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @@ -2077,7 +2076,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) { return new MethodCallImpl() - .setMethod(SupportedMethodCalls.YEAR) + .setMethod(MethodCallKind.YEAR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java similarity index 86% rename from odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java rename to odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java index dd0327e90..b9d6f2cb8 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java @@ -21,11 +21,11 @@ package org.apache.olingo.odata4.server.core.uri.queryoption; import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions; -public class InlineCountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption { +public class CountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption { private boolean count; - public InlineCountOptionImpl() { + public CountOptionImpl() { setKind(SupportedQueryOptions.INLINECOUNT); } @@ -34,7 +34,7 @@ public class InlineCountOptionImpl extends SystemQueryOptionImpl implements Inli return count; } - public InlineCountOptionImpl setValue(final boolean count) { + public CountOptionImpl setValue(final boolean count) { this.count = count; return this; } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java index d4b9179f8..0b7be406c 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java @@ -57,7 +57,7 @@ public class ExpandItemImpl implements ExpandItem { } else if (sysItem.getKind() == SupportedQueryOptions.FILTER) { filterOption = (FilterOptionImpl) sysItem; } else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) { - inlineCountOption = (InlineCountOptionImpl) sysItem; + inlineCountOption = (CountOptionImpl) sysItem; } else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) { orderByOption = (OrderByOptionImpl) sysItem; } else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) { diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java index c55559e98..96ab83191 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java @@ -29,7 +29,7 @@ public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExp setKind(SupportedQueryOptions.LEVELS); } - public LevelsOptionImpl setLevel(final int value) { + public LevelsOptionImpl setValue(final int value) { this.value = value; return this; } @@ -46,7 +46,7 @@ public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExp } @Override - public int getLevel() { + public int getValue() { return value; } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java index 7e356b9d4..fc825a4c8 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java @@ -22,7 +22,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.server.api.uri.queryoption.search.SearchExpression; -/* TODO implement */ +// TODO $search is not supported yet public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOption { public SearchOptionImpl() { @@ -31,7 +31,7 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt @Override public SearchExpression getSearchExpression() { - // TODO $search not supported yet + // TODO $search is not supported yet return null; } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java index 0f83be0a6..41603a3ce 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.AliasExpression; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; public class AliasImpl extends ExpressionImpl implements AliasExpression { @@ -37,7 +37,7 @@ public class AliasImpl extends ExpressionImpl implements AliasExpression { } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitAlias(parameterName); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java index dc6a7afcb..0a6553d12 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java @@ -20,23 +20,23 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryExpression; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; public class BinaryImpl extends ExpressionImpl implements BinaryExpression { - private SupportedBinaryOperators operator; + private BinaryOperatorKind operator; private ExpressionImpl left; private ExpressionImpl right; @Override - public SupportedBinaryOperators getOperator() { + public BinaryOperatorKind getOperator() { return operator; } - public BinaryExpression setOperator(final SupportedBinaryOperators operator) { + public BinaryExpression setOperator(final BinaryOperatorKind operator) { this.operator = operator; return this; } @@ -61,7 +61,7 @@ public class BinaryImpl extends ExpressionImpl implements BinaryExpression { } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { T left = this.left.accept(visitor); T right = this.right.accept(visitor); return visitor.visitBinaryOperator(operator, left, right); diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java deleted file mode 100644 index 64520290f..000000000 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.odata4.server.core.uri.queryoption.expression; - -import org.apache.olingo.odata4.commons.api.ODataApplicationException; -import org.apache.olingo.odata4.commons.api.edm.EdmType; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Constant; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; - -public class ConstantImpl extends ExpressionImpl implements Constant { - - EdmType type; - SupportedConstants kind; - - @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { - return visitor.visitConstant(kind); - } - - @Override - public boolean isNull() { - return kind == SupportedConstants.NULL; - } - - @Override - public boolean isTrue() { - return kind == SupportedConstants.TRUE; - } - - @Override - public boolean isFalse() { - return kind == SupportedConstants.FALSE; - } - - @Override - public EdmType getType() { - return type; - } - - public ConstantImpl setType(final EdmType type) { - this.type = type; - return this; - } - - @Override - public SupportedConstants getKind() { - return kind; - } - - public ConstantImpl setKind(final SupportedConstants kind) { - this.kind = kind; - return this; - } - -} diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java index 762eb9b45..88329897b 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.commons.api.edm.EdmEnumType; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Enumeration; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; public class EnumerationImpl extends ExpressionImpl implements Enumeration { @@ -53,7 +53,7 @@ public class EnumerationImpl extends ExpressionImpl implements Enumeration { } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitEnum(type, values); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java index da61cf0b3..04be11fa8 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java @@ -19,7 +19,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.LambdaRef; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; @@ -39,7 +39,7 @@ public class LambdaRefImpl extends ExpressionImpl implements LambdaRef, Visitabl } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitLambdaReference(variableText); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java index f61cc50d6..cb54f0fc5 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java @@ -19,7 +19,8 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.commons.api.edm.EdmType; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Literal; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; @@ -27,6 +28,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableE public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExression { private String text; + private EdmType type; @Override public String getText() { @@ -39,7 +41,17 @@ public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExr } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public EdmType getType() { + return type; + } + + public LiteralImpl setType(final EdmType type) { + this.type = type; + return this; + } + + @Override + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitLiteral(text); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java index 121f87c4b..ce9c78f43 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java @@ -21,7 +21,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.commons.api.edm.EdmType; import org.apache.olingo.odata4.server.api.uri.UriInfoResource; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; @@ -45,7 +45,7 @@ public class MemberImpl extends ExpressionImpl implements Member, VisitableExres } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitMember(path); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java index ccc5359b4..96e5eb236 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java @@ -22,24 +22,24 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.odata4.commons.api.ODataApplicationException; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCall; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; public class MethodCallImpl extends ExpressionImpl implements MethodCall, VisitableExression { - private SupportedMethodCalls method; + private MethodCallKind method; private List parameters = new ArrayList(); @Override - public SupportedMethodCalls getMethod() { + public MethodCallKind getMethod() { return method; } - public MethodCallImpl setMethod(final SupportedMethodCalls methodCalls) { + public MethodCallImpl setMethod(final MethodCallKind methodCalls) { method = methodCalls; return this; } @@ -59,7 +59,7 @@ public class MethodCallImpl extends ExpressionImpl implements MethodCall, Visita } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { List userParameters = new ArrayList(); for (ExpressionImpl parameter : parameters) { userParameters.add(parameter.accept(visitor)); diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java index 40e510f16..c38afe20f 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.commons.api.edm.EdmType; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.TypeLiteral; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; @@ -40,7 +40,7 @@ public class TypeLiteralImpl extends ExpressionImpl implements TypeLiteral, Visi } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { return visitor.visitTypeLiteral(type); } diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java index 7c8ab2d62..4e233c37a 100644 --- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java +++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java @@ -19,24 +19,24 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.ODataApplicationException; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperator; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression; public class UnaryImpl extends ExpressionImpl implements UnaryOperator, VisitableExression { - private SupportedUnaryOperators operator; + private UnaryOperatorKind operator; private ExpressionImpl expression; @Override - public SupportedUnaryOperators getOperator() { + public UnaryOperatorKind getOperator() { return operator; } - public void setOperator(final SupportedUnaryOperators operator) { + public void setOperator(final UnaryOperatorKind operator) { this.operator = operator; } @@ -50,7 +50,7 @@ public class UnaryImpl extends ExpressionImpl implements UnaryOperator, Visitabl } @Override - public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { T operand = expression.accept(visitor); return visitor.visitUnaryOperator(operator, operand); } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java index bb0ebb585..acedb6fb4 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java @@ -374,11 +374,12 @@ public class EdmTechProvider extends EdmProvider { .setType(nameETMedia); /* - * TODO add stream property + * TODO add propertyStream * Property propertyStream = new Property() * .setName("PropertyStream") * .setType(EdmStream.getFullQualifiedName()); */ + NavigationProperty navPropertyETKeyPrimNavOne = new NavigationProperty() .setName("NavPropertyETKeyPrimNavOne") .setType(nameETKeyPrimNav); @@ -678,7 +679,7 @@ public class EdmTechProvider extends EdmProvider { propertyDecimal, propertySingle, propertyDouble, propertyDuration, propertyGuid, propertyInt16, propertyInt32, propertyInt64, propertySByte, - propertyTimeOfDay/* TODO add steam property */)); + propertyTimeOfDay/* TODO add propertyStream */)); } else if (complexTypeName.equals(nameCTCollAllPrim)) { return new ComplexType() @@ -928,7 +929,7 @@ public class EdmTechProvider extends EdmProvider { propertySingle, propertyDouble, propertyDecimal, propertyBinary, propertyDate, propertyDateTimeOffset, propertyDuration, propertyGuid, - propertyTimeOfDay /* TODO add stream property */)); + propertyTimeOfDay /* TODO add propertyStream */)); } else if (entityTypeName.equals(nameETCollAllPrim)) { return new EntityType() @@ -942,7 +943,7 @@ public class EdmTechProvider extends EdmProvider { collPropertyInt16, collPropertyInt32, collPropertyInt64, collPropertySingle, collPropertyDouble, collPropertyDecimal, collPropertyBinary, collPropertyDate, collPropertyDateTimeOffset, - collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream property */)); + collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add propertyStream */)); } else if (entityTypeName.equals(nameETTwoPrim)) { return new EntityType() @@ -1021,7 +1022,7 @@ public class EdmTechProvider extends EdmProvider { propertyDecimal, propertyDate, propertySingle, propertyDouble, propertyDateTimeOffset, propertyDuration, propertyGuid, - propertyTimeOfDay /* TODO add stream property */)); + propertyTimeOfDay /* TODO add propertyStream */)); } else if (entityTypeName.equals(nameETCompAllPrim)) { return new EntityType() @@ -1093,7 +1094,7 @@ public class EdmTechProvider extends EdmProvider { propertySingle, propertyDouble, propertyDecimal, propertyBinary, propertyDate, propertyDateTimeOffset, - propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add stream property */, + propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add propertyStream */, collPropertyString, collPropertyBoolean, collPropertyByte, collPropertySByte, collPropertyInt16, @@ -1101,7 +1102,7 @@ public class EdmTechProvider extends EdmProvider { collPropertySingle, collPropertyDouble, collPropertyDecimal, collPropertyBinary, collPropertyDate, collPropertyDateTimeOffset, - collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream property */)); + collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add propertyStream */)); } else if (entityTypeName.equals(nameETKeyNav)) { return new EntityType() diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java index db8fc159d..563ec471c 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java @@ -27,10 +27,11 @@ 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.queryoption.ExpandItem; import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; +import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl; @@ -44,8 +45,8 @@ public class ExpandValidator implements Validator { // --- Setup --- - public ExpandValidator setGoUpValidator(final Validator parentValidator) { - invokedByValidator = parentValidator; + public ExpandValidator setUpValidator(final Validator validator) { + invokedByValidator = validator; return this; } @@ -62,27 +63,44 @@ public class ExpandValidator implements Validator { // --- Navigation --- - public UriResourceValidator goPath() { + public ExpandValidator goUpToExpandValidator() { + return (ExpandValidator) invokedByValidator; + } + + public ResourceValidator goUpToUriResourceValidator() { + return (ResourceValidator) invokedByValidator; + } + + public ResourceValidator goPath() { UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourceInfo(); if (uriInfo.getKind() != UriInfoKind.resource) { fail("goPath() can only be used on UriInfoKind.resource"); } - return new UriResourceValidator() + return new ResourceValidator() .setUpValidator(this) .setEdm(edm) .setUriInfoImplPath(uriInfo); } - public UriResourceValidator goSelectItemPath(final int index) { + public FilterValidator goOrder(final int index) { + OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption(); + + return new FilterValidator() + .setValidator(this) + .setEdm(edm) + .setExpression(orderBy.getOrders().get(index).getExpression()); + } + + public ResourceValidator goSelectItem(final int index) { SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption(); SelectItem item = select.getSelectItems().get(index); UriInfoImpl uriInfo = (UriInfoImpl) item.getResourceInfo(); - return new UriResourceValidator() + return new ResourceValidator() .setUpValidator(this) .setEdm(edm) .setUriInfoImplPath(uriInfo); @@ -90,20 +108,12 @@ public class ExpandValidator implements Validator { } public ExpandValidator goExpand() { - ExpandValidator val = new ExpandValidator(); - val.setExpand((ExpandOptionImpl) expandItem.getExpandOption()); - val.setGoUpValidator(this); + ExpandValidator val = new ExpandValidator() + .setExpand((ExpandOptionImpl) expandItem.getExpandOption()) + .setUpValidator(this); return val; } - public ExpandValidator goUpToExpandValidator() { - return (ExpandValidator) invokedByValidator; - } - - public UriResourceValidator goUpToUriResourceValidator() { - return (UriResourceValidator) invokedByValidator; - } - public ExpandValidator first() { expandItemIndex = 0; expandItem = expandOption.getExpandItems().get(expandItemIndex); @@ -170,7 +180,7 @@ public class ExpandValidator implements Validator { return this; } - public ExpandValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) { + public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName fqn) { SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption(); SelectItem item = select.getSelectItems().get(index); @@ -178,7 +188,7 @@ public class ExpandValidator implements Validator { return this; } - public ExpandValidator isFilterText(final String text) { + public ExpandValidator isFilterOptionText(final String text) { QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption(); assertEquals(text, option.getText()); return this; @@ -190,7 +200,7 @@ public class ExpandValidator implements Validator { try { String tmp = FilterTreeToText.Serialize(filter); assertEquals(serialized, tmp); - } catch (ExceptionVisitExpression e) { + } catch (ExpressionVisitException e) { fail("Exception occured while converting the filterTree into text" + "\n" + " Exception: " + e.getMessage()); } catch (ODataApplicationException e) { @@ -201,4 +211,10 @@ public class ExpandValidator implements Validator { return this; } + public ExpandValidator isSortOrder(final int index, final boolean descending) { + OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption(); + assertEquals(descending, orderBy.getOrders().get(index).isDescending()); + return this; + } + } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java index 145d04122..325831c19 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java @@ -29,46 +29,45 @@ import org.apache.olingo.odata4.server.api.uri.UriResourceLambdaAll; import org.apache.olingo.odata4.server.api.uri.UriResourceLambdaAny; import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped; import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind; public class FilterTreeToText implements ExpressionVisitor { public static String Serialize(final FilterOption filter) - throws ExceptionVisitExpression, ODataApplicationException { + throws ExpressionVisitException, ODataApplicationException { Expression expression = filter.getExpression(); return expression.accept(new FilterTreeToText()); } public static String Serialize(final Expression expression) - throws ExceptionVisitExpression, ODataApplicationException { + throws ExpressionVisitException, ODataApplicationException { return expression.accept(new FilterTreeToText()); } @Override - public String visitBinaryOperator(final SupportedBinaryOperators operator, final String left, final String right) - throws ExceptionVisitExpression { + public String visitBinaryOperator(final BinaryOperatorKind operator, final String left, final String right) + throws ExpressionVisitException { return "<" + left + " " + operator.toString() + " " + right + ">"; } @Override - public String visitUnaryOperator(final SupportedUnaryOperators operator, final String operand) - throws ExceptionVisitExpression { + public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand) + throws ExpressionVisitException { return "<" + operator + " " + operand.toString() + ">"; } @Override - public String visitMethodCall(final SupportedMethodCalls methodCall, final List parameters) - throws ExceptionVisitExpression { + public String visitMethodCall(final MethodCallKind methodCall, final List parameters) + throws ExpressionVisitException { String text = "<" + methodCall + "("; int i = 0; @@ -83,12 +82,12 @@ public class FilterTreeToText implements ExpressionVisitor { } @Override - public String visitLiteral(final String literal) throws ExceptionVisitExpression { + public String visitLiteral(final String literal) throws ExpressionVisitException { return "<" + literal + ">"; } @Override - public String visitMember(final UriInfoResource resource) throws ExceptionVisitExpression, ODataApplicationException { + public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException { String ret = ""; UriInfoResource path = resource; @@ -100,7 +99,6 @@ public class FilterTreeToText implements ExpressionVisitor { tmp = visitLambdaExpression("ALL", all.getLamdaVariable(), all.getExpression()); } else if (item instanceof UriResourceLambdaAny) { UriResourceLambdaAny any = (UriResourceLambdaAny) item; - // TODO create enum tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression()); } else if (item instanceof UriResourcePartTyped) { UriResourcePartTyped typed = (UriResourcePartTyped) item; @@ -117,13 +115,13 @@ public class FilterTreeToText implements ExpressionVisitor { } @Override - public String visitAlias(final String referenceName) throws ExceptionVisitExpression { + public String visitAlias(final String referenceName) throws ExpressionVisitException { return "<" + referenceName + ">"; } @Override public String visitLambdaExpression(final String functionText, final String string, final Expression expression) - throws ExceptionVisitExpression, ODataApplicationException { + throws ExpressionVisitException, ODataApplicationException { return "<" + functionText + ";" + ((expression == null) ? "" : expression.accept(this)) + ">"; } @@ -140,7 +138,7 @@ public class FilterTreeToText implements ExpressionVisitor { @Override public String visitEnum(final EdmEnumType type, final List enumValues) - throws ExceptionVisitExpression, ODataApplicationException { + throws ExpressionVisitException, ODataApplicationException { String tmp = ""; for (String item : enumValues) { @@ -153,10 +151,4 @@ public class FilterTreeToText implements ExpressionVisitor { return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>"; } - @Override - public String visitConstant(final SupportedConstants kind) - throws ExceptionVisitExpression, ODataApplicationException { - // TODO Auto-generated method stub - return "<" + kind.toString() + ">"; - } } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java index b85b9a923..f8a79bd95 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java @@ -29,12 +29,11 @@ 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.UriInfo; import org.apache.olingo.odata4.server.api.uri.UriInfoKind; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; import org.apache.olingo.odata4.server.core.uri.UriParserException; import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException; import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException; @@ -43,7 +42,6 @@ import org.apache.olingo.odata4.server.core.uri.parser.Parser; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.BinaryImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ConstantImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.EnumerationImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl; @@ -64,7 +62,7 @@ public class FilterValidator implements Validator { private UriParserException exception; // --- Setup --- - public FilterValidator setUriResourcePathValidator(final UriResourceValidator uriResourcePathValidator) { + public FilterValidator setUriResourcePathValidator(final ResourceValidator uriResourcePathValidator) { invokedByValidator = uriResourcePathValidator; return this; } @@ -74,6 +72,11 @@ public class FilterValidator implements Validator { return this; } + public FilterValidator setValidator(final Validator uriValidator) { + invokedByValidator = uriValidator; + return this; + } + public FilterValidator setEdm(final Edm edm) { this.edm = edm; return this; @@ -118,14 +121,17 @@ public class FilterValidator implements Validator { } public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException { - // TODO change to ESTwoKeyNav + String uri = "ESTwoKeyNav?$filter=" + filter.trim(); + return runUri(uri); + } + + public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws UriParserException { String uri = "SINav?$filter=" + filter.trim(); return runUri(uri); } public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException { - // TODO change to ESTwoKeyNav - String uri = "SINav?$filter=" + filter.trim(); + String uri = "ESTwoKeyNav?$filter=" + filter.trim(); return runUriEx(uri); } @@ -249,27 +255,31 @@ public class FilterValidator implements Validator { // --- Navigation --- - public Validator goUp() { - return invokedByValidator; + public ExpandValidator goUpToExpandValidator() { + return (ExpandValidator) invokedByValidator; } - public UriResourceValidator goPath() { + public ResourceValidator goUpToResourceValidator() { + return (ResourceValidator) invokedByValidator; + } + + public ResourceValidator goPath() { if (!(curExpression instanceof MemberImpl)) { fail("Current expression not a member"); } MemberImpl member = (MemberImpl) curExpression; - UriResourceValidator uriValidator = new UriResourceValidator(); - uriValidator.setEdm(edm); - uriValidator.setUriInfoImplPath((UriInfoImpl) member.getPath()); - uriValidator.setUpValidator(this); - return uriValidator; + + return new ResourceValidator() + .setEdm(edm) + .setUriInfoImplPath((UriInfoImpl) member.getPath()) + .setUpValidator(this); + } public FilterValidator goParameter(final int parameterIndex) { if (curExpression instanceof MethodCallImpl) { MethodCallImpl methodCall = (MethodCallImpl) curExpression; - curExpression = methodCall.getParameters().get(parameterIndex); } else { fail("Current expression not a methodCall"); @@ -293,7 +303,7 @@ public class FilterValidator implements Validator { try { String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter); assertEquals(expectedFilterAsString, actualFilterAsText); - } catch (ExceptionVisitExpression e) { + } catch (ExpressionVisitException e) { fail("Exception occured while converting the filterTree into text" + "\n" + " Exception: " + e.getMessage()); } catch (ODataApplicationException e) { @@ -375,7 +385,7 @@ public class FilterValidator implements Validator { return this; } - public FilterValidator isMethod(final SupportedMethodCalls methodKind, final int parameterCount) { + public FilterValidator isMethod(final MethodCallKind methodKind, final int parameterCount) { if (!(curExpression instanceof MethodCallImpl)) { fail("Current expression is not a methodCall"); } @@ -388,7 +398,7 @@ public class FilterValidator implements Validator { } public FilterValidator isParameterText(final int parameterIndex, final String parameterText) - throws ExceptionVisitExpression, ODataApplicationException { + throws ExpressionVisitException, ODataApplicationException { if (!(curExpression instanceof MethodCallImpl)) { fail("Current expression is not a method"); @@ -403,7 +413,7 @@ public class FilterValidator implements Validator { return this; } - public FilterValidator isBinary(final SupportedBinaryOperators binaryOperator) { + public FilterValidator isBinary(final BinaryOperatorKind binaryOperator) { if (!(curExpression instanceof BinaryImpl)) { fail("Current expression is not a binary operator"); } @@ -455,16 +465,6 @@ public class FilterValidator implements Validator { return this; } - public FilterValidator isConstant(final SupportedConstants kind) { - if (!(curExpression instanceof ConstantImpl)) { - fail("Current expression not a constant"); - } - - assertEquals(kind, ((ConstantImpl) curExpression).getKind()); - - return this; - } - public FilterValidator isSortOrder(final int index, final boolean descending) { assertEquals(descending, orderBy.getOrders().get(index).isDescending()); return this; @@ -485,4 +485,34 @@ public class FilterValidator implements Validator { return this; } + public FilterValidator isNull() { + if (!(curExpression instanceof LiteralImpl)) { + fail("Current expression is not a literal"); + } + + String actualLiteralText = ((LiteralImpl) curExpression).getText(); + assertEquals("null", actualLiteralText); + return this; + } + + public FilterValidator isTrue() { + if (!(curExpression instanceof LiteralImpl)) { + fail("Current expression is not a literal"); + } + + String actualLiteralText = ((LiteralImpl) curExpression).getText(); + assertEquals("true", actualLiteralText); + return this; + } + + public FilterValidator isFalse() { + if (!(curExpression instanceof LiteralImpl)) { + fail("Current expression is not a literal"); + } + + String actualLiteralText = ((LiteralImpl) curExpression).getText(); + assertEquals("false", actualLiteralText); + return this; + } + } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java similarity index 88% rename from odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java rename to odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java index 29d2d9204..19fe38362 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java @@ -19,14 +19,15 @@ package org.apache.olingo.odata4.server.core.testutil; import org.antlr.v4.runtime.DefaultErrorStrategy; +import org.antlr.v4.runtime.DiagnosticErrorListener; import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser; import org.apache.olingo.odata4.server.core.uri.parser.Parser; -public class ParserTest extends Parser { +public class ParserWithLogging extends Parser { TestErrorLogger errorCollector1; TestErrorLogger errorCollector2; - public ParserTest() { + public ParserWithLogging() { errorCollector1 = new TestErrorLogger("Stage 1", 1); errorCollector2 = new TestErrorLogger("Stage 2", 1); } @@ -42,6 +43,7 @@ public class ParserTest extends Parser { // Log error to console parser.removeErrorListeners(); parser.addErrorListener(errorCollector1); + parser.addErrorListener(new DiagnosticErrorListener()); } @Override @@ -49,5 +51,6 @@ public class ParserTest extends Parser { // Log error to console parser.removeErrorListeners(); parser.addErrorListener(errorCollector2); + parser.addErrorListener(new DiagnosticErrorListener()); } } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriResourceValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ResourceValidator.java similarity index 80% rename from odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriResourceValidator.java rename to odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ResourceValidator.java index 10c741ed4..c27b059ec 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriResourceValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ResourceValidator.java @@ -36,7 +36,7 @@ import org.apache.olingo.odata4.server.api.uri.UriResourceKind; import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped; import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption; import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.odata4.server.core.uri.UriParserException; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl; @@ -55,7 +55,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl; -public class UriResourceValidator implements Validator { +public class ResourceValidator implements Validator { private Edm edm; private Validator invokedBy; private UriInfo uriInfo = null; @@ -65,17 +65,17 @@ public class UriResourceValidator implements Validator { // --- Setup --- - public UriResourceValidator setUpValidator(final Validator uriValidator) { + public ResourceValidator setUpValidator(final Validator uriValidator) { invokedBy = uriValidator; return this; } - public UriResourceValidator setEdm(final Edm edm) { + public ResourceValidator setEdm(final Edm edm) { this.edm = edm; return this; } - public UriResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) { + public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) { uriInfo = uriInfoPath; last(); return this; @@ -83,16 +83,16 @@ public class UriResourceValidator implements Validator { // --- Execution --- - public UriResourceValidator run(final String uri) { - ParserTest testParser = new ParserTest(); - // testParser.setLogLevel(1); + public ResourceValidator run(final String uri) { + ParserWithLogging testParser = new ParserWithLogging(); + UriInfoImpl uriInfoTmp = null; uriPathInfo = null; try { uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm); } catch (UriParserException e) { fail("Exception occured while parsing the URI: " + uri + "\n" - + " Exception: " + e.getMessage()); + + " Message: " + e.getMessage()); } if (uriInfoTmp.getKind() != UriInfoKind.resource) { @@ -118,24 +118,98 @@ public class UriResourceValidator implements Validator { return (FilterValidator) invokedBy; } + public FilterValidator goParameter(final int index) { + assertEquals(UriResourceKind.function, uriPathInfo.getKind()); + UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo; + + return new FilterValidator() + .setEdm(edm) + .setExpression(function.getParameters().get(index).getExression()) + .setValidator(this); + } + public FilterValidator goLambdaExpression() { if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) { - FilterValidator val = new FilterValidator(); - val.setEdm(edm); - val.setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression()); - return (val); + return new FilterValidator() + .setEdm(edm) + .setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression()); + } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) { - FilterValidator val = new FilterValidator(); - val.setEdm(edm); - val.setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression()); - return (val); + return new FilterValidator() + .setEdm(edm) + .setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression()); } else { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } return null; } - public UriResourceValidator isLambdaVar(final String var) { + public ResourceValidator goSelectItem(final int index) { + SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption(); + + SelectItem item = select.getSelectItems().get(index); + UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo(); + + return new ResourceValidator() + .setUpValidator(this) + .setEdm(edm) + .setUriInfoImplPath(uriInfo1); + + } + + public ExpandValidator goExpand() { + ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption(); + if (expand == null) { + fail("invalid resource kind: " + uriPathInfo.getKind().toString()); + } + + return new ExpandValidator().setUpValidator(this).setExpand(expand); + } + + public ResourceValidator first() { + uriResourceIndex = 0; + uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0); + return this; + } + + public ResourceValidator last() { + uriResourceIndex = 0; + + try { + uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1); + uriResourceIndex = uriInfo.getUriResourceParts().size() - 1; + } catch (IndexOutOfBoundsException ex) { + fail("not enough segments"); + } + + return this; + } + + public ResourceValidator n() { + uriResourceIndex++; + + try { + uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex); + } catch (IndexOutOfBoundsException ex) { + fail("not enough segments"); + } + + return this; + } + + public ResourceValidator at(final int index) { + uriResourceIndex = index; + try { + uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index); + } catch (IndexOutOfBoundsException ex) { + fail("not enough segments"); + } + return this; + } + + // --- Validation --- + + public ResourceValidator isLambdaVar(final String var) { String actualVar = null; if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) { actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLamdaVariable(); @@ -149,72 +223,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator goSelectItemPath(final int index) { - SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption(); - - SelectItem item = select.getSelectItems().get(index); - UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo(); - - return new UriResourceValidator() - .setUpValidator(this) - .setEdm(edm) - .setUriInfoImplPath(uriInfo1); - - } - - public ExpandValidator goExpand() { - ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption(); - if (expand == null) { - fail("invalid resource kind: " + uriPathInfo.getKind().toString()); - } - - return new ExpandValidator().setGoUpValidator(this).setExpand(expand); - } - - public UriResourceValidator first() { - uriResourceIndex = 0; - uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0); - return this; - } - - public UriResourceValidator last() { - uriResourceIndex = 0; - - try { - uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1); - uriResourceIndex = uriInfo.getUriResourceParts().size() - 1; - } catch (IndexOutOfBoundsException ex) { - fail("not enough segments"); - } - - return this; - } - - public UriResourceValidator n() { - uriResourceIndex++; - - try { - uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex); - } catch (IndexOutOfBoundsException ex) { - fail("not enough segments"); - } - - return this; - } - - public UriResourceValidator at(final int index) { - uriResourceIndex = index; - try { - uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index); - } catch (IndexOutOfBoundsException ex) { - fail("not enough segments"); - } - return this; - } - - // --- Validation --- - - public UriResourceValidator isTypeFilter(final FullQualifiedName expectedType) { + public ResourceValidator isTypeFilter(final FullQualifiedName expectedType) { if (uriPathInfo.getKind() != UriResourceKind.complexProperty && uriPathInfo.getKind() != UriResourceKind.singleton && @@ -239,7 +248,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isType(final FullQualifiedName type) { + public ResourceValidator isType(final FullQualifiedName type) { if (!(uriPathInfo instanceof UriResourcePartTyped)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -257,13 +266,13 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) { + public ResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) { isType(type); assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection()); return this; } - public UriResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) { + public ResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) { if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -281,7 +290,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) { + public ResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) { if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -300,7 +309,7 @@ public class UriResourceValidator implements Validator { } // other functions - public UriResourceValidator checkCustomParameter(final int index, final String name, final String value) { + public ResourceValidator checkCustomParameter(final int index, final String name, final String value) { if (uriInfo == null) { fail("hasQueryParameter: uriInfo == null"); } @@ -317,7 +326,7 @@ public class UriResourceValidator implements Validator { } // TODO remove - public UriResourceValidator isCollection(final boolean isCollection) { + public ResourceValidator isCollection(final boolean isCollection) { if (!(uriPathInfo instanceof UriResourcePartTyped)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -331,13 +340,13 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isFilterString(final String expectedFilterTreeAsString) { + public ResourceValidator isFilterString(final String expectedFilterTreeAsString) { ExpressionImpl filterTree = (ExpressionImpl) uriInfo.getFilterOption().getExpression(); try { String filterTreeAsString = filterTree.accept(new FilterTreeToText()); assertEquals(expectedFilterTreeAsString, filterTreeAsString); - } catch (ExceptionVisitExpression e) { + } catch (ExpressionVisitException e) { fail("isFilterString: Exception " + e.getMessage() + " occured"); } catch (ODataApplicationException e) { fail("isFilterString: Exception " + e.getMessage() + " occured"); @@ -346,7 +355,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) { + public ResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) { if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -359,7 +368,7 @@ public class UriResourceValidator implements Validator { } - public UriResourceValidator isKeyPredicate(final int index, final String name, final String text) { + public ResourceValidator isKeyPredicate(final int index, final String name, final String text) { if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -372,7 +381,7 @@ public class UriResourceValidator implements Validator { } - public UriResourceValidator isParameter(final int index, final String name, final String text) { + public ResourceValidator isParameter(final int index, final String name, final String text) { if (!(uriPathInfo instanceof UriResourceFunctionImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -385,7 +394,7 @@ public class UriResourceValidator implements Validator { } - public UriResourceValidator isParameterAlias(final int index, final String name, final String alias) { + public ResourceValidator isParameterAlias(final int index, final String name, final String alias) { if (!(uriPathInfo instanceof UriResourceFunctionImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -398,12 +407,12 @@ public class UriResourceValidator implements Validator { } - public UriResourceValidator isKind(final UriInfoKind kind) { + public ResourceValidator isKind(final UriInfoKind kind) { assertEquals(kind, uriInfo.getKind()); return this; } - public UriResourceValidator isPrimitiveProperty(final String name, + public ResourceValidator isPrimitiveProperty(final String name, final FullQualifiedName type, final boolean isCollection) { if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); @@ -419,8 +428,8 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isComplexProperty(final String name, final FullQualifiedName type, - final boolean isCollection) { + public ResourceValidator + isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) { if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -435,8 +444,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator - isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) { + public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) { if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) { fail("invalid resource kind: " + uriPathInfo.getKind().toString()); } @@ -451,100 +459,100 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isUriPathInfoKind(final UriResourceKind infoType) { + public ResourceValidator isUriPathInfoKind(final UriResourceKind infoType) { assertNotNull(uriPathInfo); assertEquals(infoType, uriPathInfo.getKind()); return this; } - public UriResourceValidator isAction(final String name) { + public ResourceValidator isAction(final String name) { assertEquals(UriResourceKind.action, uriPathInfo.getKind()); assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName()); return this; } - public UriResourceValidator isFunction(final String name) { + public ResourceValidator isFunction(final String name) { assertEquals(UriResourceKind.function, uriPathInfo.getKind()); assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName()); return this; } - public UriResourceValidator isFunctionImport(final String name) { + public ResourceValidator isFunctionImport(final String name) { assertEquals(UriResourceKind.function, uriPathInfo.getKind()); assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName()); return this; } - public UriResourceValidator isEntitySet(final String name) { + public ResourceValidator isEntitySet(final String name) { assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind()); assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName()); return this; } - public UriResourceValidator isComplex(final String name) { + public ResourceValidator isComplex(final String name) { assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind()); assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName()); return this; } - public UriResourceValidator isSingleton(final String name) { + public ResourceValidator isSingleton(final String name) { assertEquals(UriResourceKind.singleton, uriPathInfo.getKind()); assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName()); return this; } - public UriResourceValidator isValue() { + public ResourceValidator isValue() { assertEquals(UriResourceKind.value, uriPathInfo.getKind()); return this; } - public UriResourceValidator isCount() { + public ResourceValidator isCount() { assertEquals(UriResourceKind.count, uriPathInfo.getKind()); return this; } - public UriResourceValidator isRef() { + public ResourceValidator isRef() { assertEquals(UriResourceKind.ref, uriPathInfo.getKind()); return this; } - public UriResourceValidator isActionImport(final String actionName) { + public ResourceValidator isActionImport(final String actionName) { assertEquals(UriResourceKind.action, uriPathInfo.getKind()); assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName()); return this; } - public UriResourceValidator isIt() { + public ResourceValidator isIt() { assertEquals(UriResourceKind.it, uriPathInfo.getKind()); return this; } - public UriResourceValidator isTopText(final String topText) { + public ResourceValidator isTopText(final String topText) { assertEquals(topText, uriInfo.getTopOption().getText()); return this; } - public UriResourceValidator isFormatText(final String formatText) { + public ResourceValidator isFormatText(final String formatText) { assertEquals(formatText, uriInfo.getFormatOption().getText()); return this; } - public UriResourceValidator isInlineCountText(final String inlineCountText) { + public ResourceValidator isInlineCountText(final String inlineCountText) { assertEquals(inlineCountText, uriInfo.getInlineCountOption().getText()); return this; } - public UriResourceValidator isSkipText(final String skipText) { + public ResourceValidator isSkipText(final String skipText) { assertEquals(skipText, uriInfo.getSkipOption().getText()); return this; } - public UriResourceValidator isSkipTokenText(final String skipTokenText) { + public ResourceValidator isSkipTokenText(final String skipTokenText) { assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText()); return this; } - public UriResourceValidator isSelectItemStar(final int index) { + public ResourceValidator isSelectItemStar(final int index) { SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption(); SelectItem item = select.getSelectItems().get(index); @@ -552,7 +560,7 @@ public class UriResourceValidator implements Validator { return this; } - public UriResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) { + public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) { SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption(); SelectItem item = select.getSelectItems().get(index); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/TestErrorLogger.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/TestErrorLogger.java index 08777e830..04a26403e 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/TestErrorLogger.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/TestErrorLogger.java @@ -28,6 +28,7 @@ import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Recognizer; import org.antlr.v4.runtime.atn.ATNConfigSet; import org.antlr.v4.runtime.dfa.DFA; +import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer; class TestErrorLogger implements ANTLRErrorListener { @@ -44,7 +45,6 @@ class TestErrorLogger implements ANTLRErrorListener { final int charPositionInLine, final String msg, final RecognitionException e) { - // Collect the exception if (logLevel > 0) { System.out.println("\n" + prefix + " -- SyntaxError"); trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e); @@ -57,64 +57,22 @@ class TestErrorLogger implements ANTLRErrorListener { final boolean exact, final BitSet ambigAlts, final ATNConfigSet configs) { - /* - * if (tokenValidator.logLevel > 0) { - * System.out.println("reportAmbiguity: "); - * System.out.println(" ambigAlts: " + ambigAlts); - * System.out.println(" configs: " + configs); - * System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex))); - * } - */ - /* - * if (!tokenValidator.allowAmbiguity) { - * printStack(recognizer); - * fail("reportAmbiguity"); - * } - */ } @Override public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex, final BitSet conflictingAlts, final ATNConfigSet configs) { - /* - * // The grammar should be written in order to avoid attempting a full context parse because its negative - * // impact on the performance, so trace and stop here - * if (tokenValidator.logLevel > 0) { - * System.out.println("allowed AttemptingFullContext"); - * } - * - * if (!tokenValidator.allowFullContext) { - * printStack(recognizer); - * fail("reportAttemptingFullContext"); - * } - */ + } @Override public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex, final int prediction, final ATNConfigSet configs) { - /* - * if (tokenValidator.logLevel > 0) { - * System.out.println("allowed ContextSensitivity"); - * } - * - * if (!tokenValidator.allowContextSensitifity) { - * printStack(recognizer); - * fail("reportContextSensitivity"); - * } - */ + } - /* - * private void printStack(final Parser recognizer) { - * List stack = ((Parser) recognizer).getRuleInvocationStack(); - * Collections.reverse(stack); - * - * System.out.println(" Rule stack: " + stack); - * } - */ private void printStack(final Recognizer recognizer) { List stack = ((Parser) recognizer).getRuleInvocationStack(); Collections.reverse(stack); @@ -125,50 +83,23 @@ class TestErrorLogger implements ANTLRErrorListener { final int line, final int charPositionInLine, final String msg, final RecognitionException e) { System.out.println("Error message: " + msg); - // TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation printStack(recognizer); + System.out.println(" line/char :" + line + " / " + charPositionInLine); + System.out.println(" sym :" + offendingSymbol); if (e != null && e.getOffendingToken() != null) { - // String lexerTokenName = TestSuiteLexer.tokenNames[e.getOffendingToken().getType()]; String lexerTokenName = ""; try { - // TODO check how the Lexer is accessed in the new package structure - // lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()]; + lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()]; } catch (ArrayIndexOutOfBoundsException es) { lexerTokenName = "token error"; } - System.out.println(" line " + line + ":" + charPositionInLine + " at " + - offendingSymbol + "/" + lexerTokenName + ": " + msg); - } else { - System.out.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg); - } - } - public static int getDecisionRule(final Recognizer recognizer, final int decision) { - if (recognizer == null || decision < 0) { - return -1; + System.out.println(" tokenname:" + lexerTokenName); } - if (decision >= recognizer.getATN().decisionToState.size()) { - return -1; - } - - return recognizer.getATN().decisionToState.get(decision).ruleIndex; - } - - public static String getRuleDisplayName(final Recognizer recognizer, final int ruleIndex) { - if (recognizer == null || ruleIndex < 0) { - return Integer.toString(ruleIndex); - } - - String[] ruleNames = recognizer.getRuleNames(); - if (ruleIndex < 0 || ruleIndex >= ruleNames.length) { - return Integer.toString(ruleIndex); - } - - return ruleNames[ruleIndex]; } } \ No newline at end of file diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriValidator.java index 77e307949..b03ea65e8 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriValidator.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/UriValidator.java @@ -72,7 +72,7 @@ public class UriValidator implements Validator { try { // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri); uriInfo = (UriInfoImpl) parser.parseUri(uri, edm); - + fail("Exception expected"); } catch (UriParserException e) { exception = e; } @@ -81,7 +81,7 @@ public class UriValidator implements Validator { } public UriValidator log(final String uri) { - ParserTest parserTest = new ParserTest(); + ParserWithLogging parserTest = new ParserWithLogging(); parserTest.setLogLevel(1); uriInfo = null; try { @@ -96,12 +96,12 @@ public class UriValidator implements Validator { } // Navigation - public UriResourceValidator goPath() { + public ResourceValidator goPath() { if (uriInfo.getKind() != UriInfoKind.resource) { fail("invalid resource kind: " + uriInfo.getKind().toString()); } - return new UriResourceValidator() + return new ResourceValidator() .setUpValidator(this) .setEdm(edm) .setUriInfoImplPath(uriInfo); @@ -122,16 +122,16 @@ public class UriValidator implements Validator { fail("invalid resource kind: " + uriInfo.getKind().toString()); } - return new ExpandValidator().setGoUpValidator(this).setExpand(expand); + return new ExpandValidator().setUpValidator(this).setExpand(expand); } - public UriResourceValidator goSelectItemPath(final int index) { + public ResourceValidator goSelectItemPath(final int index) { SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption(); SelectItem item = select.getSelectItems().get(index); UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo(); - return new UriResourceValidator() + return new ResourceValidator() .setUpValidator(this) .setEdm(edm) .setUriInfoImplPath(uriInfo1); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriInfoImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriInfoImplTest.java index 467b83182..9864cfb7f 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriInfoImplTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriInfoImplTest.java @@ -41,12 +41,12 @@ import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl; import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl; +import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl; @@ -135,7 +135,7 @@ public class UriInfoImplTest { FilterOptionImpl filter = new FilterOptionImpl(); FormatOptionImpl format = new FormatOptionImpl(); IdOptionImpl id = new IdOptionImpl(); - InlineCountOptionImpl inlinecount = new InlineCountOptionImpl(); + CountOptionImpl inlinecount = new CountOptionImpl(); OrderByOptionImpl orderby = new OrderByOptionImpl(); SearchOptionImpl search = new SearchOptionImpl(); SelectOptionImpl select = new SelectOptionImpl(); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java index 653faf9d9..3e0990170 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/UriParameterImplTest.java @@ -299,7 +299,6 @@ public class UriParameterImplTest { impl.toString(true)); // set entry - // TODO remove ??? impl = new Mock(); impl.setType(entityType); impl.setEntryTypeFilter(entityTypeBaseEntry); @@ -308,7 +307,6 @@ public class UriParameterImplTest { assertEquals("mock/com.sap.odata.test1.ETTwoBaseTwoKeyNav", impl.toString(true)); // set collection - // TODO remove ??? impl = new Mock(); impl.setType(entityType); impl.setCollectionTypeFilter(entityTypeBaseColl); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java index 8cfc9a353..cda67846f 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestFullResourcePath.java @@ -26,15 +26,14 @@ import org.apache.olingo.odata4.commons.api.ODataApplicationException; import org.apache.olingo.odata4.commons.api.edm.Edm; 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.ExceptionVisitExpression; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; 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.testutil.FilterValidator; -import org.apache.olingo.odata4.server.core.testutil.UriResourceValidator; +import org.apache.olingo.odata4.server.core.testutil.ResourceValidator; import org.apache.olingo.odata4.server.core.testutil.UriValidator; import org.apache.olingo.odata4.server.core.uri.UriParserException; import org.junit.Test; @@ -42,18 +41,20 @@ import org.junit.Test; public class TestFullResourcePath { Edm edm = null; UriValidator testUri = null; - UriResourceValidator testRes = null; + ResourceValidator testRes = null; FilterValidator testFilter = null; public TestFullResourcePath() { edm = new EdmProviderImpl(new EdmTechTestProvider()); testUri = new UriValidator().setEdm(edm); - testRes = new UriResourceValidator().setEdm(edm); + testRes = new ResourceValidator().setEdm(edm); testFilter = new FilterValidator().setEdm(edm); } @Test - public void test() {} + public void test() throws UriParserException { + // testUri.log("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38"); + } @Test public void testFunctionBound_varOverloading() { @@ -908,7 +909,7 @@ public class TestFullResourcePath { testUri.runEx("$crossjoin").isExSyntax(0); testUri.runEx("$crossjoin/error").isExSyntax(0); testUri.runEx("$crossjoin()").isExSyntax(0); - testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0); + // testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0); } @Test @@ -924,7 +925,7 @@ public class TestFullResourcePath { @Test public void runEntityIdError() { - /* TODO move to validator */ + // TODO planned: move to validator // testUri.runEx("$entity").isExSyntax(0); // testUri.runEx("$entity?$idfalse=ESKeyNav(1)").isExSyntax(0); // testUri.runEx("$entity/com.sap.odata.test1.invalidType?$id=ESKeyNav(1)").isExSemantic(0); @@ -956,7 +957,7 @@ public class TestFullResourcePath { testUri.runEx("ESAllPrim/$ref/invalid").isExSemantic(0); testUri.runEx("ESAllPrim/$count/invalid").isExSemantic(0); testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(0); - testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0); + // testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0); testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(0); testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(0); testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(0); @@ -2120,7 +2121,9 @@ public class TestFullResourcePath { .isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true) .isType(EdmTechProvider.nameETKeyNav, true) .n().isRef() - .goUpExpandValidator();// .isFilterSerialized(""); TODO check order BY + .goUpExpandValidator() + .isSortOrder(0, false) + .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1)") .isKind(UriInfoKind.resource).goPath().goExpand() @@ -2215,7 +2218,9 @@ public class TestFullResourcePath { .goPath().first() .isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true) .isType(EdmTechProvider.nameETKeyNav, true) - .goUpExpandValidator();// TODO check orderby + .goUpExpandValidator() + .isSortOrder(0, false) + .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1)") .isKind(UriInfoKind.resource).goPath().goExpand() @@ -2252,7 +2257,7 @@ public class TestFullResourcePath { .isType(EdmTechProvider.nameETKeyNav, true) .goUpExpandValidator() .isSelectText("PropertyString") - .goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); + .goSelectItem(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETTwoKeyNavOne)") .isKind(UriInfoKind.resource).goPath().goExpand() @@ -2293,7 +2298,7 @@ public class TestFullResourcePath { .isType(EdmTechProvider.nameETKeyNav, true) .goUpExpandValidator() .isSelectText("PropertyString") - .goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); + .goSelectItem(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=max)") .isKind(UriInfoKind.resource).goPath().goExpand() @@ -2437,7 +2442,7 @@ public class TestFullResourcePath { .isType(EdmTechProvider.nameETTwoKeyNav) .isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav) .goUpExpandValidator() - .goSelectItemPath(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); + .goSelectItem(0).isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($expand=NavPropertyETKeyNavMany(" + "$expand=NavPropertyETKeyNavOne))") @@ -2467,7 +2472,7 @@ public class TestFullResourcePath { .isType(EdmTechProvider.nameETKeyNav) .goUpExpandValidator() .isSelectText("PropertyInt16") - .goSelectItemPath(0).isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); + .goSelectItem(0).isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false); testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyComplex/PropertyInt16)") .isKind(UriInfoKind.resource) @@ -2529,7 +2534,8 @@ public class TestFullResourcePath { .isKind(UriInfoKind.resource).goPath() .isInlineCountText("false"); - // TODO testUri.runEx("ESAllPrim?$count=foo").isExSyntax(0); + // TODO planned: move to validator + // testUri.runEx("ESAllPrim?$count=foo").isExSyntax(0); } @Test @@ -2538,14 +2544,12 @@ public class TestFullResourcePath { testUri.run("ESAllPrim?$skip=3") .isKind(UriInfoKind.resource).goPath() .isSkipText("3"); - /* - * testUri.run("ESAllPrim?$skip=0") - * .isKind(UriInfoKind.resource).goPath() - * .isSkipText("0"); - * testUri.run("ESAllPrim?$skip=-3") - * .isKind(UriInfoKind.resource).goPath() - * .isSkipText("-3");TODO - */ + testUri.run("ESAllPrim?$skip=0") + .isKind(UriInfoKind.resource).goPath() + .isSkipText("0"); + testUri.run("ESAllPrim?$skip=-3") + .isKind(UriInfoKind.resource).goPath() + .isSkipText("-3"); } @Test @@ -2836,7 +2840,7 @@ public class TestFullResourcePath { .isType(EdmTechProvider.nameDate) .isMember().goPath() .first().isUriPathInfoKind(UriResourceKind.startingTypeFilter) - .isType(EdmTechProvider.nameETTwoKeyNav).isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .isType(EdmTechProvider.nameETTwoKeyNav).isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) .n().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false) .goUpFilterValidator() .root().right() @@ -2881,7 +2885,7 @@ public class TestFullResourcePath { testFilter.runOnETAllPrim("PropertySByte eq PropertySByte") .is("< eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left() .isType(EdmTechProvider.nameSByte) .root().right() @@ -2889,7 +2893,7 @@ public class TestFullResourcePath { testFilter.runOnETAllPrim("PropertySByte ne PropertySByte") .is("< ne >") - .isBinary(SupportedBinaryOperators.NE) + .isBinary(BinaryOperatorKind.NE) .root().left() .isType(EdmTechProvider.nameSByte) .root().right() @@ -3268,21 +3272,21 @@ public class TestFullResourcePath { // DODO not synced testFilter.runOnETAllPrim("PropertyDecimal ge PropertyDecimal") .is("< ge >") - .isBinary(SupportedBinaryOperators.GE) + .isBinary(BinaryOperatorKind.GE) .root().left() .isType(EdmTechProvider.nameDecimal) .root().right() .isType(EdmTechProvider.nameDecimal); testFilter.runOnETAllPrim("PropertyDecimal lt PropertyDecimal") .is("< lt >") - .isBinary(SupportedBinaryOperators.LT) + .isBinary(BinaryOperatorKind.LT) .root().left() .isType(EdmTechProvider.nameDecimal) .root().right() .isType(EdmTechProvider.nameDecimal); testFilter.runOnETAllPrim("PropertyDecimal le PropertyDecimal") .is("< le >") - .isBinary(SupportedBinaryOperators.LE) + .isBinary(BinaryOperatorKind.LE) .root().left() .isType(EdmTechProvider.nameDecimal) .root().right() @@ -3312,7 +3316,13 @@ public class TestFullResourcePath { .n() .isFunction("BFCCTPrimCompRTESTwoKeyNavParam") .isParameter(0, "ParameterString", "PropertyComplex/PropertyComplex/PropertyString") - // TODO go into parameter + .goParameter(0) + .isMember() + .goPath() + .first().isComplex("PropertyComplex") + .n().isComplex("PropertyComplex") + .n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false).goUpFilterValidator() + .goUpToResourceValidator() .isKeyPredicate(0, "PropertyInt16", "1") .isKeyPredicate(1, "PropertyString", "'2'") .n() @@ -3326,7 +3336,9 @@ public class TestFullResourcePath { .isComplexProperty("PropertyComplex", EdmTechProvider.nameCTPrimComp, false) .n() .isFunction("BFCCTPrimCompRTETTwoKeyNavParam") - // TODO go into parameter + .goParameter(0) + .isNull() + .goUpToResourceValidator() .n() .isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); @@ -3339,21 +3351,21 @@ public class TestFullResourcePath { .n() .isFunction("BFCESTwoKeyNavRTString"); - testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'") - .is("<<$it/BFCETTwoKeyNavRTETTwoKeyNav/PropertyString> eq <'SomeString'>>") + testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFESTwoKeyNavRTESTwoKeyNav()/PropertyString eq 'SomeString'") + .is("<<$it/BFESTwoKeyNavRTESTwoKeyNav/PropertyString> eq <'SomeString'>>") .root().left().goPath() .first() .isIt() .n() - .isFunction("BFCETTwoKeyNavRTETTwoKeyNav") + .isFunction("BFESTwoKeyNavRTESTwoKeyNav") .n() .isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); - testFilter.runOnETTwoKeyNav("com.sap.odata.test1.BFCETTwoKeyNavRTETTwoKeyNav()/PropertyString eq 'SomeString'") - .is("< eq <'SomeString'>>") + testFilter.runOnETTwoKeyNav("com.sap.odata.test1.BFESTwoKeyNavRTESTwoKeyNav()/PropertyString eq 'SomeString'") + .is("< eq <'SomeString'>>") .root().left().goPath() .first() - .isFunction("BFCETTwoKeyNavRTETTwoKeyNav") + .isFunction("BFESTwoKeyNavRTESTwoKeyNav") .n() .isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); @@ -3390,7 +3402,7 @@ public class TestFullResourcePath { .n() .isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); - testFilter.runOnETTwoKeyNav("$it/com.sap.odata.test1.BFCETTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase" + testFilter.runOnETTwoKeyNavSingle("$it/com.sap.odata.test1.BFCETTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase" + "/PropertyString eq 'SomeString'") .is("<<$it/BFCETTwoKeyNavRTCTTwoPrim/com.sap.odata.test1.CTBase/PropertyString> eq <'SomeString'>>") .root().left().goPath() @@ -3438,7 +3450,7 @@ public class TestFullResourcePath { .root().left().goPath() .first() .isFunction("UFCRTETTwoKeyNavParam") - .isParameter(0, "ParameterInt16", "PropertyInt16") // TODO + .isParameter(0, "ParameterInt16", "PropertyInt16") .n() .isComplexProperty("PropertyComplex", EdmTechProvider.nameCTPrimComp, false) .n() @@ -3449,51 +3461,51 @@ public class TestFullResourcePath { } @Test - public void testFilterPMethods() throws ExceptionVisitExpression, ODataApplicationException, UriParserException { + public void testFilterPMethods() throws ExpressionVisitException, ODataApplicationException, UriParserException { testFilter.runOnETKeyNav("indexof(PropertyString,'47') eq 5") .is("<,<'47'>)> eq <5>>") .root().left() - .isMethod(SupportedMethodCalls.INDEXOF, 2) + .isMethod(MethodCallKind.INDEXOF, 2) .isParameterText(0, "") .isParameterText(1, "<'47'>"); testFilter.runOnETKeyNav("tolower(PropertyString) eq 'foo'") .is("<)> eq <'foo'>>") .root().left() - .isMethod(SupportedMethodCalls.TOLOWER, 1) + .isMethod(MethodCallKind.TOLOWER, 1) .isParameterText(0, ""); testFilter.runOnETKeyNav("toupper(PropertyString) eq 'FOO'") .is("<)> eq <'FOO'>>") .root().left() - .isMethod(SupportedMethodCalls.TOUPPER, 1) + .isMethod(MethodCallKind.TOUPPER, 1) .isParameterText(0, ""); testFilter.runOnETKeyNav("trim(PropertyString) eq 'fooba'") .is("<)> eq <'fooba'>>") .root().left() - .isMethod(SupportedMethodCalls.TRIM, 1) + .isMethod(MethodCallKind.TRIM, 1) .isParameterText(0, ""); testFilter.runOnETKeyNav("substring(PropertyString,4) eq 'foo'") .is("<,<4>)> eq <'foo'>>") .root().left() - .isMethod(SupportedMethodCalls.SUBSTRING, 2) + .isMethod(MethodCallKind.SUBSTRING, 2) .isParameterText(0, "") .isParameterText(1, "<4>"); testFilter.runOnETKeyNav("substring(PropertyString,4) eq 'foo'") .is("<,<4>)> eq <'foo'>>") .root().left() - .isMethod(SupportedMethodCalls.SUBSTRING, 2) + .isMethod(MethodCallKind.SUBSTRING, 2) .isParameterText(0, "") .isParameterText(1, "<4>"); testFilter.runOnETKeyNav("substring(PropertyString,2,4) eq 'foo'") .is("<,<2>,<4>)> eq <'foo'>>") .root().left() - .isMethod(SupportedMethodCalls.SUBSTRING, 3) + .isMethod(MethodCallKind.SUBSTRING, 3) .isParameterText(0, "") .isParameterText(1, "<2>") .isParameterText(2, "<4>"); @@ -3501,367 +3513,367 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("concat(PropertyString,PropertyComplexTwoPrim/PropertyString) eq 'foo'") .is("<,)> eq <'foo'>>") .root().left() - .isMethod(SupportedMethodCalls.CONCAT, 2) + .isMethod(MethodCallKind.CONCAT, 2) .isParameterText(0, "") .isParameterText(1, ""); testFilter.runOnETKeyNav("concat(PropertyString,'bar') eq 'foobar'") .is("<,<'bar'>)> eq <'foobar'>>") .root().left() - .isMethod(SupportedMethodCalls.CONCAT, 2) + .isMethod(MethodCallKind.CONCAT, 2) .isParameterText(0, "") .isParameterText(1, "<'bar'>"); testFilter.runOnETKeyNav("concat(PropertyString,'bar') eq 'foobar'") .is("<,<'bar'>)> eq <'foobar'>>") .root().left() - .isMethod(SupportedMethodCalls.CONCAT, 2) + .isMethod(MethodCallKind.CONCAT, 2) .isParameterText(0, "") .isParameterText(1, "<'bar'>"); testFilter.runOnETKeyNav("concat(PropertyString, cast(PropertyComplexAllPrim/PropertyInt16,Edm.String))") .is(",,)>)>") - .isMethod(SupportedMethodCalls.CONCAT, 2) + .isMethod(MethodCallKind.CONCAT, 2) .isParameterText(0, "") .isParameterText(1, ",)>") .goParameter(1) - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .isParameterText(0, "") .isParameterText(1, ""); testFilter.runOnETKeyNav("length(PropertyString) eq 32") .is("<)> eq <32>>") .root().left() - .isMethod(SupportedMethodCalls.LENGTH, 1) + .isMethod(MethodCallKind.LENGTH, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("year(PropertyDate) eq 2013") .is("<)> eq <2013>>") .root().left() - .isMethod(SupportedMethodCalls.YEAR, 1) + .isMethod(MethodCallKind.YEAR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("year(2013-09-25) eq 2013") .is("<)> eq <2013>>") .root().left() - .isMethod(SupportedMethodCalls.YEAR, 1) + .isMethod(MethodCallKind.YEAR, 1) .isParameterText(0, "<2013-09-25>"); testFilter.runOnETAllPrim("year(PropertyDateTimeOffset) eq 2013") .is("<)> eq <2013>>") .root().left() - .isMethod(SupportedMethodCalls.YEAR, 1) + .isMethod(MethodCallKind.YEAR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("year(2013-09-25T12:34:56.123456789012-10:24) eq 2013") .is("<)> eq <2013>>") .root().left() - .isMethod(SupportedMethodCalls.YEAR, 1) + .isMethod(MethodCallKind.YEAR, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("month(PropertyDate) eq 9") .is("<)> eq <9>>") .root().left() - .isMethod(SupportedMethodCalls.MONTH, 1) + .isMethod(MethodCallKind.MONTH, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("month(2013-09-25) eq 9") .is("<)> eq <9>>") .root().left() - .isMethod(SupportedMethodCalls.MONTH, 1) + .isMethod(MethodCallKind.MONTH, 1) .isParameterText(0, "<2013-09-25>"); testFilter.runOnETAllPrim("month(PropertyDateTimeOffset) eq 9") .is("<)> eq <9>>") .root().left() - .isMethod(SupportedMethodCalls.MONTH, 1) + .isMethod(MethodCallKind.MONTH, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("month(2013-09-25T12:34:56.123456789012-10:24) eq 9") .is("<)> eq <9>>") .root().left() - .isMethod(SupportedMethodCalls.MONTH, 1) + .isMethod(MethodCallKind.MONTH, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("day(PropertyDate) eq 25") .is("<)> eq <25>>") .root().left() - .isMethod(SupportedMethodCalls.DAY, 1) + .isMethod(MethodCallKind.DAY, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("day(2013-09-25) eq 25") .is("<)> eq <25>>") .root().left() - .isMethod(SupportedMethodCalls.DAY, 1) + .isMethod(MethodCallKind.DAY, 1) .isParameterText(0, "<2013-09-25>"); testFilter.runOnETAllPrim("day(PropertyDateTimeOffset) eq 25") .is("<)> eq <25>>") .root().left() - .isMethod(SupportedMethodCalls.DAY, 1) + .isMethod(MethodCallKind.DAY, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("day(2013-09-25T12:34:56.123456789012-10:24) eq 25") .is("<)> eq <25>>") .root().left() - .isMethod(SupportedMethodCalls.DAY, 1) + .isMethod(MethodCallKind.DAY, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("hour(PropertyDateTimeOffset) eq 2") .is("<)> eq <2>>") .root().left() - .isMethod(SupportedMethodCalls.HOUR, 1) + .isMethod(MethodCallKind.HOUR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("hour(PropertyDateTimeOffset) eq 2") .is("<)> eq <2>>") .root().left() - .isMethod(SupportedMethodCalls.HOUR, 1) + .isMethod(MethodCallKind.HOUR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("hour(2013-09-25T12:34:56.123456789012-10:24) eq 2") .is("<)> eq <2>>") .root().left() - .isMethod(SupportedMethodCalls.HOUR, 1) + .isMethod(MethodCallKind.HOUR, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("hour(PropertyTimeOfDay) eq 2") .is("<)> eq <2>>") .root().left() - .isMethod(SupportedMethodCalls.HOUR, 1) + .isMethod(MethodCallKind.HOUR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("hour(12:34:55.123456789012) eq 12") .is("<)> eq <12>>") .root().left() - .isMethod(SupportedMethodCalls.HOUR, 1) + .isMethod(MethodCallKind.HOUR, 1) .isParameterText(0, "<12:34:55.123456789012>"); testFilter.runOnETAllPrim("minute(PropertyDateTimeOffset) eq 34") .is("<)> eq <34>>") .root().left() - .isMethod(SupportedMethodCalls.MINUTE, 1) + .isMethod(MethodCallKind.MINUTE, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("minute(2013-09-25T12:34:56.123456789012-10:24) eq 34") .is("<)> eq <34>>") .root().left() - .isMethod(SupportedMethodCalls.MINUTE, 1) + .isMethod(MethodCallKind.MINUTE, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("minute(PropertyTimeOfDay) eq 34") .is("<)> eq <34>>") .root().left() - .isMethod(SupportedMethodCalls.MINUTE, 1) + .isMethod(MethodCallKind.MINUTE, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("minute(12:34:55.123456789012) eq 34") .is("<)> eq <34>>") .root().left() - .isMethod(SupportedMethodCalls.MINUTE, 1) + .isMethod(MethodCallKind.MINUTE, 1) .isParameterText(0, "<12:34:55.123456789012>"); testFilter.runOnETAllPrim("second(PropertyDateTimeOffset) eq 56") .is("<)> eq <56>>") .root().left() - .isMethod(SupportedMethodCalls.SECOND, 1) + .isMethod(MethodCallKind.SECOND, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("second(2013-09-25T12:34:56.123456789012-10:24) eq 56") .is("<)> eq <56>>") .root().left() - .isMethod(SupportedMethodCalls.SECOND, 1) + .isMethod(MethodCallKind.SECOND, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("second(PropertyTimeOfDay) eq 56") .is("<)> eq <56>>") .root().left() - .isMethod(SupportedMethodCalls.SECOND, 1) + .isMethod(MethodCallKind.SECOND, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("second(12:34:55.123456789012) eq 56") .is("<)> eq <56>>") .root().left() - .isMethod(SupportedMethodCalls.SECOND, 1) + .isMethod(MethodCallKind.SECOND, 1) .isParameterText(0, "<12:34:55.123456789012>"); testFilter.runOnETAllPrim("fractionalseconds(PropertyDateTimeOffset) eq 123456789012") .is("<)> eq <123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.FRACTIONALSECONDS, 1) + .isMethod(MethodCallKind.FRACTIONALSECONDS, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("fractionalseconds(2013-09-25T12:34:56.123456789012-10:24) eq 123456789012") .is("<)> eq <123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.FRACTIONALSECONDS, 1) + .isMethod(MethodCallKind.FRACTIONALSECONDS, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("fractionalseconds(PropertyTimeOfDay) eq 123456789012") .is("<)> eq <123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.FRACTIONALSECONDS, 1) + .isMethod(MethodCallKind.FRACTIONALSECONDS, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("fractionalseconds(12:34:55.123456789012) eq 123456789012") .is("<)> eq <123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.FRACTIONALSECONDS, 1) + .isMethod(MethodCallKind.FRACTIONALSECONDS, 1) .isParameterText(0, "<12:34:55.123456789012>"); testFilter.runOnETAllPrim("totalseconds(PropertyDuration) eq 4711") .is("<)> eq <4711>>") .root().left() - .isMethod(SupportedMethodCalls.TOTALSECONDS, 1) + .isMethod(MethodCallKind.TOTALSECONDS, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("totalseconds(duration'P10DT5H34M21.123456789012S') eq 4711") .is("<)> eq <4711>>") .root().left() - .isMethod(SupportedMethodCalls.TOTALSECONDS, 1) + .isMethod(MethodCallKind.TOTALSECONDS, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("date(PropertyDateTimeOffset) eq 2013-09-25") .is("<)> eq <2013-09-25>>") .root().left() - .isMethod(SupportedMethodCalls.DATE, 1) + .isMethod(MethodCallKind.DATE, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("date(2013-09-25T12:34:56.123456789012-10:24) eq 2013-09-25") .is("<)> eq <2013-09-25>>") .root().left() - .isMethod(SupportedMethodCalls.DATE, 1) + .isMethod(MethodCallKind.DATE, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("time(PropertyDateTimeOffset) eq 12:34:55.123456789012") .is("<)> eq <12:34:55.123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.TIME, 1) + .isMethod(MethodCallKind.TIME, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("time(2013-09-25T12:34:56.123456789012-10:24) eq 12:34:55.123456789012") .is("<)> eq <12:34:55.123456789012>>") .root().left() - .isMethod(SupportedMethodCalls.TIME, 1) + .isMethod(MethodCallKind.TIME, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("round(PropertyDouble) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.ROUND, 1) + .isMethod(MethodCallKind.ROUND, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("round(17.45e1) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.ROUND, 1) + .isMethod(MethodCallKind.ROUND, 1) .isParameterText(0, "<17.45e1>"); testFilter.runOnETAllPrim("round(PropertyDecimal) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.ROUND, 1) + .isMethod(MethodCallKind.ROUND, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("round(17.45) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.ROUND, 1) + .isMethod(MethodCallKind.ROUND, 1) .isParameterText(0, "<17.45>"); testFilter.runOnETAllPrim("floor(PropertyDouble) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.FLOOR, 1) + .isMethod(MethodCallKind.FLOOR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("floor(17.45e1) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.FLOOR, 1) + .isMethod(MethodCallKind.FLOOR, 1) .isParameterText(0, "<17.45e1>"); testFilter.runOnETAllPrim("floor(PropertyDecimal) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.FLOOR, 1) + .isMethod(MethodCallKind.FLOOR, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("floor(17.45) eq 17") .is("<)> eq <17>>") .root().left() - .isMethod(SupportedMethodCalls.FLOOR, 1) + .isMethod(MethodCallKind.FLOOR, 1) .isParameterText(0, "<17.45>"); testFilter.runOnETAllPrim("ceiling(PropertyDouble) eq 18") .is("<)> eq <18>>") .root().left() - .isMethod(SupportedMethodCalls.CEILING, 1) + .isMethod(MethodCallKind.CEILING, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("ceiling(17.55e1) eq 18") .is("<)> eq <18>>") .root().left() - .isMethod(SupportedMethodCalls.CEILING, 1) + .isMethod(MethodCallKind.CEILING, 1) .isParameterText(0, "<17.55e1>"); testFilter.runOnETAllPrim("ceiling(PropertyDecimal) eq 18") .is("<)> eq <18>>") .root().left() - .isMethod(SupportedMethodCalls.CEILING, 1) + .isMethod(MethodCallKind.CEILING, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("ceiling(17.55) eq 18") .is("<)> eq <18>>") .root().left() - .isMethod(SupportedMethodCalls.CEILING, 1) + .isMethod(MethodCallKind.CEILING, 1) .isParameterText(0, "<17.55>"); testFilter.runOnETAllPrim("totaloffsetminutes(PropertyDateTimeOffset) eq 4711") .is("<)> eq <4711>>") .root().left() - .isMethod(SupportedMethodCalls.TOTALOFFSETMINUTES, 1) + .isMethod(MethodCallKind.TOTALOFFSETMINUTES, 1) .isParameterText(0, ""); testFilter.runOnETAllPrim("totaloffsetminutes(2013-09-25T12:34:56.123456789012-10:24) eq 4711") .is("<)> eq <4711>>") .root().left() - .isMethod(SupportedMethodCalls.TOTALOFFSETMINUTES, 1) + .isMethod(MethodCallKind.TOTALOFFSETMINUTES, 1) .isParameterText(0, "<2013-09-25T12:34:56.123456789012-10:24>"); testFilter.runOnETAllPrim("mindatetime()") .is("") - .isMethod(SupportedMethodCalls.MINDATETIME, 0); + .isMethod(MethodCallKind.MINDATETIME, 0); testFilter.runOnETAllPrim("mindatetime() eq 2013-09-25T12:34:56.123456789012-10:24") .is("< eq <2013-09-25T12:34:56.123456789012-10:24>>") .root().left() - .isMethod(SupportedMethodCalls.MINDATETIME, 0); + .isMethod(MethodCallKind.MINDATETIME, 0); testFilter.runOnETAllPrim("maxdatetime()") .is("") - .isMethod(SupportedMethodCalls.MAXDATETIME, 0); + .isMethod(MethodCallKind.MAXDATETIME, 0); testFilter.runOnETAllPrim("maxdatetime() eq 2013-09-25T12:34:56.123456789012-10:24") .is("< eq <2013-09-25T12:34:56.123456789012-10:24>>") .root().left() - .isMethod(SupportedMethodCalls.MAXDATETIME, 0); + .isMethod(MethodCallKind.MAXDATETIME, 0); testFilter.runOnETAllPrim("now()") .is("") - .isMethod(SupportedMethodCalls.NOW, 0); + .isMethod(MethodCallKind.NOW, 0); testFilter.runOnETAllPrim("now() eq 2013-09-25T12:34:56.123456789012-10:24") .is("< eq <2013-09-25T12:34:56.123456789012-10:24>>") .root().left() - .isMethod(SupportedMethodCalls.NOW, 0); + .isMethod(MethodCallKind.NOW, 0); testFilter.runOnETTwoKeyNav("$it/PropertyString eq 'SomeString'") .is("<<$it/PropertyString> eq <'SomeString'>>") .root().left() .goPath() .first().isUriPathInfoKind(UriResourceKind.it) - .isType(EdmTechProvider.nameETTwoKeyNav, false) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); testFilter.runOnCTTwoPrim("$it/PropertyString eq 'SomeString'") @@ -3881,7 +3893,7 @@ public class TestFullResourcePath { testFilter.runOnString("endswith($it,'sap.com')") .is(",<'sap.com'>)>") - .isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isMethod(MethodCallKind.ENDSWITH, 2) .isParameterText(0, "<$it>") .isParameterText(1, "<'sap.com'>") .goParameter(0) @@ -3892,7 +3904,7 @@ public class TestFullResourcePath { testFilter.runOnString("endswith($it,'sap.com') eq false") .is("<,<'sap.com'>)> eq >") .root().left() - .isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isMethod(MethodCallKind.ENDSWITH, 2) .isParameterText(0, "<$it>") .isParameterText(1, "<'sap.com'>") .goParameter(0) @@ -3902,13 +3914,13 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("endswith($it/CollPropertyString,'sap.com')") .is(",<'sap.com'>)>") - .isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isMethod(MethodCallKind.ENDSWITH, 2) .isParameterText(0, "<$it/CollPropertyString>") .isParameterText(1, "<'sap.com'>") .goParameter(0) .goPath() .first().isUriPathInfoKind(UriResourceKind.it) - .isType(EdmTechProvider.nameETTwoKeyNav, false) + .isType(EdmTechProvider.nameETTwoKeyNav, true) .n().isPrimitiveProperty("CollPropertyString", EdmTechProvider.nameString, true); testFilter.runOnETTwoKeyNav("PropertyComplex/PropertyComplex/PropertyInt16 eq $root" @@ -3931,7 +3943,7 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("cast(com.sap.odata.test1.ETBaseTwoKeyNav)") .is(")>") .root() - .isMethod(SupportedMethodCalls.CAST, 1) + .isMethod(MethodCallKind.CAST, 1) .isParameterText(0, "") .goParameter(0) .isTypedLiteral(EdmTechProvider.nameETBaseTwoKeyNav); @@ -3939,7 +3951,7 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("cast(PropertyComplexTwoPrim,com.sap.odata.test1.CTBase)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .isParameterText(0, "") .isParameterText(1, "") .goParameter(0).goPath().first() @@ -3952,7 +3964,7 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("cast($it,com.sap.odata.test1.CTBase)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .isParameterText(0, "<$it>") .isParameterText(1, "") .goParameter(0).goPath().first() @@ -3965,7 +3977,7 @@ public class TestFullResourcePath { ) .is("<,)> eq ,)>>") .root().left() - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .isParameterText(0, "<$it>") .isParameterText(1, "") .goParameter(0).goPath().first() @@ -3974,7 +3986,7 @@ public class TestFullResourcePath { .root().left() .goParameter(1).isTypedLiteral(EdmTechProvider.nameCTBase) .root().right() - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .isParameterText(0, "<$it>") .isParameterText(1, "") .goParameter(0).goPath().first() @@ -3985,27 +3997,27 @@ public class TestFullResourcePath { testFilter.runOnInt32("cast(Edm.Int32)") .is(")>") - .isMethod(SupportedMethodCalls.CAST, 1) + .isMethod(MethodCallKind.CAST, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameInt32); testFilter.runOnDateTimeOffset("cast(Edm.DateTimeOffset)") .is(")>") - .isMethod(SupportedMethodCalls.CAST, 1) + .isMethod(MethodCallKind.CAST, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameDateTimeOffset); testFilter.runOnDuration("cast(Edm.Duration)") .is(")>") - .isMethod(SupportedMethodCalls.CAST, 1) + .isMethod(MethodCallKind.CAST, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameDuration); testFilter.runOnTimeOfDay("cast(Edm.TimeOfDay)") .is(")>") - .isMethod(SupportedMethodCalls.CAST, 1) + .isMethod(MethodCallKind.CAST, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameTimeOfDay); testFilter.runOnETKeyNav("cast(CollPropertyInt16,Edm.Int32)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath().first() .isPrimitiveProperty("CollPropertyInt16", EdmTechProvider.nameInt16, true) .goUpFilterValidator().root() @@ -4014,7 +4026,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav( "cast(PropertyComplex/PropertyComplex/PropertyDateTimeOffset,Edm.DateTimeOffset)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath() .first().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTPrimComp, false) .n().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false) @@ -4024,7 +4036,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("cast(PropertyComplex/PropertyComplex/PropertyDuration,Edm.Duration)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath() .first().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTPrimComp, false) .n().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false) @@ -4034,7 +4046,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("cast(PropertyComplex/PropertyComplex/PropertyTimeOfDay,Edm.TimeOfDay)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath() .first().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTPrimComp, false) .n().isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false) @@ -4044,7 +4056,7 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("cast(PropertyComplexAllPrim,com.sap.odata.test1.CTTwoPrim)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath() .first().isComplexProperty("PropertyComplexAllPrim", EdmTechProvider.nameCTAllPrim, false) .goUpFilterValidator().root() @@ -4054,7 +4066,7 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("cast(NavPropertyETKeyNavOne,com.sap.odata.test1.ETKeyPrimNav)") .is(",)>") - .isMethod(SupportedMethodCalls.CAST, 2) + .isMethod(MethodCallKind.CAST, 2) .goParameter(0).goPath() .first().isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false) .goUpFilterValidator().root() @@ -4067,14 +4079,14 @@ public class TestFullResourcePath { } @Test - public void runLamdbaFunctions() throws ExceptionVisitExpression, ODataApplicationException, UriParserException { + public void runLamdbaFunctions() throws ExpressionVisitException, ODataApplicationException, UriParserException { testFilter.runOnETKeyNav("any(d:d/PropertyInt16 eq 1)") .is("< eq <1>>>>") .root().goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) .isType(EdmTechProvider.nameETKeyNav, false) @@ -4086,13 +4098,13 @@ public class TestFullResourcePath { .first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) .isType(EdmTechProvider.nameETTwoKeyNav, false) .n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false); - // TODO lambda does not check if the previous path segment is a collection + // TODO planned: lambda does not check if the previous path segment is a collection // testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavOne/any(d:d/PropertyString eq 'SomeString')"); testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any()") @@ -4105,7 +4117,7 @@ public class TestFullResourcePath { .n().isPrimitiveProperty("CollPropertyString", EdmTechProvider.nameString, true) .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) .isType(EdmTechProvider.nameString, false); @@ -4118,7 +4130,7 @@ public class TestFullResourcePath { .n().isFunction("BFCETTwoKeyNavRTESTwoKeyNav") .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) .isType(EdmTechProvider.nameETTwoKeyNav, false) @@ -4134,9 +4146,9 @@ public class TestFullResourcePath { .first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .root().isBinary(SupportedBinaryOperators.OR) + .root().isBinary(BinaryOperatorKind.OR) .root().left() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left() .goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) @@ -4162,9 +4174,9 @@ public class TestFullResourcePath { .first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .root().isBinary(SupportedBinaryOperators.OR) + .root().isBinary(BinaryOperatorKind.OR) .root().left() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left() .goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) @@ -4191,9 +4203,9 @@ public class TestFullResourcePath { .first().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true) .n().isUriPathInfoKind(UriResourceKind.lambdaAny) .goLambdaExpression() - .root().isBinary(SupportedBinaryOperators.AND) + .root().isBinary(BinaryOperatorKind.AND) .root().left() - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .left() .goPath() .first().isUriPathInfoKind(UriResourceKind.lambdaVariable) @@ -4218,74 +4230,74 @@ public class TestFullResourcePath { } @Test - public void runIsOf() throws ExceptionVisitExpression, ODataApplicationException, UriParserException { + public void runIsOf() throws ExpressionVisitException, ODataApplicationException, UriParserException { testFilter.runOnETKeyNav("isof(com.sap.odata.test1.ETTwoKeyNav)") .is(")>") .root() - .isMethod(SupportedMethodCalls.ISOF, 1) + .isMethod(MethodCallKind.ISOF, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameETTwoKeyNav); testFilter.runOnETKeyNav("isof(com.sap.odata.test1.ETBaseTwoKeyNav) eq true") .is("<)> eq >") - .root().isBinary(SupportedBinaryOperators.EQ) + .root().isBinary(BinaryOperatorKind.EQ) .left() - .isMethod(SupportedMethodCalls.ISOF, 1) + .isMethod(MethodCallKind.ISOF, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameETBaseTwoKeyNav); testFilter .runOnETKeyNav("isof(com.sap.odata.test1.ETBaseTwoKeyNav) eq true and PropertyComplex/PropertyInt16 eq 1") .is("<<)> eq > and < eq <1>>>") - .root().isBinary(SupportedBinaryOperators.AND) - .left().isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.ISOF, 1) + .root().isBinary(BinaryOperatorKind.AND) + .left().isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.ISOF, 1) .goParameter(0).isTypedLiteral(EdmTechProvider.nameETBaseTwoKeyNav); testFilter.runOnETKeyNav("isof(NavPropertyETKeyNavOne, com.sap.odata.test1.ETKeyNav) eq true") .is("<,)> eq >") - .root().isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.ISOF, 2) + .root().isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false) .goUpFilterValidator() .root().left().goParameter(1).isTypedLiteral(EdmTechProvider.nameETKeyNav); testFilter.runOnETKeyNav("isof(PropertyComplexTwoPrim,com.sap.odata.test1.CTTwoPrim)") .is(",)>") - .root().isMethod(SupportedMethodCalls.ISOF, 2) + .root().isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isComplex("PropertyComplexTwoPrim").goUpFilterValidator() .root().goParameter(1).isTypedLiteral(EdmTechProvider.nameCTTwoPrim); testFilter.runOnETKeyNav("isof(PropertyComplexTwoPrim,com.sap.odata.test1.CTTwoBase)") .is(",)>") - .root().isMethod(SupportedMethodCalls.ISOF, 2) + .root().isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isComplex("PropertyComplexTwoPrim").goUpFilterValidator() .root().goParameter(1).isTypedLiteral(EdmTechProvider.nameCTTwoBase); testFilter.runOnETKeyNav("isof(PropertyComplexTwoPrim,com.sap.odata.test1.CTTwoPrim) eq true") .is("<,)> eq >") - .root().left().isMethod(SupportedMethodCalls.ISOF, 2) + .root().left().isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isComplex("PropertyComplexTwoPrim").goUpFilterValidator() .root().left().goParameter(1).isTypedLiteral(EdmTechProvider.nameCTTwoPrim); testFilter.runOnETKeyNav("isof($it,com.sap.odata.test1.CTTwoPrim)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isIt().goUpFilterValidator() .root().goParameter(1).isTypedLiteral(EdmTechProvider.nameCTTwoPrim); testFilter.runOnETKeyNav("isof($it,com.sap.odata.test1.CTTwoBase) eq false") .is("<,)> eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath().isIt().goUpFilterValidator() .root().left().goParameter(1).isTypedLiteral(EdmTechProvider.nameCTTwoBase); testFilter.runOnETKeyNav("isof(PropertyComplex/PropertyInt16,Edm.Int32)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false) @@ -4295,7 +4307,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyDateTimeOffset,Edm.DateTimeOffset)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4306,7 +4318,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyTimeOfDay,Edm.TimeOfDay)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4317,7 +4329,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav(" isof(PropertyComplex/PropertyComplex/PropertyDuration,Edm.Duration)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4328,7 +4340,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyString,Edm.String)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4340,7 +4352,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("isof(PropertyComplex/PropertyComplex/PropertyString,Edm.Guid)") .is(",)>") .root() - .isMethod(SupportedMethodCalls.ISOF, 2) + .isMethod(MethodCallKind.ISOF, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4350,18 +4362,18 @@ public class TestFullResourcePath { } @Test - public void testHas() throws ExceptionVisitExpression, ODataApplicationException, UriParserException { + public void testHas() throws ExpressionVisitException, ODataApplicationException, UriParserException { testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String1'") .is("< has >>") - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().goPath().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) .goUpFilterValidator() .root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1")); testFilter.runOnETTwoKeyNav("PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2'") .is("< has >>") - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().goPath() .first().isComplex("PropertyComplexEnum") .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) @@ -4372,9 +4384,9 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav( "PropertyComplexEnum/PropertyEnumString has com.sap.odata.test1.ENString'String2' eq true") .is("<< has >> eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left() - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().left().goPath() .first().isComplex("PropertyComplexEnum") .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) @@ -4383,7 +4395,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String3'") .is("< has >>") - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().goPath() .first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) .isType(EdmTechProvider.nameENString) @@ -4392,7 +4404,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("PropertyEnumString has com.sap.odata.test1.ENString'String,String3'") .is("< has >>") - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().goPath() .first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) .isType(EdmTechProvider.nameENString) @@ -4402,14 +4414,14 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("PropertyEnumString has null") .is("< has >") .root() - .isBinary(SupportedBinaryOperators.HAS) + .isBinary(BinaryOperatorKind.HAS) .root().left().goPath() .first().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString).goUpFilterValidator() - .root().right().isConstant(SupportedConstants.NULL); + .root().right().isNull(); testFilter.runOnETTwoKeyNav("endswith(PropertyComplex/PropertyComplex/PropertyString,'dorf')") .is(",<'dorf'>)>") - .isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isMethod(MethodCallKind.ENDSWITH, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4418,8 +4430,8 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("endswith(PropertyComplex/PropertyComplex/PropertyString,'dorf') eq true") .is("<,<'dorf'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.ENDSWITH, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4428,20 +4440,20 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("endswith('Walldorf','dorf')") .is(",<'dorf'>)>") - .isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isMethod(MethodCallKind.ENDSWITH, 2) .goParameter(0).isLiteral("'Walldorf'") .root().goParameter(1).isLiteral("'dorf'"); testFilter.runOnETTwoKeyNav("endswith('Walldorf','dorf') eq true") .is("<,<'dorf'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.ENDSWITH, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.ENDSWITH, 2) .goParameter(0).isLiteral("'Walldorf'") .root().left().goParameter(1).isLiteral("'dorf'"); testFilter.runOnETKeyNav("startswith(PropertyComplexAllPrim/PropertyString,'Wall')") .is(",<'Wall'>)>") - .isMethod(SupportedMethodCalls.STARTSWITH, 2) + .isMethod(MethodCallKind.STARTSWITH, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplexAllPrim") .n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false).goUpFilterValidator() @@ -4449,8 +4461,8 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("startswith(PropertyComplexAllPrim/PropertyString,'Wall') eq true") .is("<,<'Wall'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.STARTSWITH, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.STARTSWITH, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplexAllPrim") .n().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false).goUpFilterValidator() @@ -4458,20 +4470,20 @@ public class TestFullResourcePath { testFilter.runOnETKeyNav("startswith('Walldorf','Wall')") .is(",<'Wall'>)>") - .isMethod(SupportedMethodCalls.STARTSWITH, 2) + .isMethod(MethodCallKind.STARTSWITH, 2) .goParameter(0).isLiteral("'Walldorf'") .root().goParameter(1).isLiteral("'Wall'"); testFilter.runOnETKeyNav("startswith('Walldorf','Wall') eq true") .is("<,<'Wall'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.STARTSWITH, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.STARTSWITH, 2) .goParameter(0).isLiteral("'Walldorf'") .root().left().goParameter(1).isLiteral("'Wall'"); testFilter.runOnETTwoKeyNav("contains(PropertyComplex/PropertyComplex/PropertyString,'Wall')") .is(",<'Wall'>)>") - .isMethod(SupportedMethodCalls.CONTAINS, 2) + .isMethod(MethodCallKind.CONTAINS, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4480,8 +4492,8 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("contains(PropertyComplex/PropertyComplex/PropertyString,'Wall') eq true") .is("<,<'Wall'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.CONTAINS, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.CONTAINS, 2) .goParameter(0).goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4490,14 +4502,14 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("contains('Walldorf','Wall')") .is(",<'Wall'>)>") - .isMethod(SupportedMethodCalls.CONTAINS, 2) + .isMethod(MethodCallKind.CONTAINS, 2) .goParameter(0).isLiteral("'Walldorf'") .root().goParameter(1).isLiteral("'Wall'"); testFilter.runOnETTwoKeyNav("contains('Walldorf','Wall') eq true") .is("<,<'Wall'>)> eq >") - .isBinary(SupportedBinaryOperators.EQ) - .left().isMethod(SupportedMethodCalls.CONTAINS, 2) + .isBinary(BinaryOperatorKind.EQ) + .left().isMethod(MethodCallKind.CONTAINS, 2) .goParameter(0).isLiteral("'Walldorf'") .root().left().goParameter(1).isLiteral("'Wall'"); @@ -4509,80 +4521,80 @@ public class TestFullResourcePath { testFilter.runOnETAllPrim("PropertyBoolean eq true") .is("< eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyBoolean", EdmTechProvider.nameBoolean, false) .goUpFilterValidator() - .root().right().isConstant(SupportedConstants.TRUE); + .root().right().isTrue(); testFilter.runOnETAllPrim("PropertyBoolean eq 2") .is("< eq <2>>"); testFilter.runOnETAllPrim("PropertyDecimal eq 1.25") .is("< eq <1.25>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyDecimal", EdmTechProvider.nameDecimal, false) .goUpFilterValidator() .root().right().isLiteral("1.25"); testFilter.runOnETAllPrim("PropertyDouble eq 1.5") .is("< eq <1.5>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false) .goUpFilterValidator() .root().right().isLiteral("1.5"); testFilter.runOnETAllPrim("PropertySingle eq 1.5") .is("< eq <1.5>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertySingle", EdmTechProvider.nameSingle, false) .goUpFilterValidator() .root().right().isLiteral("1.5"); testFilter.runOnETAllPrim("PropertySByte eq -128") .is("< eq <-128>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertySByte", EdmTechProvider.nameSByte, false) .goUpFilterValidator() .root().right().isLiteral("-128"); testFilter.runOnETAllPrim("PropertyByte eq 255") .is("< eq <255>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyByte", EdmTechProvider.nameByte, false).goUpFilterValidator() .root().right().isLiteral("255"); testFilter.runOnETAllPrim("PropertyInt16 eq 32767") .is("< eq <32767>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false) .goUpFilterValidator() .root().right().isLiteral("32767"); testFilter.runOnETAllPrim("PropertyInt32 eq 2147483647") .is("< eq <2147483647>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyInt32", EdmTechProvider.nameInt32, false) .goUpFilterValidator() .root().right().isLiteral("2147483647"); testFilter.runOnETAllPrim("PropertyInt64 eq 9223372036854775807") .is("< eq <9223372036854775807>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyInt64", EdmTechProvider.nameInt64, false) .goUpFilterValidator() .root().right().isLiteral("9223372036854775807"); testFilter.runOnETAllPrim("PropertyDate eq 2013-09-25") .is("< eq <2013-09-25>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false) .goUpFilterValidator() .root().right().isLiteral("2013-09-25"); testFilter.runOnETAllPrim("PropertyDateTimeOffset eq 2013-09-25T12:34:56.123456789012-10:24") .is("< eq <2013-09-25T12:34:56.123456789012-10:24>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath() .isPrimitiveProperty("PropertyDateTimeOffset", EdmTechProvider.nameDateTimeOffset, false) .goUpFilterValidator() @@ -4590,49 +4602,49 @@ public class TestFullResourcePath { testFilter.runOnETAllPrim("PropertyDuration eq duration'P10DT5H34M21.123456789012S'") .is("< eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyDuration", EdmTechProvider.nameDuration, false) .goUpFilterValidator() .root().right().isLiteral("duration'P10DT5H34M21.123456789012S'"); testFilter.runOnETAllPrim("PropertyGuid eq 005056A5-09B1-1ED3-89BD-FB81372CCB33") .is("< eq <005056A5-09B1-1ED3-89BD-FB81372CCB33>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyGuid", EdmTechProvider.nameGuid, false) .goUpFilterValidator() .root().right().isLiteral("005056A5-09B1-1ED3-89BD-FB81372CCB33"); testFilter.runOnETAllPrim("PropertyString eq 'somestring'") .is("< eq <'somestring'>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false) .goUpFilterValidator() .root().right().isLiteral("'somestring'"); testFilter.runOnETAllPrim("PropertyTimeOfDay eq 12:34:55.12345678901") .is("< eq <12:34:55.12345678901>>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isPrimitiveProperty("PropertyTimeOfDay", EdmTechProvider.nameTimeOfDay, false) .goUpFilterValidator() .root().right().isLiteral("12:34:55.12345678901"); testFilter.runOnETTwoKeyNav("PropertyEnumString eq com.sap.odata.test1.ENString'String1'") .is("< eq >>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) .goUpFilterValidator() .root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String1")); testFilter.runOnETTwoKeyNav("PropertyEnumString eq com.sap.odata.test1.ENString'String2'") .is("< eq >>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString) .goUpFilterValidator() .root().right().isEnum(EdmTechProvider.nameENString, Arrays.asList("String2")); testFilter.runOnETTwoKeyNav("PropertyComplexEnum/PropertyEnumString eq com.sap.odata.test1.ENString'String3'") .is("< eq >>") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath() .first().isComplex("PropertyComplexEnum") .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString).goUpFilterValidator() @@ -4640,7 +4652,7 @@ public class TestFullResourcePath { testFilter.runOnETTwoKeyNav("PropertyComplexEnum/PropertyEnumString eq PropertyComplexEnum/PropertyEnumString") .is("< eq >") - .isBinary(SupportedBinaryOperators.EQ) + .isBinary(BinaryOperatorKind.EQ) .root().left().goPath() .first().isComplex("PropertyComplexEnum") .n().isComplex("PropertyEnumString").isType(EdmTechProvider.nameENString).goUpFilterValidator() @@ -4651,26 +4663,26 @@ public class TestFullResourcePath { } @Test - public void testOrderby() throws UriParserException { + public void testOrderby() throws UriParserException, UnsupportedEncodingException { testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam(" + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString'") .isSortOrder(0, false) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(0).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator() .goOrder(0).right().isLiteral("'SomeString'"); testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam(" + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' asc") .isSortOrder(0, false) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(0).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator() .goOrder(0).right().isLiteral("'SomeString'"); testFilter.runOrderByOnETTwoKeyNav("com.sap.odata.test1.UFCRTETAllPrimTwoParam(" + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc") .isSortOrder(0, true) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(0).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator() .goOrder(0).right().isLiteral("'SomeString'"); @@ -4678,18 +4690,18 @@ public class TestFullResourcePath { + "ParameterString=@ParamStringAlias,ParameterInt16=@ParamInt16Alias)/PropertyString eq 'SomeString' desc" + ", PropertyString eq '1'") .isSortOrder(0, true) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(0).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isFunction("UFCRTETAllPrimTwoParam").goUpFilterValidator() .goOrder(0).right().isLiteral("'SomeString'") .isSortOrder(1, false) - .goOrder(1).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(1).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isPrimitiveProperty("PropertyString", EdmTechProvider.nameString, false).goUpFilterValidator() .goOrder(1).right().isLiteral("'1'"); testFilter.runOrderByOnETTwoKeyNav("PropertyComplex/PropertyComplex/PropertyDate eq " + "$root/ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplex/PropertyComplex/PropertyDate") .isSortOrder(0, false) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ).left().goPath() + .goOrder(0).isBinary(BinaryOperatorKind.EQ).left().goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") .n().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false) @@ -4716,7 +4728,7 @@ public class TestFullResourcePath { testFilter.runOrderByOnETTwoKeyNav("PropertyComplex/PropertyComplex/PropertyDate " + "eq 2013-11-12 desc, PropertyString eq 'SomeString' desc") .isSortOrder(0, true) - .goOrder(0).isBinary(SupportedBinaryOperators.EQ) + .goOrder(0).isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isComplex("PropertyComplex") .n().isComplex("PropertyComplex") @@ -4742,7 +4754,7 @@ public class TestFullResourcePath { .goOrder(0).goPath() .first().isComplex("PropertyComplex").goUpFilterValidator() .isSortOrder(1, false) - .goOrder(1).isBinary(SupportedBinaryOperators.EQ) + .goOrder(1).isBinary(BinaryOperatorKind.EQ) .left().goPath() .first().isComplex("PropertyComplex") .n().isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false).goUpFilterValidator() @@ -4788,25 +4800,24 @@ public class TestFullResourcePath { .isSortOrder(0, false) .goOrder(0).left().goPath().isPrimitiveProperty("PropertyBoolean", EdmTechProvider.nameBoolean, false) .goUpFilterValidator() - .goOrder(0).right().isConstant(SupportedConstants.TRUE); + .goOrder(0).right().isTrue(); testFilter.runOrderByOnETAllPrim("PropertyBoolean eq true desc") .isSortOrder(0, true) .goOrder(0).left().goPath().isPrimitiveProperty("PropertyBoolean", EdmTechProvider.nameBoolean, false) .goUpFilterValidator() - .goOrder(0).right().isConstant(SupportedConstants.TRUE); - /* - * testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38") - * .isSortOrder(0, false) - * .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false) - * .goUpFilterValidator() - * .goOrder(0).right().isLiteral("3.5E+38"); - * - * testFilter.runOrderByOnETAllPrim("PropertyDouble eq 3.5E+38 desc").isSortOrder(0, true) - * .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false) - * .goUpFilterValidator() - * .goOrder(0).right().isLiteral("3.5E+38"); - */ + .goOrder(0).right().isTrue(); + + testFilter.runOrderByOnETAllPrim(encode("PropertyDouble eq 3.5E+38")) + .isSortOrder(0, false) + .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false) + .goUpFilterValidator() + .goOrder(0).right().isLiteral("3.5E+38"); + + testFilter.runOrderByOnETAllPrim(encode("PropertyDouble eq 3.5E+38 desc")).isSortOrder(0, true) + .goOrder(0).left().goPath().isPrimitiveProperty("PropertyDouble", EdmTechProvider.nameDouble, false) + .goUpFilterValidator() + .goOrder(0).right().isLiteral("3.5E+38"); testFilter.runOrderByOnETAllPrim("PropertySingle eq 1.5") .isSortOrder(0, false) @@ -4976,15 +4987,51 @@ 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); testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 asc, PropertyInt32 PropertyDuration desc").isExSyntax(0); } - public static String encode(final String decoded) throws UnsupportedEncodingException { + public void testSearch() { + testUri.run("ESTwoKeyNav?$search=abc"); + testUri.run("ESTwoKeyNav?$search=NOT abc"); + + testUri.run("ESTwoKeyNav?$search=abc AND def"); + testUri.run("ESTwoKeyNav?$search=abc OR def"); + testUri.run("ESTwoKeyNav?$search=abc def"); + + testUri.run("ESTwoKeyNav?$search=abc AND def AND ghi"); + testUri.run("ESTwoKeyNav?$search=abc AND def OR ghi"); + testUri.run("ESTwoKeyNav?$search=abc AND def ghi"); + + testUri.run("ESTwoKeyNav?$search=abc OR def AND ghi"); + testUri.run("ESTwoKeyNav?$search=abc OR def OR ghi"); + testUri.run("ESTwoKeyNav?$search=abc OR def ghi"); + + testUri.run("ESTwoKeyNav?$search=abc def AND ghi"); + testUri.run("ESTwoKeyNav?$search=abc def OR ghi"); + testUri.run("ESTwoKeyNav?$search=abc def ghi"); + + // mixed not + testUri.run("ESTwoKeyNav?$search= abc def AND ghi"); + testUri.run("ESTwoKeyNav?$search=NOT abc NOT def OR NOT ghi"); + testUri.run("ESTwoKeyNav?$search= abc def NOT ghi"); + + // parenthesis + testUri.run("ESTwoKeyNav?$search= (abc)"); + testUri.run("ESTwoKeyNav?$search= (abc AND def)"); + testUri.run("ESTwoKeyNav?$search= (abc AND def) OR ghi "); + testUri.run("ESTwoKeyNav?$search= (abc AND def) ghi "); + testUri.run("ESTwoKeyNav?$search= abc AND (def OR ghi)"); + testUri.run("ESTwoKeyNav?$search= abc AND (def ghi)"); + } + + public static String encode(final String decoded) throws UnsupportedEncodingException { return URLEncoder.encode(decoded, "UTF-8"); } + } diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java index 9303d9439..50015fac4 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestLexer.java @@ -41,6 +41,7 @@ public class TestLexer { @Test public void test() { + // test.log(1).run("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38"); } // ;------------------------------------------------------------------------------ diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java index 315cd5165..f14ddbb27 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/antlr/TestUriParserImpl.java @@ -18,8 +18,6 @@ */ package org.apache.olingo.odata4.server.core.uri.antlr; -// TODO after adding the external API to the URI processing class this unit test require a mayor rework - import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; @@ -28,12 +26,12 @@ import org.apache.olingo.odata4.commons.api.edm.Edm; 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.SupportedMethodCalls; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; 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.testutil.FilterValidator; -import org.apache.olingo.odata4.server.core.testutil.UriResourceValidator; +import org.apache.olingo.odata4.server.core.testutil.ResourceValidator; import org.apache.olingo.odata4.server.core.testutil.UriValidator; import org.apache.olingo.odata4.server.core.uri.UriParserException; import org.junit.Test; @@ -60,13 +58,13 @@ public class TestUriParserImpl { + "," + PropertyDateTimeOffset + "," + PropertyDuration + "," + PropertyGuid + "," + PropertyTimeOfDay; UriValidator testUri = null; - UriResourceValidator testRes = null; + ResourceValidator testRes = null; FilterValidator testFilter = null; public TestUriParserImpl() { edm = new EdmProviderImpl(new EdmTechTestProvider()); testUri = new UriValidator().setEdm(edm); - testRes = new UriResourceValidator().setEdm(edm); + testRes = new ResourceValidator().setEdm(edm); testFilter = new FilterValidator().setEdm(edm); } @@ -204,10 +202,7 @@ public class TestUriParserImpl { .isAction("UARTETParam") .isType(EdmTechProvider.nameETTwoKeyTwoPrim, false); - // TODO add error test - // testUri.run("AIRTPrimParam/invalidElement").isKind(UriInfoKind.resource).goPath(). - // isUriPathInfoKind(UriResourceKind.action); - // testUri.run("InvalidAction"); + testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(0); } @Test @@ -1008,7 +1003,6 @@ public class TestUriParserImpl { @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() @@ -1036,7 +1030,7 @@ public class TestUriParserImpl { .isTypeFilterOnEntry(EdmTechProvider.nameCTBase) .at(1).isType(EdmTechProvider.nameString); -// on Complex collection + // on Complex collection testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?" + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString") .goFilter().root().isMember().goPath() @@ -1050,9 +1044,7 @@ public class TestUriParserImpl { @Test public void testComplexTypeCastFollowingAsCollection() { - // TODO inform OTTO testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/com.sap.odata.test1.CTBase"); - } @Test @@ -1086,13 +1078,13 @@ public class TestUriParserImpl { // TODO sync testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)") .is(",)>") - .isMethod(SupportedMethodCalls.GEODISTANCE, 2); + .isMethod(MethodCallKind.GEODISTANCE, 2); testFilter.runOnETAllPrim("geo.length(PropertySByte)") .is(")>") - .isMethod(SupportedMethodCalls.GEOLENGTH, 1); + .isMethod(MethodCallKind.GEOLENGTH, 1); testFilter.runOnETAllPrim("geo.intersects(PropertySByte,PropertySByte)") .is(",)>") - .isMethod(SupportedMethodCalls.GEOINTERSECTS, 2); + .isMethod(MethodCallKind.GEOINTERSECTS, 2); } @Test diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java index e0ec2a8b7..a809073d9 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/QueryOptionTest.java @@ -28,7 +28,6 @@ import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName; import org.apache.olingo.odata4.server.api.uri.UriInfoResource; import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions; 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.apiimpl.UriInfoImpl; import org.apache.olingo.odata4.server.core.uri.queryoption.expression.AliasImpl; @@ -58,7 +57,7 @@ public class QueryOptionTest { // input options ExpandOptionImpl expand = new ExpandOptionImpl(); FilterOptionImpl filter = new FilterOptionImpl(); - InlineCountOptionImpl inlinecount = new InlineCountOptionImpl(); + CountOptionImpl inlinecount = new CountOptionImpl(); OrderByOptionImpl orderby = new OrderByOptionImpl(); SearchOptionImpl search = new SearchOptionImpl(); SelectOptionImpl select = new SelectOptionImpl(); @@ -161,7 +160,7 @@ public class QueryOptionTest { @Test public void testInlineCountImpl() { - InlineCountOptionImpl option = new InlineCountOptionImpl(); + CountOptionImpl option = new CountOptionImpl(); assertEquals(SupportedQueryOptions.INLINECOUNT, option.getKind()); assertEquals(false, option.getValue()); @@ -174,9 +173,9 @@ public class QueryOptionTest { LevelsOptionImpl option = new LevelsOptionImpl(); assertEquals(SupportedQueryOptions.LEVELS, option.getKind()); - assertEquals(0, option.getLevel()); - option.setLevel(1); - assertEquals(1, option.getLevel()); + assertEquals(0, option.getValue()); + option.setValue(1); + assertEquals(1, option.getValue()); option = new LevelsOptionImpl(); option.setMax(); @@ -223,15 +222,13 @@ public class QueryOptionTest { public void testSearchOptionImpl() { SearchOptionImpl option = new SearchOptionImpl(); assertEquals(SupportedQueryOptions.SEARCH, option.getKind()); - // TODO $search not supported yet + // TODO $search is not supported yet } @Test public void testSelectItemImpl() { SelectItemImpl option = new SelectItemImpl(); - edm.getEntityType(EdmTechProvider.nameETKeyNav); - // no typed collection else case ( e.g. if not path is added) option = new SelectItemImpl(); diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ExpressionTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ExpressionTest.java index f520e24d8..5d8e29dd5 100644 --- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ExpressionTest.java +++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ExpressionTest.java @@ -29,14 +29,12 @@ import org.apache.olingo.odata4.commons.api.edm.EdmAction; import org.apache.olingo.odata4.commons.api.edm.EdmEntityType; import org.apache.olingo.odata4.commons.api.edm.EdmEnumType; import org.apache.olingo.odata4.commons.api.edm.EdmFunction; -import org.apache.olingo.odata4.commons.api.edm.EdmType; import org.apache.olingo.odata4.server.api.uri.UriInfoKind; import org.apache.olingo.odata4.server.api.uri.UriInfoResource; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls; -import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind; +import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind; 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; @@ -51,21 +49,18 @@ public class ExpressionTest { @Test public void testSupportedOperators() { - assertEquals(SupportedUnaryOperators.MINUS, SupportedUnaryOperators.get("-")); - assertEquals(null, SupportedUnaryOperators.get("XXX")); + assertEquals(UnaryOperatorKind.MINUS, UnaryOperatorKind.get("-")); + assertEquals(null, UnaryOperatorKind.get("XXX")); - assertEquals(SupportedBinaryOperators.MOD, SupportedBinaryOperators.get("mod")); - assertEquals(null, SupportedBinaryOperators.get("XXX")); + assertEquals(BinaryOperatorKind.MOD, BinaryOperatorKind.get("mod")); + assertEquals(null, BinaryOperatorKind.get("XXX")); - assertEquals(SupportedMethodCalls.CONCAT, SupportedMethodCalls.get("concat")); - assertEquals(null, SupportedMethodCalls.get("XXX")); - - assertEquals(SupportedConstants.TRUE, SupportedConstants.get("true")); - assertEquals(null, SupportedConstants.get("XXX")); + assertEquals(MethodCallKind.CONCAT, MethodCallKind.get("concat")); + assertEquals(null, MethodCallKind.get("XXX")); } @Test - public void testAliasExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testAliasExpression() throws ExpressionVisitException, ODataApplicationException { AliasImpl expression = new AliasImpl(); expression.setParameter("Test"); @@ -78,7 +73,7 @@ public class ExpressionTest { } @Test - public void testBinaryExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testBinaryExpression() throws ExpressionVisitException, ODataApplicationException { BinaryImpl expression = new BinaryImpl(); ExpressionImpl expressionLeft = new LiteralImpl().setText("A"); @@ -86,48 +81,18 @@ public class ExpressionTest { expression.setLeftOperand(expressionLeft); expression.setRightOperand(expressionRight); - expression.setOperator(SupportedBinaryOperators.SUB); + expression.setOperator(BinaryOperatorKind.SUB); assertEquals(expressionLeft, expression.getLeftOperand()); assertEquals(expressionRight, expression.getRightOperand()); - assertEquals(SupportedBinaryOperators.SUB, expression.getOperator()); + assertEquals(BinaryOperatorKind.SUB, expression.getOperator()); String output = expression.accept(new FilterTreeToText()); assertEquals("< sub >", output); } @Test - public void testConstantExpression() throws ExceptionVisitExpression, ODataApplicationException { - ConstantImpl expression = new ConstantImpl(); - EdmType type = edm.getEntityType(EdmTechProvider.nameETKeyNav); - assertNotNull(type); - expression.setType(type); - assertEquals(type, expression.getType()); - - expression.setKind(SupportedConstants.FALSE); - assertEquals(SupportedConstants.FALSE, expression.getKind()); - assertEquals(true, expression.isFalse()); - assertEquals(false, expression.isTrue()); - assertEquals(false, expression.isNull()); - assertEquals("", expression.accept(new FilterTreeToText())); - - expression.setKind(SupportedConstants.TRUE); - assertEquals(SupportedConstants.TRUE, expression.getKind()); - assertEquals(false, expression.isFalse()); - assertEquals(true, expression.isTrue()); - assertEquals(false, expression.isNull()); - assertEquals("", expression.accept(new FilterTreeToText())); - - expression.setKind(SupportedConstants.NULL); - assertEquals(SupportedConstants.NULL, expression.getKind()); - assertEquals(false, expression.isFalse()); - assertEquals(false, expression.isTrue()); - assertEquals(true, expression.isNull()); - assertEquals("", expression.accept(new FilterTreeToText())); - } - - @Test - public void testEnumerationExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testEnumerationExpression() throws ExpressionVisitException, ODataApplicationException { EnumerationImpl expression = new EnumerationImpl(); EdmEnumType type = (EdmEnumType) edm.getEnumType(EdmTechProvider.nameENString); assertNotNull(type); @@ -143,7 +108,7 @@ public class ExpressionTest { } @Test - public void testLambdaRefExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testLambdaRefExpression() throws ExpressionVisitException, ODataApplicationException { LambdaRefImpl expression = new LambdaRefImpl(); expression.setVariableText("A"); assertEquals("A", expression.getVariableName()); @@ -153,7 +118,7 @@ public class ExpressionTest { } @Test - public void testLiteralExpresion() throws ExceptionVisitExpression, ODataApplicationException { + public void testLiteralExpresion() throws ExpressionVisitException, ODataApplicationException { LiteralImpl expression = new LiteralImpl(); expression.setText("A"); assertEquals("A", expression.getText()); @@ -162,11 +127,11 @@ public class ExpressionTest { } @Test - public void testMemberExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testMemberExpression() throws ExpressionVisitException, ODataApplicationException { MemberImpl expression = new MemberImpl(); EdmEntityType entityType = edm.getEntityType(EdmTechProvider.nameETKeyNav); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplTyped EdmAction action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null); UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart( new UriResourceActionImpl().setAction(action)).asUriInfoResource(); @@ -180,28 +145,28 @@ public class ExpressionTest { // UriResourceImplTyped check collection = false case assertEquals(false, expression.isCollection()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplTyped check collection = true case action = edm.getAction(EdmTechProvider.nameUARTPrimCollParam, null, null); expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart( new UriResourceActionImpl().setAction(action)) .asUriInfoResource()); assertEquals(true, expression.isCollection()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplTyped with filter action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null); expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart( new UriResourceActionImpl().setAction(action).setTypeFilter(entityType)) .asUriInfoResource()); assertEquals(entityType, expression.getType()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplKeyPred EdmFunction function = edm.getFunction(EdmTechProvider.nameUFCRTETKeyNav, null, null, null); expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart( new UriResourceFunctionImpl().setFunction(function)) .asUriInfoResource()); assertEquals(function.getReturnType().getType(), expression.getType()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplKeyPred typeFilter on entry EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav); function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null, Arrays.asList(("ParameterInt16"))); @@ -210,7 +175,7 @@ public class ExpressionTest { .asUriInfoResource()); assertEquals(entityBaseType, expression.getType()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // UriResourceImplKeyPred typeFilter on entry entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav); function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null, Arrays.asList(("ParameterInt16"))); @@ -219,7 +184,7 @@ public class ExpressionTest { .asUriInfoResource()); assertEquals(entityBaseType, expression.getType()); - new UriInfoImpl().setKind(UriInfoKind.resource); + // no typed entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav); function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null, Arrays.asList(("ParameterInt16"))); @@ -231,16 +196,16 @@ public class ExpressionTest { } @Test - public void testMethodCallExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testMethodCallExpression() throws ExpressionVisitException, ODataApplicationException { MethodCallImpl expression = new MethodCallImpl(); - expression.setMethod(SupportedMethodCalls.CONCAT); + expression.setMethod(MethodCallKind.CONCAT); ExpressionImpl p0 = new LiteralImpl().setText("A"); ExpressionImpl p1 = new LiteralImpl().setText("B"); expression.addParameter(p0); expression.addParameter(p1); - assertEquals(SupportedMethodCalls.CONCAT, expression.getMethod()); + assertEquals(MethodCallKind.CONCAT, expression.getMethod()); assertEquals(",)>", expression.accept(new FilterTreeToText())); assertEquals(p0, expression.getParameters().get(0)); @@ -248,7 +213,7 @@ public class ExpressionTest { } @Test - public void testTypeLiteralExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testTypeLiteralExpression() throws ExpressionVisitException, ODataApplicationException { TypeLiteralImpl expression = new TypeLiteralImpl(); EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav); expression.setType(entityBaseType); @@ -258,14 +223,14 @@ public class ExpressionTest { } @Test - public void testUnaryExpression() throws ExceptionVisitExpression, ODataApplicationException { + public void testUnaryExpression() throws ExpressionVisitException, ODataApplicationException { UnaryImpl expression = new UnaryImpl(); - expression.setOperator(SupportedUnaryOperators.MINUS); + expression.setOperator(UnaryOperatorKind.MINUS); ExpressionImpl operand = new LiteralImpl().setText("A"); expression.setOperand(operand); - assertEquals(SupportedUnaryOperators.MINUS, expression.getOperator()); + assertEquals(UnaryOperatorKind.MINUS, expression.getOperator()); assertEquals(operand, expression.getOperand()); assertEquals("<- >", expression.accept(new FilterTreeToText()));