mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-06 08:39:14 +00:00
[OLINGO-63] Uri Parser: Extends test cases
This commit is contained in:
parent
ae46250b03
commit
c8d0b26ad6
@ -18,11 +18,15 @@
|
||||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.producer.api.uri;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
|
||||
public interface UriResourceSingleton extends UriResourcePartTyped {
|
||||
EdmType getEntityType();
|
||||
|
||||
|
||||
EdmSingleton getSingleton();
|
||||
EdmEntityType getEntityType();
|
||||
EdmEntityType getEntityTypeFilter();
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
EdmActionImport edmAI = edmEntityContainer.getActionImport(odi);
|
||||
if (edmAI != null) {
|
||||
UriResourceActionImpl uriPathInfo = new UriResourceActionImpl();
|
||||
uriPathInfo.setAction(edmAI.getAction());
|
||||
uriPathInfo.setActionImport(edmAI);
|
||||
|
||||
uriInfoResource.addPathInfo(uriPathInfo);
|
||||
return null;
|
||||
}
|
||||
@ -339,7 +340,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
|
||||
} else {
|
||||
// is
|
||||
if (lastSegment.getComplexTypeFilter() != null) {
|
||||
if (lastSegment.getTypeFilter() != null) {
|
||||
throw wrap(new UriParserSemanticException("Chaining typefilters not allowed"));
|
||||
}
|
||||
|
||||
@ -376,7 +377,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
|
||||
} else {
|
||||
|
||||
if (lastSegment.getComplexTypeFilter() != null) {
|
||||
if (lastSegment.getTypeFilter() != null) {
|
||||
throw wrap(new UriParserSemanticException("Chaining Typefilters not allowed"));
|
||||
}
|
||||
|
||||
@ -459,7 +460,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
return lastKeyPred.getTypeFilterOnCollection();
|
||||
}
|
||||
}
|
||||
EdmType type = lastSegment.getComplexTypeFilter();
|
||||
EdmType type = lastSegment.getTypeFilter();
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
@ -557,7 +558,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
if (type == null) {
|
||||
throw wrap(new UriParserSemanticException("Expected EntityTypeName"));
|
||||
}
|
||||
|
||||
uriInfo.setEntityTypeCast(type);
|
||||
|
||||
contextUriInfo = uriInfo;
|
||||
contextType.push(uriInfo.getEntityTypeCast());
|
||||
|
||||
@ -1049,8 +1051,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
||||
* lastPathInfo.addTypeFilter(typeFilter);
|
||||
* }
|
||||
*/
|
||||
|
||||
return id.setValue(ctx.children.get(2).getText());
|
||||
|
||||
String text = ctx.children.get(2).getText();
|
||||
|
||||
return id.setValue(text).setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +31,7 @@ public abstract class UriResourceImplTyped extends UriResourcePartImpl implement
|
||||
super(kind);
|
||||
}
|
||||
|
||||
public EdmType getComplexTypeFilter() {//TODO rename to TypeFilter
|
||||
public EdmType getTypeFilter() {//TODO rename to TypeFilter
|
||||
return typeFilter;
|
||||
}
|
||||
|
||||
|
@ -18,23 +18,36 @@
|
||||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.producer.core.uri;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.UriResourceSingleton;
|
||||
|
||||
public class UriResourceSingletonImpl extends UriResourceImplTyped {
|
||||
public class UriResourceSingletonImpl extends UriResourceImplTyped implements UriResourceSingleton {
|
||||
|
||||
private EdmSingleton singleton;
|
||||
|
||||
public UriResourceSingletonImpl() {
|
||||
super(UriResourceKind.singleton);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EdmSingleton getSingleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public UriResourceSingletonImpl setSingleton(EdmSingleton singleton) {
|
||||
|
||||
this.singleton = singleton;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmEntityType getEntityTypeFilter() {
|
||||
return (EdmEntityType) typeFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -45,10 +58,24 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped {
|
||||
public EdmType getType() {
|
||||
return singleton.getEntityType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmEntityType getEntityType() {
|
||||
return singleton.getEntityType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ public class EdmTechProvider extends EdmProvider {
|
||||
new Parameter().setName("ParameterInt16").setType(nameInt16)))
|
||||
|
||||
.setReturnType(
|
||||
new ReturnType().setCollection(true).setType(nameCTTwoPrim))
|
||||
new ReturnType().setType(nameCTTwoPrim).setCollection(true))
|
||||
);
|
||||
|
||||
} else if (actionName.equals(nameUARTETParam)) {
|
||||
|
@ -39,7 +39,7 @@ public class FilterValidator implements Validator {
|
||||
private int logLevel;
|
||||
|
||||
// --- Setup ---
|
||||
public FilterValidator SetUriResourcePathValidator(UriResourcePathValidator uriResourcePathValidator) {
|
||||
public FilterValidator SetUriResourcePathValidator(UriResourceValidator uriResourcePathValidator) {
|
||||
this.invokedBy = uriResourcePathValidator;
|
||||
return this;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
||||
import org.apache.olingo.odata4.producer.core.uri.ParserAdapter;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceActionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceComplexPropertyImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
|
||||
@ -46,30 +47,33 @@ import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceEntitySetImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourcePropertyImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceSimplePropertyImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.UriResourceSingletonImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
|
||||
|
||||
public class UriResourcePathValidator implements Validator {
|
||||
public class UriResourceValidator implements Validator {
|
||||
private Edm edm;
|
||||
private Validator invokedBy;
|
||||
private UriInfo uriInfo = null;
|
||||
|
||||
private UriResourcePartImpl uriPathInfo = null;
|
||||
private int uriResourceIndex;
|
||||
|
||||
// --- Setup ---
|
||||
|
||||
public UriResourcePathValidator setUriValidator(UriValidator uriValidator) {
|
||||
public UriResourceValidator setUriValidator(UriValidator uriValidator) {
|
||||
invokedBy = uriValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator setEdm(final Edm edm) {
|
||||
public UriResourceValidator setEdm(final Edm edm) {
|
||||
this.edm = edm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator setUriInfoImplPath(UriInfoImpl uriInfoPath) {
|
||||
public UriResourceValidator setUriInfoImplPath(UriInfoImpl uriInfoPath) {
|
||||
this.uriInfo = uriInfoPath;
|
||||
last();
|
||||
return this;
|
||||
@ -77,7 +81,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
|
||||
// --- Execution ---
|
||||
|
||||
public UriResourcePathValidator run(String uri) {
|
||||
public UriResourceValidator run(String uri) {
|
||||
UriInfoImpl uriInfoTmp = null;
|
||||
uriPathInfo = null;
|
||||
try {
|
||||
@ -102,7 +106,8 @@ public class UriResourcePathValidator implements Validator {
|
||||
return (UriValidator) invokedBy;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator at(int index) {
|
||||
public UriResourceValidator at(int index) {
|
||||
uriResourceIndex = index;
|
||||
try {
|
||||
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
@ -111,7 +116,8 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator first() {
|
||||
public UriResourceValidator first() {
|
||||
uriResourceIndex = 0;
|
||||
try {
|
||||
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(0);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
@ -120,9 +126,23 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator last() {
|
||||
public UriResourceValidator last() {
|
||||
try {
|
||||
uriResourceIndex = 0;
|
||||
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
|
||||
uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enought segemnts");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator n() {
|
||||
uriResourceIndex++;
|
||||
|
||||
try {
|
||||
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enought segemnts");
|
||||
}
|
||||
@ -132,13 +152,19 @@ public class UriResourcePathValidator implements Validator {
|
||||
|
||||
// --- Validation ---
|
||||
|
||||
public UriResourcePathValidator isTypeFilter(FullQualifiedName expectedType) {
|
||||
|
||||
if (uriPathInfo.getKind() != UriResourceKind.complexProperty) {
|
||||
public UriResourceValidator isTypeFilter(FullQualifiedName expectedType) {
|
||||
|
||||
if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
|
||||
uriPathInfo.getKind() != UriResourceKind.singleton) {
|
||||
fail("type wrong ujriResourceKind ( you may also check isTypeFilterOnEntry or isTypeFilterOnCollection");
|
||||
}
|
||||
|
||||
EdmType actualType= ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
|
||||
}
|
||||
|
||||
EdmType actualType = null;
|
||||
if (uriPathInfo instanceof UriResourceComplexPropertyImpl) {
|
||||
actualType = ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
|
||||
} else if (uriPathInfo instanceof UriResourceSingletonImpl) {
|
||||
actualType = ((UriResourceSingletonImpl) uriPathInfo).getEntityTypeFilter();
|
||||
}
|
||||
|
||||
if (actualType == null) {
|
||||
fail("type information not set");
|
||||
@ -150,7 +176,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isType(FullQualifiedName type) {
|
||||
public UriResourceValidator isType(FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourceImplTyped)) {
|
||||
fail("not typed");
|
||||
}
|
||||
@ -164,12 +190,19 @@ public class UriResourcePathValidator implements Validator {
|
||||
FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
|
||||
|
||||
assertEquals(type.toString(), actualName.toString());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isTypeFilterOnEntry(FullQualifiedName type) {
|
||||
public UriResourceValidator isType(FullQualifiedName type, boolean isFinallyACollection) {
|
||||
isType(type);
|
||||
assertEquals(isFinallyACollection, ((UriResourceImplTyped) uriPathInfo).isCollection());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isTypeFilterOnEntry(FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
|
||||
fail("not typed");
|
||||
fail("not keypred");
|
||||
}
|
||||
UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
|
||||
|
||||
@ -184,9 +217,9 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isTypeFilterOnCollection(FullQualifiedName expectedType) {
|
||||
public UriResourceValidator isTypeFilterOnCollection(FullQualifiedName expectedType) {
|
||||
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
|
||||
fail("not typed");
|
||||
fail("not keypred");
|
||||
}
|
||||
UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
|
||||
|
||||
@ -203,7 +236,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
}
|
||||
|
||||
// other functions
|
||||
public UriResourcePathValidator checkCustomParameter(int index, String name, String value) {
|
||||
public UriResourceValidator checkCustomParameter(int index, String name, String value) {
|
||||
if (uriInfo == null) {
|
||||
fail("hasQueryParameter: uriInfo == null");
|
||||
}
|
||||
@ -219,7 +252,8 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isCollection(boolean isCollection) {
|
||||
// TODO remove
|
||||
public UriResourceValidator isCollection(boolean isCollection) {
|
||||
if (!(uriPathInfo instanceof UriResourceImplTyped)) {
|
||||
fail("not typed");
|
||||
}
|
||||
@ -233,7 +267,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isFilterString(String expectedFilterTreeAsString) {
|
||||
public UriResourceValidator isFilterString(String expectedFilterTreeAsString) {
|
||||
|
||||
ExpressionImpl filterTree = (ExpressionImpl) this.uriInfo.getFilterOption().getExpression();
|
||||
try {
|
||||
@ -246,7 +280,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isKeyPredicate(int index, String name, String value) {
|
||||
public UriResourceValidator isKeyPredicate(int index, String name, String value) {
|
||||
if (!(uriPathInfo instanceof UriResourceEntitySetImpl)) {
|
||||
// TODO add and "or" for FunctionImports
|
||||
fail("isKeyPredicate: uriPathInfo is not instanceof UriPathInfoEntitySetImpl");
|
||||
@ -260,12 +294,12 @@ public class UriResourcePathValidator implements Validator {
|
||||
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isKind(UriInfoKind kind) {
|
||||
public UriResourceValidator isKind(UriInfoKind kind) {
|
||||
assertEquals(kind, uriInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isProperty(String name, FullQualifiedName type) {
|
||||
public UriResourceValidator isProperty(String name, FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourcePropertyImpl)) {
|
||||
// TODO add and "or" for FunctionImports
|
||||
fail("not a property");
|
||||
@ -280,7 +314,7 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isComplexProperty(int index, String name, FullQualifiedName type) {
|
||||
public UriResourceValidator isComplexProperty(int index, String name, FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
|
||||
// TODO add and "or" for FunctionImports
|
||||
fail("not a property");
|
||||
@ -295,24 +329,80 @@ public class UriResourcePathValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isUriPathInfoKind(UriResourceKind infoType) {
|
||||
public UriResourceValidator isUriPathInfoKind(UriResourceKind infoType) {
|
||||
assertNotNull(uriPathInfo);
|
||||
assertEquals(infoType, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourcePathValidator isNav(String name, FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
|
||||
// TODO add and "or" for FunctionImports
|
||||
fail("not a property");
|
||||
}
|
||||
|
||||
UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
|
||||
|
||||
EdmElement property = uriPathInfoProp.getNavigationProperty();
|
||||
|
||||
assertEquals(name, property.getName());
|
||||
assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
|
||||
public UriResourceValidator isAction(String name) {
|
||||
assertEquals(UriResourceKind.action, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFunction(String name) {
|
||||
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFunctionImport(String name) {
|
||||
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isEntitySet(String name) {
|
||||
assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isComplex(String name) {
|
||||
assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSimple(String name) {
|
||||
assertEquals(UriResourceKind.simpleProperty, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceSimplePropertyImpl) uriPathInfo).getProperty().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSingleton(String name) {
|
||||
assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isValue() {
|
||||
assertEquals(UriResourceKind.value, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isCount() {
|
||||
assertEquals(UriResourceKind.count, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isRef() {
|
||||
assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isActionImport(String actionName) {
|
||||
assertEquals(UriResourceKind.action, uriPathInfo.getKind());
|
||||
assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isNav(String name) {
|
||||
assertEquals(UriResourceKind.navigationProperty, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceNavigationPropertyImpl) uriPathInfo).getNavigationProperty().getName());
|
||||
// assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.Edm;
|
||||
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.UriInfoKind;
|
||||
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
|
||||
@ -60,12 +61,12 @@ public class UriValidator implements Validator {
|
||||
}
|
||||
|
||||
// Navigation
|
||||
public UriResourcePathValidator goPath() {
|
||||
public UriResourceValidator goPath() {
|
||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||
fail("goPath can only be used on resourcePaths");
|
||||
}
|
||||
|
||||
return new UriResourcePathValidator()
|
||||
return new UriResourceValidator()
|
||||
.setUriValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo);
|
||||
@ -125,15 +126,21 @@ public class UriValidator implements Validator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriValidator isEntityType(FullQualifiedName nameetbase) {
|
||||
public UriValidator isEntityType(FullQualifiedName fullName) {
|
||||
if (uriInfo.getKind() != UriInfoKind.entityId) {
|
||||
fail("isKeyPredicate: uriPathInfo is not instanceof UriInfoImplCrossjoin");
|
||||
}
|
||||
|
||||
assertEquals(nameetbase.toString(), uriInfo.getEntityTypeCast().toString());
|
||||
|
||||
assertEquals(fullName.toString(), fullName(uriInfo.getEntityTypeCast()));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String fullName(EdmEntityType type) {
|
||||
return type.getNamespace() + "." + type.getName();
|
||||
}
|
||||
|
||||
public void isID(String idAsText) {
|
||||
assertEquals(idAsText, uriInfo.getIdOption().getText());
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEn
|
||||
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.FilterValidator;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.UriResourcePathValidator;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.UriResourceValidator;
|
||||
import org.apache.olingo.odata4.producer.core.testutil.UriValidator;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -56,21 +56,21 @@ public class TestUriParserImpl {
|
||||
+ "," + PropertySByte + "," + PropertyInt32 + "," + PropertyInt64 + "," + PropertyDecimal + "," + PropertyDate
|
||||
+ "," + PropertyDateTimeOffset + "," + PropertyDuration + "," + PropertyGuid + "," + PropertyTimeOfDay;
|
||||
FilterValidator testFilter = null;
|
||||
UriResourcePathValidator testPath = null;
|
||||
UriResourceValidator testPath = null;
|
||||
UriValidator testUri = null;
|
||||
|
||||
public TestUriParserImpl() {
|
||||
edm = new EdmProviderImpl(new EdmTechTestProvider());
|
||||
|
||||
testUri = new UriValidator().setEdm(edm);
|
||||
testPath = new UriResourcePathValidator().setEdm(edm);
|
||||
testPath = new UriResourceValidator().setEdm(edm);
|
||||
testFilter = new FilterValidator().setEdm(edm);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
// use this method for error analysis
|
||||
testPath.run("ESAllKey(" + allKeys + ")")
|
||||
.isUriPathInfoKind(UriResourceKind.entitySet)
|
||||
.isKeyPredicate(0, "PropertyString", "'ABC'")
|
||||
@ -79,7 +79,7 @@ public class TestUriParserImpl {
|
||||
|
||||
@Test
|
||||
public void testActionImport() {
|
||||
|
||||
|
||||
testPath.run("AIRTPrimParam")
|
||||
.isUriPathInfoKind(UriResourceKind.action)
|
||||
.isType(EdmTechProvider.nameString);
|
||||
@ -484,7 +484,7 @@ public class TestUriParserImpl {
|
||||
.isType(EdmTechProvider.nameETKeyNav)
|
||||
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||
.at(1)
|
||||
.isNav("NavPropertyETTwoKeyNavOne", EdmTechProvider.nameETTwoKeyNav)
|
||||
.isNav("NavPropertyETTwoKeyNavOne")
|
||||
.isUriPathInfoKind(UriResourceKind.navigationProperty)
|
||||
.isType(EdmTechProvider.nameETTwoKeyNav)
|
||||
.at(2)
|
||||
@ -524,7 +524,7 @@ public class TestUriParserImpl {
|
||||
.isType(EdmTechProvider.nameETKeyNav)
|
||||
.isType(EdmTechProvider.nameETTwoKeyNav)
|
||||
.isKeyPredicate(0, "PropertyInt16", "1")
|
||||
.isNav("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav)
|
||||
.isNav("NavPropertyETTwoKeyNavMany")
|
||||
.at(1)
|
||||
.isUriPathInfoKind(UriResourceKind.navigationProperty)
|
||||
.isType(EdmTechProvider.nameETTwoKeyNav)
|
||||
|
Loading…
x
Reference in New Issue
Block a user