[OLINGO-659] Fix for filter parsing of $count resources

Change-Id: I3359c25f233b6c18360a280b45355cf8ddd9a851

Signed-off-by: Christian Amend <chrisam@apache.org>
This commit is contained in:
Klaus Straubinger 2015-05-12 15:23:00 +02:00 committed by Christian Amend
parent 04baf388ec
commit 7062aff867
2 changed files with 22 additions and 0 deletions

View File

@ -36,7 +36,10 @@ import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriResource;
import org.apache.olingo.server.api.uri.UriResourceCount;
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
import org.apache.olingo.server.api.uri.UriResourceRef;
import org.apache.olingo.server.api.uri.UriResourceValue;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
import org.apache.olingo.server.core.uri.UriInfoImpl;
@ -144,6 +147,12 @@ public class Parser {
}
UriResource lastSegment = context.contextUriInfo.getLastResourcePart();
if (lastSegment instanceof UriResourceCount
|| lastSegment instanceof UriResourceRef
|| lastSegment instanceof UriResourceValue) {
final List<UriResource> parts = context.contextUriInfo.getUriResourceParts();
lastSegment = parts.get(parts.size() - 2);
}
if (lastSegment instanceof UriResourcePartTyped) {
UriResourcePartTyped typed = (UriResourcePartTyped) lastSegment;

View File

@ -4756,7 +4756,20 @@ public class TestFullResourcePath {
.root().right().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
.n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator();
}
@Test
public void filterOnCountAndRef() throws Exception {
testUri.run("ESKeyNav/$count", "$filter=PropertyInt16 ge 0")
.goPath().isCount()
.goUpUriValidator().goFilter().isBinary(BinaryOperatorKind.GE)
.left().goPath().first().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
.goUpFilterValidator().root().right().isLiteral("0");
testUri.run("ESKeyNav/$ref", "$filter=PropertyInt16 ge 0")
.goPath().isRef()
.goUpUriValidator().goFilter().isBinary(BinaryOperatorKind.GE)
.left().goPath().first().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
.goUpFilterValidator().root().right().isLiteral("0");
}
@Test