[OLINGO-659] TecSvc: $levels system query options lead now to a 501 not implemented status

This commit is contained in:
Christian Holzer 2015-09-01 14:50:48 +02:00
parent 78a9539e36
commit a3541721ef
2 changed files with 77 additions and 0 deletions

View File

@ -476,6 +476,77 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
}
@Test
public void expandWithLevels() {
final ODataClient client = getClient();
final Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
expandOptions.put(QueryOption.LEVELS, 2);
// expand=*($levels=2)
URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions("*", expandOptions)
.build();
try {
client.getRetrieveRequestFactory().getEntitySetRequest(uri);
} catch(ODataServerErrorException e) {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
// expand=NavPropertyETTwoKeyNavMany($levels=2)
expandOptions.clear();
expandOptions.put(QueryOption.LEVELS, 2);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.build();
try {
client.getRetrieveRequestFactory().getEntitySetRequest(uri);
} catch(ODataServerErrorException e) {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
expandOptions.clear();
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.build();
try {
client.getRetrieveRequestFactory().getEntitySetRequest(uri);
} catch(ODataServerErrorException e) {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2);$levels=3)
expandOptions.clear();
expandOptions.put(QueryOption.LEVELS, 2);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.build();
try {
client.getRetrieveRequestFactory().getEntitySetRequest(uri);
} catch(ODataServerErrorException e) {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
expandOptions.clear();
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
expandOptions.put(QueryOption.LEVELS, 3);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.build();
try {
client.getRetrieveRequestFactory().getEntitySetRequest(uri);
} catch(ODataServerErrorException e) {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
}
private ODataRetrieveResponse<ClientEntitySet> buildRequest(final String entitySet, final String navigationProperty,
final Map<QueryOption, Object> expandOptions) {

View File

@ -75,9 +75,15 @@ public class ExpandSystemQueryOptionHandler {
private void applyExpandOptionToEntity(final Entity entity, final EdmBindingTarget edmBindingTarget,
final ExpandOption expandOption) throws ODataApplicationException {
final EdmEntityType entityType = edmBindingTarget.getEntityType();
for (ExpandItem item : expandOption.getExpandItems()) {
if(item.getLevelsOption() != null) {
throw new ODataApplicationException("$levels is not implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
List<EdmNavigationProperty> navigationProperties = new ArrayList<EdmNavigationProperty>();
if(item.isStar()) {
List<EdmNavigationPropertyBinding> bindings = edmBindingTarget.getNavigationPropertyBindings();