[OLINGO-553] Fixed dispatching for FunctionImport
This commit is contained in:
parent
ae165feedc
commit
65166b4112
|
@ -90,6 +90,49 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void entityCollectionWithAppendedKey() {
|
||||
// .../odata.svc/FICRTCollESMedia()(1)
|
||||
final ODataInvokeRequest<ODataEntity> request = getClient().getInvokeRequestFactory()
|
||||
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
|
||||
.appendOperationCallSegment("FICRTCollESMedia")
|
||||
.appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1))
|
||||
.build(), ODataEntity.class);
|
||||
assertNotNull(request);
|
||||
|
||||
final ODataInvokeResponse<ODataEntity> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
|
||||
final ODataEntity entity = response.getBody();
|
||||
assertNotNull(entity);
|
||||
final ODataProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void entityCollectionWithAppendedKeyAndProperty() {
|
||||
// .../odata.svc/FICRTCollESMedia()(2)/PropertyInt16
|
||||
final ODataInvokeRequest<ODataProperty> request = getClient().getInvokeRequestFactory()
|
||||
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
|
||||
.appendOperationCallSegment("FICRTCollESMedia")
|
||||
.appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2))
|
||||
.appendPropertySegment("PropertyInt16")
|
||||
.build(), ODataProperty.class);
|
||||
assertNotNull(request);
|
||||
|
||||
final ODataInvokeResponse<ODataProperty> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
|
||||
final ODataProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(2, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void countEntityCollection() throws Exception {
|
||||
final ODataRawRequest request = getClient().getRetrieveRequestFactory()
|
||||
|
|
|
@ -299,8 +299,12 @@ public class ODataHandler {
|
|||
throw new ODataHandlerException("No unbound function defined for function import",
|
||||
ODataHandlerException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
|
||||
}
|
||||
EdmReturnType returnType = unboundFunctions.get(0).getReturnType();
|
||||
handleOperationDispatching(request, response, false, returnType);
|
||||
if(uriResourceFunction.getKeyPredicates().isEmpty()) {
|
||||
EdmReturnType returnType = unboundFunctions.get(0).getReturnType();
|
||||
handleOperationDispatching(request, response, false, returnType);
|
||||
} else {
|
||||
handleEntityDispatching(request, response, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleActionDispatching(final ODataRequest request, final ODataResponse response,
|
||||
|
@ -331,19 +335,19 @@ public class ODataHandler {
|
|||
}
|
||||
|
||||
private void handleOperationDispatching(final ODataRequest request, final ODataResponse response,
|
||||
final boolean isAction, final EdmReturnType edmReturnTypeKind)
|
||||
final boolean isAction, final EdmReturnType edmReturnType)
|
||||
throws ODataHandlerException, SerializerException, ContentNegotiatorException,
|
||||
ODataApplicationException, DeserializerException {
|
||||
|
||||
switch (edmReturnTypeKind.getType().getKind()) {
|
||||
switch (edmReturnType.getType().getKind()) {
|
||||
case ENTITY:
|
||||
handleEntityDispatching(request, response, edmReturnTypeKind.isCollection(), false, isAction);
|
||||
handleEntityDispatching(request, response, edmReturnType.isCollection(), false, isAction);
|
||||
break;
|
||||
case PRIMITIVE:
|
||||
handlePrimitivePropertyDispatching(request, response, isAction, edmReturnTypeKind.isCollection());
|
||||
handlePrimitivePropertyDispatching(request, response, isAction, edmReturnType.isCollection());
|
||||
break;
|
||||
case COMPLEX:
|
||||
handleComplexPropertyDispatching(request, response, isAction, edmReturnTypeKind.isCollection());
|
||||
handleComplexPropertyDispatching(request, response, isAction, edmReturnType.isCollection());
|
||||
break;
|
||||
default:
|
||||
throw new ODataHandlerException("not implemented",
|
||||
|
|
Loading…
Reference in New Issue