[OLINGO-63] Uri Parser: add Tests for package org.apache.olingo.odata4.producer.core.uri.queryoption
This commit is contained in:
parent
f8d92381a1
commit
224967b5af
|
@ -30,7 +30,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
|
|||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
|
||||
|
||||
public interface UriInfoResource {
|
||||
|
@ -55,7 +55,7 @@ public interface UriInfoResource {
|
|||
|
||||
SkipOption getSkipOption();
|
||||
|
||||
SkiptokenOption getSkipTokenOption();
|
||||
SkipTokenOption getSkipTokenOption();
|
||||
|
||||
TopOption getTopOption();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface ExpandItem {
|
|||
|
||||
ExpandOption getExpand();
|
||||
|
||||
UriInfoResource getPath();
|
||||
UriInfoResource getResourcePath();
|
||||
|
||||
boolean isStar();
|
||||
|
||||
|
|
|
@ -21,5 +21,5 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
|
|||
public interface FormatOption extends SystemQueryOption {
|
||||
|
||||
// TODO Select best representation for format
|
||||
Object getFormat();
|
||||
String getFormat();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
|
|||
|
||||
public interface IdOption extends SystemQueryOption {
|
||||
|
||||
String getIdValue();
|
||||
String getValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
|
|||
|
||||
public interface InlineCountOption extends SystemQueryOption {
|
||||
|
||||
boolean getvalue();
|
||||
boolean getValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
|
||||
|
||||
public interface SelectItem {
|
||||
|
@ -34,6 +35,7 @@ public interface SelectItem {
|
|||
|
||||
EdmEntityType getEntityTypeCast();
|
||||
|
||||
List<UriResourcePart> getPropertyChainList();
|
||||
|
||||
UriInfoResource getPath();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.producer.api.uri.queryoption;
|
||||
|
||||
public interface SkiptokenOption extends SystemQueryOption {
|
||||
public interface SkipTokenOption extends SystemQueryOption {
|
||||
|
||||
String getValue();
|
||||
|
|
@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
|
|||
|
||||
public interface TopOption extends SystemQueryOption {
|
||||
|
||||
String getTopValue();
|
||||
String getValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ public enum SupportedMethodCalls {
|
|||
return syntax;
|
||||
}
|
||||
|
||||
public static SupportedMethodCalls get(final String operator) {
|
||||
public static SupportedMethodCalls get(final String method) {
|
||||
for (SupportedMethodCalls op : SupportedMethodCalls.values()) {
|
||||
if (op.toString().equals(operator + '(')) {
|
||||
if (op.toString().equals(method )) {
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
|
|||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
||||
|
@ -57,7 +57,7 @@ import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
|
|||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SearchOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkiptokenOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipTokenOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.TopOptionImpl;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
private SearchOptionImpl searchOption;
|
||||
private SelectOptionImpl selectOption;
|
||||
private SkipOptionImpl skipOption;
|
||||
private SkiptokenOptionImpl skipTokenOption;
|
||||
private SkipTokenOptionImpl skipTokenOption;
|
||||
private TopOptionImpl topOption;
|
||||
|
||||
private String fragment;
|
||||
|
@ -211,7 +211,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SkiptokenOption getSkipTokenOption() {
|
||||
public SkipTokenOption getSkipTokenOption() {
|
||||
return skipTokenOption;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
} else if (sysItem.getKind() == SupportedQueryOptions.SKIP) {
|
||||
skipOption = (SkipOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SKIPTOKEN) {
|
||||
skipTokenOption = (SkiptokenOptionImpl) sysItem;
|
||||
skipTokenOption = (SkipTokenOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.TOP) {
|
||||
topOption = (TopOptionImpl) sysItem;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
|||
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
|
@ -154,14 +155,14 @@ import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
|
|||
import org.apache.olingo.odata4.producer.core.uri.queryoption.FormatOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.IdOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.LevelsExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.LevelsOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByItemImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectItemImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkiptokenOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipTokenOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.TopOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl;
|
||||
|
@ -1139,10 +1140,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
if (ctx.vR != null) {
|
||||
expandItem.setIsRef(true);
|
||||
} else if (ctx.vM != null) {
|
||||
expandItem.setExpandQueryOption(new LevelsExpandOptionImpl().setMax().setText(ctx.vM.getText()));
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl().setMax();
|
||||
levels.setText(ctx.vM.getText());
|
||||
expandItem.setSystemQueryOption(levels);
|
||||
} else if (ctx.vL != null) {
|
||||
// TODO set value as integer
|
||||
expandItem.setExpandQueryOption(new LevelsExpandOptionImpl().setText(ctx.vL.getText()));
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl().setMax();
|
||||
levels.setText(ctx.vL.getText());
|
||||
expandItem.setSystemQueryOption(levels);
|
||||
}
|
||||
|
||||
} else if (ctx.vEP != null) {
|
||||
|
@ -1154,7 +1159,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
|
||||
List<SystemQueryOptionImpl> list = (List<SystemQueryOptionImpl>) ctx.vEPE.accept(this);
|
||||
for (SystemQueryOptionImpl option : list) {
|
||||
expandItem.setExpandQueryOption(option);
|
||||
expandItem.setSystemQueryOption(option);
|
||||
}
|
||||
contextExpandItemPath = contextExpandItemPathBU;
|
||||
}
|
||||
|
@ -1203,14 +1208,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
targetType = getLastType(lastSegment);
|
||||
isColl = lastSegment.isCollection();
|
||||
} else {
|
||||
if (contextExpandItemPath.getPath() == null) {
|
||||
if (contextExpandItemPath.getResourcePath() == null) {
|
||||
// use the type of the last resource path segement
|
||||
UriResourceImplTyped lastSegment = (UriResourceImplTyped) contextUriInfo.getLastResourcePart();
|
||||
targetType = getLastType(lastSegment);
|
||||
isColl = lastSegment.isCollection();
|
||||
} else {
|
||||
// use the type of the last ''expand'' path segement
|
||||
UriInfoImpl info = (UriInfoImpl) contextExpandItemPath.getPath();
|
||||
UriInfoImpl info = (UriInfoImpl) contextExpandItemPath.getResourcePath();
|
||||
targetType = getLastType((UriResourceImplTyped) info.getLastResourcePart());
|
||||
isColl = ((UriResourceImplTyped) info.getLastResourcePart()).isCollection();
|
||||
}
|
||||
|
@ -1219,14 +1224,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
contextTypes.push(new LastTypeColl(targetType, isColl));
|
||||
|
||||
if (ctx.vC != null) {
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getPath();
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourcePath();
|
||||
resourcePath.addPathInfo(new UriResourceCountImpl());
|
||||
|
||||
for (ExpandCountOptionContext s : ctx.vlEOC) {
|
||||
list.add((SystemQueryOptionImpl) s.accept(this));
|
||||
}
|
||||
} else if (ctx.vR != null) {
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getPath();
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourcePath();
|
||||
resourcePath.addPathInfo(new UriResourceRefImpl());
|
||||
|
||||
for (ExpandRefOptionContext s : ctx.vlEOR) {
|
||||
|
@ -1263,16 +1268,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
|
||||
TerminalNodeImpl c2 = (TerminalNodeImpl) ctx.children.get(2);
|
||||
if (c2.symbol.getType() == UriLexer.ATOM) {
|
||||
format.setValue("atom");
|
||||
format.setFormat("atom");
|
||||
} else if (c2.symbol.getType() == UriLexer.JSON) {
|
||||
format.setValue("json");
|
||||
format.setFormat("json");
|
||||
} else if (c2.symbol.getType() == UriLexer.XML) {
|
||||
format.setValue("xml");
|
||||
format.setFormat("xml");
|
||||
} else if (c2.symbol.getType() == UriLexer.PCHARS) {
|
||||
if (ctx.getChildCount() == 2) {
|
||||
format.setValue(c2.getText());
|
||||
format.setFormat(c2.getText());
|
||||
} else {
|
||||
format.setValue(c2.getText() + "/" + ctx.children.get(4).getText());
|
||||
format.setFormat(c2.getText() + "/" + ctx.children.get(4).getText());
|
||||
}
|
||||
}
|
||||
String text = ctx.children.get(2).getText();
|
||||
|
@ -1371,7 +1376,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public Object visitLevels(LevelsContext ctx) {
|
||||
|
||||
LevelsExpandOptionImpl levels = new LevelsExpandOptionImpl();
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl();
|
||||
|
||||
String text = ctx.children.get(2).getText();
|
||||
|
||||
|
@ -1548,7 +1553,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
public Object visitOrderByItem(OrderByItemContext ctx) {
|
||||
OrderByItemImpl oItem = new OrderByItemImpl();
|
||||
if (ctx.vD != null) {
|
||||
oItem.setSortOrder(true);
|
||||
oItem.setDescending(true);
|
||||
}
|
||||
|
||||
oItem.setExpression((ExpressionImpl) ctx.vC.accept(this));
|
||||
|
@ -1752,11 +1757,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
if (property.isPrimitive()) {
|
||||
UriResourceSimplePropertyImpl simple = new UriResourceSimplePropertyImpl();
|
||||
simple.setProperty(property);
|
||||
contextSelectItem.addPath(simple);
|
||||
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
|
||||
resourcePath.addPathInfo(simple);
|
||||
} else {
|
||||
UriResourceComplexPropertyImpl complex = new UriResourceComplexPropertyImpl();
|
||||
complex.setProperty(property);
|
||||
contextSelectItem.addPath(complex);
|
||||
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
|
||||
resourcePath.addPathInfo(complex);
|
||||
}
|
||||
} else {
|
||||
throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed"));
|
||||
|
@ -1776,7 +1785,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
EdmComplexType ct = edm.getComplexType(fullName);
|
||||
if (ct != null) {
|
||||
if (((EdmStructuralType) prevType).compatibleTo(ct)) {
|
||||
UriResourcePart lastSegment = contextSelectItem.getLastPart();
|
||||
UriResourcePart lastSegment = ((UriInfoImpl)contextSelectItem.getPath()).getLastResourcePart();
|
||||
if (lastSegment instanceof UriResourceImplKeyPred) {
|
||||
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment;
|
||||
lastKeyPred.setCollectionTypeFilter(ct);
|
||||
|
@ -1810,7 +1819,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
if (action != null) {
|
||||
UriResourceActionImpl uriAction = new UriResourceActionImpl();
|
||||
uriAction.setAction(action);
|
||||
contextSelectItem.addPath(uriAction);
|
||||
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
|
||||
resourcePath.addPathInfo(uriAction);
|
||||
}
|
||||
|
||||
// check for function
|
||||
|
@ -1820,7 +1831,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
if (function != null) {
|
||||
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
|
||||
uriFunction.setFunction(function);
|
||||
contextSelectItem.addPath(uriFunction);
|
||||
|
||||
UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
|
||||
resourcePath.addPathInfo(uriFunction);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1839,7 +1852,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
|
||||
@Override
|
||||
public Object visitSkiptoken(final SkiptokenContext ctx) {
|
||||
SkiptokenOptionImpl skiptoken = new SkiptokenOptionImpl();
|
||||
SkipTokenOptionImpl skiptoken = new SkipTokenOptionImpl();
|
||||
|
||||
String text = ctx.children.get(2).getText();
|
||||
|
||||
|
|
|
@ -52,41 +52,34 @@ public class ExpandItemImpl implements ExpandItem {
|
|||
|
||||
private boolean isRef;
|
||||
|
||||
public ExpandItemImpl setEdm(final Edm edm) {
|
||||
return this;
|
||||
}
|
||||
public ExpandItemImpl setSystemQueryOption(final SystemQueryOptionImpl sysItem) {
|
||||
|
||||
public ExpandItemImpl setExpandQueryOption(final QueryOptionImpl item) {
|
||||
if (item instanceof SystemQueryOptionImpl) {
|
||||
SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item;
|
||||
|
||||
if (sysItem.getKind() == SupportedQueryOptions.EXPAND) {
|
||||
expandOption = (ExpandOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
|
||||
filterOption = (FilterOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
|
||||
inlineCountOption = (InlineCountOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
|
||||
orderByOption = (OrderByOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) {
|
||||
searchOption = (SearchOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SELECT) {
|
||||
selectOption = (SelectOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SKIP) {
|
||||
skipOption = (SkipOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.TOP) {
|
||||
topOption = (TopOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.LEVELS) {
|
||||
levelsExpandOption = (LevelsExpandOption) sysItem;
|
||||
}
|
||||
if (sysItem.getKind() == SupportedQueryOptions.EXPAND) {
|
||||
expandOption = (ExpandOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
|
||||
filterOption = (FilterOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
|
||||
inlineCountOption = (InlineCountOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
|
||||
orderByOption = (OrderByOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) {
|
||||
searchOption = (SearchOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SELECT) {
|
||||
selectOption = (SelectOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SKIP) {
|
||||
skipOption = (SkipOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.TOP) {
|
||||
topOption = (TopOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.LEVELS) {
|
||||
levelsExpandOption = (LevelsExpandOption) sysItem;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExpandItemImpl setExpandQueryOptions(final List<QueryOptionImpl> list) {
|
||||
public ExpandItemImpl setSystemQueryOptions(final List<SystemQueryOptionImpl> list) {
|
||||
|
||||
for (QueryOptionImpl item : list) {
|
||||
setExpandQueryOption(item);
|
||||
for (SystemQueryOptionImpl item : list) {
|
||||
setSystemQueryOption(item);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -143,7 +136,7 @@ public class ExpandItemImpl implements ExpandItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UriInfoResource getPath() {
|
||||
public UriInfoResource getResourcePath() {
|
||||
|
||||
return resourcePath;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class FormatOptionImpl extends SystemQueryOptionImpl implements FormatOpt
|
|||
setKind(SupportedQueryOptions.FORMAT);
|
||||
}
|
||||
|
||||
public FormatOptionImpl setValue(final String value) {
|
||||
public FormatOptionImpl setFormat(final String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class IdOptionImpl extends SystemQueryOptionImpl implements IdOption {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getIdValue() {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class InlineCountOptionImpl extends SystemQueryOptionImpl implements Inli
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getvalue() {
|
||||
public boolean getValue() {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,29 +22,25 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
|||
import org.apache.olingo.odata4.producer.api.uri.queryoption.LevelsExpandOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
|
||||
|
||||
public class LevelsExpandOptionImpl extends SystemQueryOptionImpl implements LevelsExpandOption {
|
||||
public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExpandOption {
|
||||
private boolean isMax;
|
||||
private int value;
|
||||
|
||||
public LevelsExpandOptionImpl() {
|
||||
public LevelsOptionImpl() {
|
||||
setKind(SupportedQueryOptions.LEVELS);
|
||||
}
|
||||
|
||||
public LevelsExpandOptionImpl setValue(final int value) {
|
||||
public LevelsOptionImpl setLevel(final int value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMax() {
|
||||
return isMax;
|
||||
}
|
||||
|
||||
public LevelsExpandOptionImpl setMax() {
|
||||
public LevelsOptionImpl setMax() {
|
||||
isMax = true;
|
||||
return this;
|
||||
|
|
@ -22,7 +22,7 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
|||
import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByItem;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
|
||||
|
||||
public class OrderByItemImpl extends SystemQueryOptionImpl implements OrderByItem {
|
||||
public class OrderByItemImpl implements OrderByItem {
|
||||
|
||||
private ExpressionImpl expression;
|
||||
private boolean descending = false; // default sort order is ascending
|
||||
|
@ -32,7 +32,7 @@ public class OrderByItemImpl extends SystemQueryOptionImpl implements OrderByIte
|
|||
return descending;
|
||||
}
|
||||
|
||||
public OrderByItem setSortOrder(final boolean descending) {
|
||||
public OrderByItem setDescending(final boolean descending) {
|
||||
this.descending = descending;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class OrderByOptionImpl extends SystemQueryOptionImpl implements OrderByO
|
|||
for (OrderByItemImpl item : orders) {
|
||||
retList.add(item);
|
||||
}
|
||||
return Collections.unmodifiableList(retList);
|
||||
return retList;
|
||||
}
|
||||
|
||||
public OrderByOptionImpl addOrder(final OrderByItemImpl order) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt
|
|||
|
||||
@Override
|
||||
public SearchExpression getSearchExpression() {
|
||||
// TODO Auto-generated method stub
|
||||
// TODO $search not supported yet
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,43 +18,76 @@
|
|||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
||||
|
||||
//TODO rework this
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.IdOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplTyped;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
|
||||
|
||||
public class SelectItemImpl implements SelectItem {
|
||||
|
||||
private UriResourceImplTyped lastResourcePart;
|
||||
private UriInfoResource path;
|
||||
|
||||
private List<UriResourcePartImpl> parts = new ArrayList<UriResourcePartImpl>();
|
||||
private boolean isStar;
|
||||
private FullQualifiedName addOperationsInSchemaNameSpace;
|
||||
private EdmEntityType entityTypeCast;
|
||||
|
||||
public EdmType getType() {
|
||||
if (lastResourcePart != null) {
|
||||
if (lastResourcePart instanceof UriResourceImplKeyPred) {
|
||||
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastResourcePart;
|
||||
if (lastKeyPred.getTypeFilterOnEntry() != null) {
|
||||
return lastKeyPred.getTypeFilterOnEntry();
|
||||
} else if (lastKeyPred.getTypeFilterOnCollection() != null) {
|
||||
return lastKeyPred.getTypeFilterOnCollection();
|
||||
}
|
||||
UriInfoImpl uriInfo = (UriInfoImpl) path;
|
||||
UriResourcePartImpl lastResourcePart = null;
|
||||
if (uriInfo != null) {
|
||||
lastResourcePart = (UriResourcePartImpl) uriInfo.getLastResourcePart();
|
||||
}
|
||||
|
||||
if (lastResourcePart instanceof UriResourceImplKeyPred) {
|
||||
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastResourcePart;
|
||||
if (lastKeyPred.getTypeFilterOnEntry() != null) {
|
||||
return lastKeyPred.getTypeFilterOnEntry();
|
||||
} else if (lastKeyPred.getTypeFilterOnCollection() != null) {
|
||||
return lastKeyPred.getTypeFilterOnCollection();
|
||||
}
|
||||
EdmType type = lastResourcePart.getTypeFilter();
|
||||
return lastKeyPred.getType();
|
||||
} else if (lastResourcePart instanceof UriResourceImplTyped) {
|
||||
UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastResourcePart;
|
||||
EdmType type = lastTyped.getTypeFilter();
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
return lastTyped.getType();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UriInfoResource getPath() {
|
||||
if (this.path == null) {
|
||||
this.path = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,20 +128,4 @@ public class SelectItemImpl implements SelectItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UriResourcePart> getPropertyChainList() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public UriResourcePart getLastPart() {
|
||||
return lastResourcePart;
|
||||
}
|
||||
|
||||
public SelectItemImpl addPath(final UriResourceImplTyped resourcePart) {
|
||||
parts.add(resourcePart);
|
||||
lastResourcePart = resourcePart;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
|||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
|
||||
|
||||
/* TODO implement */
|
||||
public class SkipOptionImpl extends SystemQueryOptionImpl implements SkipOption {
|
||||
private String value;
|
||||
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
||||
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
|
||||
|
||||
/* TODO implement */
|
||||
public class SkiptokenOptionImpl extends SystemQueryOptionImpl implements SkiptokenOption {
|
||||
public class SkipTokenOptionImpl extends SystemQueryOptionImpl implements SkipTokenOption {
|
||||
private String skipTokenValue;
|
||||
|
||||
public SkiptokenOptionImpl() {
|
||||
public SkipTokenOptionImpl() {
|
||||
setKind(SupportedQueryOptions.SKIPTOKEN);
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ public class SkiptokenOptionImpl extends SystemQueryOptionImpl implements Skipto
|
|||
return skipTokenValue;
|
||||
}
|
||||
|
||||
public SkiptokenOptionImpl setValue(final String skipTokenValue) {
|
||||
public SkipTokenOptionImpl setValue(final String skipTokenValue) {
|
||||
this.skipTokenValue = skipTokenValue;
|
||||
return this;
|
||||
}
|
|
@ -30,6 +30,7 @@ public class TopOptionImpl extends SystemQueryOptionImpl implements TopOption {
|
|||
setKind(SupportedQueryOptions.TOP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -39,10 +40,6 @@ public class TopOptionImpl extends SystemQueryOptionImpl implements TopOption {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTopValue() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ExpandValidator implements Validator {
|
|||
// --- Navigation ---
|
||||
|
||||
public UriResourceValidator goPath() {
|
||||
UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getPath();
|
||||
UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourcePath();
|
||||
|
||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||
fail("goPath() can only be used on UriInfoKind.resource");
|
||||
|
|
|
@ -20,33 +20,351 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
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.EdmFunction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.EdmTechProvider;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.EdmTechTestProvider;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.FilterTreeToText;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceActionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.AliasImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.LiteralImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.MemberImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
//TOOD add getKind check to all
|
||||
public class QueryOptiontest {
|
||||
|
||||
Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
|
||||
|
||||
@Test
|
||||
public void testAliasQueryOption() {
|
||||
AliasQueryOptionImpl option = new AliasQueryOptionImpl();
|
||||
|
||||
|
||||
ExpressionImpl expression = new LiteralImpl();
|
||||
|
||||
|
||||
option.setAliasValue(expression);
|
||||
assertEquals( expression, option.getValue());
|
||||
assertEquals(expression, option.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExandItemImpl() {
|
||||
ExpandItemImpl option = new ExpandItemImpl();
|
||||
|
||||
// input options
|
||||
ExpandOptionImpl expand = new ExpandOptionImpl();
|
||||
FilterOptionImpl filter = new FilterOptionImpl();
|
||||
InlineCountOptionImpl inlinecount = new InlineCountOptionImpl();
|
||||
OrderByOptionImpl orderby = new OrderByOptionImpl();
|
||||
SearchOptionImpl search = new SearchOptionImpl();
|
||||
SelectOptionImpl select = new SelectOptionImpl();
|
||||
SkipOptionImpl skip = new SkipOptionImpl();
|
||||
TopOptionImpl top = new TopOptionImpl();
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl();
|
||||
|
||||
option.setSystemQueryOption(expand);
|
||||
option.setSystemQueryOption(filter);
|
||||
option.setSystemQueryOption(inlinecount);
|
||||
option.setSystemQueryOption(orderby);
|
||||
option.setSystemQueryOption(search);
|
||||
option.setSystemQueryOption(select);
|
||||
option.setSystemQueryOption(skip);
|
||||
option.setSystemQueryOption(top);
|
||||
option.setSystemQueryOption(levels);
|
||||
|
||||
assertEquals(expand, option.getExpand());
|
||||
assertEquals(filter, option.getFilter());
|
||||
assertEquals(inlinecount, option.getInlineCount());
|
||||
assertEquals(orderby, option.getOrderBy());
|
||||
assertEquals(search, option.getSearch());
|
||||
assertEquals(select, option.getSelect());
|
||||
assertEquals(skip, option.getSkip());
|
||||
assertEquals(top, option.getTop());
|
||||
assertEquals(levels, option.getLevels());
|
||||
|
||||
// just for completeness
|
||||
option = new ExpandItemImpl();
|
||||
option.setSystemQueryOption(new IdOptionImpl());
|
||||
|
||||
option = new ExpandItemImpl();
|
||||
List<SystemQueryOptionImpl> list = new ArrayList<SystemQueryOptionImpl>();
|
||||
list.add(expand);
|
||||
list.add(filter);
|
||||
option.setSystemQueryOptions(list);
|
||||
assertEquals(expand, option.getExpand());
|
||||
assertEquals(filter, option.getFilter());
|
||||
|
||||
option = new ExpandItemImpl();
|
||||
assertEquals(false, option.isRef());
|
||||
option.setIsRef(true);
|
||||
assertEquals(true, option.isRef());
|
||||
|
||||
option = new ExpandItemImpl();
|
||||
assertEquals(false, option.isStar());
|
||||
option.setIsStar(true);
|
||||
assertEquals(true, option.isStar());
|
||||
|
||||
option = new ExpandItemImpl();
|
||||
UriInfoResource resource = new UriInfoImpl().asUriInfoResource();
|
||||
option.setResourcePath(resource);
|
||||
assertEquals(resource, option.getResourcePath());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandOptionImpl() {
|
||||
ExpandOptionImpl option = new ExpandOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.EXPAND, option.getKind());
|
||||
|
||||
ExpandItemImpl item1 = new ExpandItemImpl();
|
||||
ExpandItemImpl item2 = new ExpandItemImpl();
|
||||
option.addExpandItem(item1);
|
||||
option.addExpandItem(item2);
|
||||
assertEquals(item1, option.getExpandItems().get(0));
|
||||
assertEquals(item2, option.getExpandItems().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterOptionImpl() {
|
||||
FilterOptionImpl option = new FilterOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.FILTER, option.getKind());
|
||||
|
||||
AliasImpl expression = new AliasImpl();
|
||||
|
||||
option.setExpression(expression);
|
||||
assertEquals(expression, option.getExpression());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatOptionImpl() {
|
||||
FormatOptionImpl option = new FormatOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.FORMAT, option.getKind());
|
||||
|
||||
option.setFormat("A");
|
||||
|
||||
assertEquals("A", option.getFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdOptionImpl() {
|
||||
IdOptionImpl option = new IdOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.ID, option.getKind());
|
||||
|
||||
option.setValue("A");
|
||||
|
||||
assertEquals("A", option.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineCountImpl() {
|
||||
InlineCountOptionImpl option = new InlineCountOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.INLINECOUNT, option.getKind());
|
||||
|
||||
assertEquals(false, option.getValue());
|
||||
option.setValue(true);
|
||||
assertEquals(true, option.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLevelsExpandOptionImpl() {
|
||||
LevelsOptionImpl option = new LevelsOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.LEVELS, option.getKind());
|
||||
|
||||
assertEquals(0, option.getLevel());
|
||||
option.setLevel(1);
|
||||
assertEquals(1, option.getLevel());
|
||||
|
||||
option = new LevelsOptionImpl();
|
||||
option.setMax();
|
||||
assertEquals(true, option.isMax());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderByItemImpl() {
|
||||
OrderByItemImpl option = new OrderByItemImpl();
|
||||
|
||||
AliasImpl expression = new AliasImpl();
|
||||
option.setExpression(expression);
|
||||
assertEquals(expression, option.getExpression());
|
||||
|
||||
assertEquals(false, option.isDescending());
|
||||
option.setDescending(true);
|
||||
assertEquals(true, option.isDescending());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderByOptionImpl() {
|
||||
OrderByOptionImpl option = new OrderByOptionImpl();
|
||||
|
||||
OrderByItemImpl order0 = new OrderByItemImpl();
|
||||
OrderByItemImpl order1 = new OrderByItemImpl();
|
||||
option.addOrder(order0);
|
||||
option.addOrder(order1);
|
||||
|
||||
assertEquals(order0, option.getOrders().get(0));
|
||||
assertEquals(order1, option.getOrders().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryOptionImpl() {
|
||||
QueryOptionImpl option = new AliasQueryOptionImpl();
|
||||
|
||||
option.setName("A");
|
||||
option.setText("B");
|
||||
assertEquals("A", option.getName());
|
||||
assertEquals("B", option.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchOptionImpl() {
|
||||
SearchOptionImpl option = new SearchOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.SEARCH, option.getKind());
|
||||
// TODO $search not supported yet
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectItemImpl() {
|
||||
SelectItemImpl option = new SelectItemImpl();
|
||||
|
||||
EdmEntityType entityType = edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
||||
|
||||
// UriResourceImplTyped
|
||||
UriInfoImpl resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
EdmAction action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
||||
option = new SelectItemImpl();
|
||||
UriInfoImpl infoImpl = (UriInfoImpl) option.getPath();
|
||||
infoImpl.addPathInfo(new UriResourceActionImpl().setAction(action)).asUriInfoResource();
|
||||
assertEquals(action.getReturnType().getType(), option.getType());
|
||||
|
||||
// UriResourceImplTyped with filter
|
||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
||||
option = new SelectItemImpl();
|
||||
infoImpl = (UriInfoImpl) option.getPath();
|
||||
infoImpl.addPathInfo(new UriResourceActionImpl().setAction(action).setTypeFilter(entityType));
|
||||
assertEquals(entityType, option.getType());
|
||||
|
||||
// UriResourceImplKeyPred
|
||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
EdmFunction function = edm.getFunction(EdmTechProvider.nameUFCRTETKeyNav, null, null, null);
|
||||
option = new SelectItemImpl();
|
||||
infoImpl = (UriInfoImpl) option.getPath();
|
||||
infoImpl.addPathInfo(new UriResourceFunctionImpl().setFunction(function));
|
||||
assertEquals(function.getReturnType().getType(), option.getType());
|
||||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
option = new SelectItemImpl();
|
||||
infoImpl = (UriInfoImpl) option.getPath();
|
||||
infoImpl.addPathInfo(new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType));
|
||||
assertEquals(entityBaseType, option.getType());
|
||||
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
resource = new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
infoImpl = (UriInfoImpl) option.getPath();
|
||||
infoImpl.addPathInfo(new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType));
|
||||
assertEquals(entityBaseType, option.getType());
|
||||
|
||||
// no typed collection else case ( e.g. if not path is added)
|
||||
option = new SelectItemImpl();
|
||||
assertEquals(null, option.getType());
|
||||
|
||||
option = new SelectItemImpl();
|
||||
assertEquals(false, option.isStar());
|
||||
option.setStar(true);
|
||||
assertEquals(true, option.isStar());
|
||||
|
||||
option = new SelectItemImpl();
|
||||
assertEquals(false, option.isAllOperationsInSchema());
|
||||
FullQualifiedName fqName = new FullQualifiedName("Namespace", "Name");
|
||||
option.addAllOperationsInSchema(fqName);
|
||||
assertEquals(true, option.isAllOperationsInSchema());
|
||||
assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
|
||||
|
||||
option = new SelectItemImpl();
|
||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
option.setEntityTypeCast(entityBaseType);
|
||||
assertEquals(entityBaseType, option.getEntityTypeCast());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectOptionImpl() {
|
||||
SelectOptionImpl option = new SelectOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.SELECT, option.getKind());
|
||||
|
||||
SelectItemImpl item0 = new SelectItemImpl();
|
||||
SelectItemImpl item1 = new SelectItemImpl();
|
||||
|
||||
ArrayList<SelectItemImpl> list = new ArrayList<SelectItemImpl>();
|
||||
list.add(item0);
|
||||
list.add(item1);
|
||||
option.setSelectItems(list);
|
||||
|
||||
assertEquals(item0, option.getSelectItems().get(0));
|
||||
assertEquals(item1, option.getSelectItems().get(1));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipOptionImpl() {
|
||||
SkipOptionImpl option = new SkipOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.SKIP, option.getKind());
|
||||
|
||||
option.setValue("A");
|
||||
assertEquals("A", option.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipTokenOptionImpl() {
|
||||
SkipTokenOptionImpl option = new SkipTokenOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.SKIPTOKEN, option.getKind());
|
||||
|
||||
option.setValue("A");
|
||||
assertEquals("A", option.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSystemQueryOptionImpl() {
|
||||
SystemQueryOptionImpl option = new SystemQueryOptionImpl();
|
||||
|
||||
option.setKind(SupportedQueryOptions.EXPAND);
|
||||
assertEquals(SupportedQueryOptions.EXPAND, option.getKind());
|
||||
|
||||
assertEquals("$expand", option.getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
@Test
|
||||
public void testTopOptionImpl() {
|
||||
TopOptionImpl option = new TopOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.TOP, option.getKind());
|
||||
|
||||
option.setValue("A");
|
||||
assertEquals("A", option.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,21 @@ import org.junit.Test;
|
|||
|
||||
public class ExpressionTest {
|
||||
Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
|
||||
|
||||
@Test
|
||||
public void testSupportedOperators() {
|
||||
assertEquals(SupportedUnaryOperators.MINUS, SupportedUnaryOperators.get("-") );
|
||||
assertEquals(null, SupportedUnaryOperators.get("XXX") );
|
||||
|
||||
assertEquals(SupportedBinaryOperators.MOD, SupportedBinaryOperators.get("mod") );
|
||||
assertEquals(null, SupportedBinaryOperators.get("XXX") );
|
||||
|
||||
assertEquals(SupportedMethodCalls.CONCAT, SupportedMethodCalls.get("concat") );
|
||||
assertEquals(null, SupportedMethodCalls.get("XXX") );
|
||||
|
||||
assertEquals(SupportedConstants.TRUE, SupportedConstants.get("true") );
|
||||
assertEquals(null, SupportedConstants.get("XXX") );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
|
|
Loading…
Reference in New Issue