This commit is contained in:
Ramesh Reddy 2016-03-24 10:43:04 -05:00
commit 256468aa29
4 changed files with 88 additions and 2 deletions

View File

@ -18,10 +18,54 @@
*/
package org.apache.olingo.server.api.uri;
import java.util.List;
import org.apache.olingo.server.api.uri.queryoption.CountOption;
import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.server.api.uri.queryoption.FormatOption;
import org.apache.olingo.server.api.uri.queryoption.SearchOption;
import org.apache.olingo.server.api.uri.queryoption.SkipOption;
import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption;
import org.apache.olingo.server.api.uri.queryoption.TopOption;
/**
* Used for URI info kind {@link UriInfoKind#all} to describe URIs like
* http://.../serviceroot/$all
*/
public interface UriInfoAll {
// No additional methods needed for now.
/**
* @return List of custom query options used in the URI (without alias definitions)
*/
List<CustomQueryOption> getCustomQueryOptions();
/**
* @return Object containing information of the $format option
*/
FormatOption getFormatOption();
/**
* @return Object containing information of the $count option
*/
CountOption getCountOption();
/**
* @return Object containing information of the $search option
*/
SearchOption getSearchOption();
/**
* @return Object containing information of the $skip option
*/
SkipOption getSkipOption();
/**
* @return Object containing information of the $skiptoken option
*/
SkipTokenOption getSkipTokenOption();
/**
* @return Object containing information of the $top option
*/
TopOption getTopOption();
}

View File

@ -25,6 +25,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.server.api.uri.queryoption.FilterOption;
import org.apache.olingo.server.api.uri.queryoption.FormatOption;
import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
import org.apache.olingo.server.api.uri.queryoption.SearchOption;
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
import org.apache.olingo.server.api.uri.queryoption.SkipOption;
import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption;
@ -65,6 +66,11 @@ public interface UriInfoCrossjoin {
* @return Object containing information of the $orderby option
*/
OrderByOption getOrderByOption();
/**
* @return Object containing information of the $search option
*/
SearchOption getSearchOption();
/**
* @return Object containing information of the $select option

View File

@ -18,6 +18,8 @@
*/
package org.apache.olingo.server.core.uri.parser;
import static org.junit.Assert.assertNotNull;
import java.util.Arrays;
import java.util.Collections;
@ -27,12 +29,13 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.uri.UriInfoAll;
import org.apache.olingo.server.api.uri.UriInfoCrossjoin;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriResourceKind;
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
import org.apache.olingo.server.core.uri.parser.UriParserSemanticException.MessageKeys;
import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
import org.apache.olingo.server.core.uri.parser.search.SearchParserException;
import org.apache.olingo.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
@ -57,6 +60,35 @@ public class TestFullResourcePath {
private final TestUriValidator testUri = new TestUriValidator().setEdm(edm);
private final FilterValidator testFilter = new FilterValidator().setEdm(edm);
@Test
public void allowedSystemQueryOptionsOnAll() throws Exception {
UriInfoAll uriInfoAll = testUri.run("$all", "$count=true&$format=json&$search=abc&$skip=5&$top=5&$skiptoken=abc")
.getUriInfoRoot().asUriInfoAll();
assertNotNull(uriInfoAll.getCountOption());
assertNotNull(uriInfoAll.getFormatOption());
assertNotNull(uriInfoAll.getSearchOption());
assertNotNull(uriInfoAll.getSkipOption());
assertNotNull(uriInfoAll.getTopOption());
assertNotNull(uriInfoAll.getSkipTokenOption());
}
@Test
public void allowedSystemQueryOptionsOnCrossjoin() throws Exception {
UriInfoCrossjoin uriInfoCrossjoin =
testUri.run("$crossjoin(ESAllPrim,ESTwoPrim)", "$count=true&$expand=ESAllPrim"
+ "&$filter=ESAllPrim/PropertyInt16 eq 2&$format=json&$orderby=ESAllPrim/PropertyInt16"
+ "&$search=abc&$skip=5&$top=5&$skiptoken=abc").getUriInfoRoot().asUriInfoCrossjoin();
assertNotNull(uriInfoCrossjoin.getCountOption());
assertNotNull(uriInfoCrossjoin.getExpandOption());
assertNotNull(uriInfoCrossjoin.getFilterOption());
assertNotNull(uriInfoCrossjoin.getFormatOption());
assertNotNull(uriInfoCrossjoin.getOrderByOption());
assertNotNull(uriInfoCrossjoin.getSearchOption());
assertNotNull(uriInfoCrossjoin.getSkipOption());
assertNotNull(uriInfoCrossjoin.getTopOption());
assertNotNull(uriInfoCrossjoin.getSkipTokenOption());
}
@Test
public void trimQueryOptionsValue() throws Exception {
// OLINGO-846 trim query option value

View File

@ -238,4 +238,8 @@ public class TestUriValidator implements TestValidator {
assertEquals(fullName, uriInfo.getEntityTypeCast().getFullQualifiedName());
return this;
}
public UriInfo getUriInfoRoot() {
return uriInfo;
}
}