From 36219d3258eaa350493a0ff06a5b4bcc49d8d6b5 Mon Sep 17 00:00:00 2001 From: Klaus Straubinger Date: Thu, 12 Mar 2015 15:53:03 +0100 Subject: [PATCH] [OLINGO-557] small fix in technical service Change-Id: I12b8e4ca94b7db28cae77a5fb173a4d90075fda6 Signed-off-by: Christian Amend --- .../tecsvc/client/FunctionImportITCase.java | 31 ++++++++++++------- .../TechnicalPrimitiveComplexProcessor.java | 16 +++++----- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java index 2e51fd298..ec3331e68 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FunctionImportITCase.java @@ -89,15 +89,14 @@ public class FunctionImportITCase extends AbstractBaseTestITCase { assertEquals("2", property.getPrimitiveValue().toValue()); } - @Test public void entityCollectionWithAppendedKey() { // .../odata.svc/FICRTCollESMedia()(1) final ODataInvokeRequest request = getClient().getInvokeRequestFactory() - .getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI) - .appendOperationCallSegment("FICRTCollESMedia") - .appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1)) - .build(), ODataEntity.class); + .getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI) + .appendOperationCallSegment("FICRTCollESMedia") + .appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1)) + .build(), ODataEntity.class); assertNotNull(request); final ODataInvokeResponse response = request.execute(); @@ -111,16 +110,15 @@ public class FunctionImportITCase extends AbstractBaseTestITCase { assertEquals(1, property.getPrimitiveValue().toValue()); } - @Test public void entityCollectionWithAppendedKeyAndProperty() { // .../odata.svc/FICRTCollESMedia()(2)/PropertyInt16 final ODataInvokeRequest request = getClient().getInvokeRequestFactory() - .getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI) - .appendOperationCallSegment("FICRTCollESMedia") - .appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2)) - .appendPropertySegment("PropertyInt16") - .build(), ODataProperty.class); + .getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI) + .appendOperationCallSegment("FICRTCollESMedia") + .appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2)) + .appendPropertySegment("PropertyInt16") + .build(), ODataProperty.class); assertNotNull(request); final ODataInvokeResponse response = request.execute(); @@ -132,7 +130,6 @@ public class FunctionImportITCase extends AbstractBaseTestITCase { assertEquals(2, property.getPrimitiveValue().toValue()); } - @Test public void countEntityCollection() throws Exception { final ODataRawRequest request = getClient().getRetrieveRequestFactory() @@ -187,6 +184,16 @@ public class FunctionImportITCase extends AbstractBaseTestITCase { assertEquals("UFCRTString string value", response.getBody().toValue()); } + @Test + public void primitiveValueWithPath() throws Exception { + final ODataValueRequest request = getClient().getRetrieveRequestFactory() + .getPropertyValueRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI) + .appendOperationCallSegment("FICRTCTTwoPrim") + .appendPropertySegment("PropertyString").appendValueSegment().build()); + final ODataRetrieveResponse response = request.execute(); + assertEquals("UFCRTCTTwoPrim string value", response.getBody().toValue()); + } + @Override protected ODataClient getClient() { ODataClient odata = ODataClientFactory.getClient(); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java index f1dfa954d..e36dc6b7c 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java @@ -208,12 +208,11 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor final List path = getPropertyPath(resourceParts, 0); final Entity entity = readEntity(uriInfo); - final Property property = - entity == null ? - getPropertyData(dataProvider.readFunctionPrimitiveComplex(((UriResourceFunction) resourceParts.get(0)) - .getFunction(), - ((UriResourceFunction) resourceParts.get(0)).getParameters()), path) : - getPropertyData(entity, path); + final Property property = entity == null ? + getPropertyData(dataProvider.readFunctionPrimitiveComplex(((UriResourceFunction) resourceParts.get(0)) + .getFunction(), + ((UriResourceFunction) resourceParts.get(0)).getParameters()), path) : + getPropertyData(entity, path); if (property == null) { throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT); @@ -368,8 +367,9 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor final Entity entity = readEntity(uriInfo); final Property property = entity == null ? - dataProvider.readFunctionPrimitiveComplex(((UriResourceFunction) resourceParts.get(0)).getFunction(), - ((UriResourceFunction) resourceParts.get(0)).getParameters()) : + getPropertyData(dataProvider.readFunctionPrimitiveComplex(((UriResourceFunction) resourceParts.get(0)) + .getFunction(), + ((UriResourceFunction) resourceParts.get(0)).getParameters()), path) : getPropertyData(entity, path); if (property == null || property.getValue() == null) {