From 9d4cf6ad4c95b0ef7e3b97f590f39ee7d1776dd0 Mon Sep 17 00:00:00 2001 From: Christian Holzer Date: Fri, 19 Jun 2015 16:26:25 +0200 Subject: [PATCH] [OLINGO-704] Test added --- .../olingo/fit/tecsvc/client/BasicITCase.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java index ae258941e..2073df4f4 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java @@ -1104,6 +1104,43 @@ public class BasicITCase extends AbstractBaseTestITCase { assertEquals(Long.MAX_VALUE, responseGet.getBody().getPrimitiveValue().toValue()); } + @Test + public void updateComplexPropertyWithIEEE754CompatibleParamter() { + final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI); + client.getConfiguration().setDefaultPubFormat(ContentType.JSON); + final ClientObjectFactory of = client.getObjectFactory(); + final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV) + .appendKeySegment(1) + .appendPropertySegment(PROPERTY_COMP_ALL_PRIM).build(); + + final ODataPropertyUpdateRequest requestUpdate = client.getCUDRequestFactory() + .getPropertyComplexValueUpdateRequest(uri, UpdateType.PATCH, + of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, + of.newComplexValue("CTAllPrim") + .add(of.newPrimitiveProperty(PROPERTY_INT64, + of.newPrimitiveValueBuilder().buildInt64(Long.MIN_VALUE))) + .add(of.newPrimitiveProperty(PROPERTY_DECIMAL, + of.newPrimitiveValueBuilder().buildDecimal(BigDecimal.valueOf(12345678912L)))) + .add(of.newPrimitiveProperty(PROPERTY_INT16, + of.newPrimitiveValueBuilder().buildInt16((short) 2))))); + + requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE); + requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE); + final ODataPropertyUpdateResponse responseUpdate = requestUpdate.execute(); + String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next(); + + final ODataPropertyRequest requestGet = client.getRetrieveRequestFactory().getPropertyRequest(uri); + requestGet.addCustomHeader(HttpHeader.COOKIE, cookie); + requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE); + final ODataRetrieveResponse responseGet = requestGet.execute(); + + final ClientComplexValue complexValue = responseGet.getBody().getComplexValue(); + + assertEquals(Long.MIN_VALUE, complexValue.get(PROPERTY_INT64).getPrimitiveValue().toValue()); + assertEquals(BigDecimal.valueOf(12345678912L), complexValue.get(PROPERTY_DECIMAL).getPrimitiveValue().toValue()); + assertEquals(2, complexValue.get(PROPERTY_INT16).getPrimitiveValue().toValue()); + } + @Test public void updateProperyEdmDecimaltWithIEE754CompatibleParameter() { final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);