[OLINGO-1132]Type information is lost when primitive properties with null value is updated
This commit is contained in:
parent
66ea810b0f
commit
ce076387c3
|
@ -211,7 +211,7 @@ public final class AsyncSupportITCase extends AbstractParamTecSvcITCase {
|
|||
assertShortOrInt(42, property1.getPrimitiveValue().toValue());
|
||||
final ClientProperty property2 = createdEntity.getProperty("PropertyDecimal");
|
||||
assertNotNull(property2);
|
||||
assertNull(property2.getPrimitiveValue());
|
||||
assertNull(property2.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -412,7 +412,7 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
|||
property2.getPrimitiveValue().toValue());
|
||||
final ClientProperty property3 = entity.getProperty(PROPERTY_INT64);
|
||||
assertNotNull(property3);
|
||||
assertNull(property3.getPrimitiveValue());
|
||||
assertNull(property3.getPrimitiveValue().toValue());
|
||||
final ClientProperty property4 = entity.getProperty("PropertyDuration");
|
||||
assertNotNull(property4);
|
||||
assertEquals(isJson() ? "PT6S" : BigDecimal.valueOf(6), property4.getPrimitiveValue().toValue());
|
||||
|
@ -439,7 +439,7 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
|||
assertShortOrInt(42, property1.getPrimitiveValue().toValue());
|
||||
final ClientProperty property2 = entity.getProperty(PROPERTY_DECIMAL);
|
||||
assertNotNull(property2);
|
||||
assertNull(property2.getPrimitiveValue());
|
||||
assertNull(property2.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -504,7 +504,7 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
|||
assertNotNull(complex);
|
||||
final ClientProperty property = complex.get(PROPERTY_INT16);
|
||||
assertNotNull(property);
|
||||
assertNull(property.getPrimitiveValue());
|
||||
assertNull(property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -534,7 +534,7 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
|||
assertShortOrInt(42, property1.getPrimitiveValue().toValue());
|
||||
final ClientProperty property2 = createdEntity.getProperty(PROPERTY_DECIMAL);
|
||||
assertNotNull(property2);
|
||||
assertNull(property2.getPrimitiveValue());
|
||||
assertNull(property2.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ClientValuableImpl implements ClientValuable {
|
|||
|
||||
@Override
|
||||
public boolean hasPrimitiveValue() {
|
||||
return !hasNullValue() && value.isPrimitive();
|
||||
return value != null && value.isPrimitive();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.olingo.client.core;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -40,6 +41,8 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
|||
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||
import org.apache.olingo.client.api.domain.ClientValue;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
@ -381,4 +384,21 @@ public class EntityTest extends AbstractTest {
|
|||
public void derivedFromFullJSON() throws Exception {
|
||||
derived(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullValuesForPrimitiveTypes() throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("ESTwoKeyNav.json");
|
||||
final ClientEntity entity = client.getBinder().getODataEntity(
|
||||
client.getDeserializer(ContentType.APPLICATION_JSON).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
Entity entity1 = client.getBinder().getEntity(entity);
|
||||
assertNotNull(entity1);
|
||||
Property property = entity1.getProperty("PropertyComp").asComplex().getValue().
|
||||
get(1).asComplex().getValue().get(2);
|
||||
assertEquals(property.getType(), "Edm.Boolean");
|
||||
assertNull(property.getValue());
|
||||
assertTrue(property.isPrimitive());
|
||||
assertEquals(property.getValueType(), ValueType.PRIMITIVE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
{
|
||||
"@odata.context": "$metadata#ESTwoKeyNav/$entity",
|
||||
"@odata.metadataEtag": "W/\"10fc9ac1-4eec-4bfa-b678-45f606e48601\"",
|
||||
"@odata.type": "#olingo.odata.test1.ETTwoKeyNav",
|
||||
"@odata.id": "ESTwoKeyNav(PropertyInt16=1,PropertyString='1')",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 1,
|
||||
"PropertyString": "1",
|
||||
"PropertyComp": {
|
||||
"@odata.type": "#olingo.odata.test1.CTPrimComp",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 11,
|
||||
"PropertyComp": {
|
||||
"@odata.type": "#olingo.odata.test1.CTAllPrim",
|
||||
"PropertyString": "StringValue",
|
||||
"PropertyBinary@odata.type": "#Binary",
|
||||
"PropertyBinary": "ASNFZ4mrze8=",
|
||||
"PropertyBoolean@odata.type": "#Boolean",
|
||||
"PropertyBoolean": null,
|
||||
"PropertyByte@odata.type": "#Byte",
|
||||
"PropertyByte": 255,
|
||||
"PropertyDate@odata.type": "#Date",
|
||||
"PropertyDate": "2012-12-03",
|
||||
"PropertyDateTimeOffset@odata.type": "#DateTimeOffset",
|
||||
"PropertyDateTimeOffset": null,
|
||||
"PropertyDecimal@odata.type": "#Decimal",
|
||||
"PropertyDecimal": null,
|
||||
"PropertySingle@odata.type": "#Single",
|
||||
"PropertySingle": 179000,
|
||||
"PropertyDouble": -1790000,
|
||||
"PropertyDuration@odata.type": "#Duration",
|
||||
"PropertyDuration": "PT6S",
|
||||
"PropertyGuid@odata.type": "#Guid",
|
||||
"PropertyGuid": "01234567-89ab-cdef-0123-456789abcdef",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 32767,
|
||||
"PropertyInt32@odata.type": "#Int32",
|
||||
"PropertyInt32": 2147483647,
|
||||
"PropertyInt64@odata.type": "#Int64",
|
||||
"PropertyInt64": 92233775807,
|
||||
"PropertySByte@odata.type": "#SByte",
|
||||
"PropertySByte": 127,
|
||||
"PropertyTimeOfDay@odata.type": "#TimeOfDay",
|
||||
"PropertyTimeOfDay": "21:05:59"
|
||||
}
|
||||
},
|
||||
"PropertyCompNav": {
|
||||
"@odata.type": "#olingo.odata.test1.CTBasePrimCompNav",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 1,
|
||||
"PropertyComp": {
|
||||
"@odata.type": "#olingo.odata.test1.CTAllPrim",
|
||||
"PropertyString": "First Resource - positive values",
|
||||
"PropertyBinary@odata.type": "#Binary",
|
||||
"PropertyBinary": "ASNFZ4mrze8=",
|
||||
"PropertyBoolean": true,
|
||||
"PropertyByte@odata.type": "#Byte",
|
||||
"PropertyByte": 255,
|
||||
"PropertyDate@odata.type": "#Date",
|
||||
"PropertyDate": "2012-12-03",
|
||||
"PropertyDateTimeOffset@odata.type": "#DateTimeOffset",
|
||||
"PropertyDateTimeOffset": "2012-12-03T07:16:23Z",
|
||||
"PropertyDecimal@odata.type": "#Decimal",
|
||||
"PropertyDecimal": 34,
|
||||
"PropertySingle@odata.type": "#Single",
|
||||
"PropertySingle": 170000000,
|
||||
"PropertyDouble": -179000000,
|
||||
"PropertyDuration@odata.type": "#Duration",
|
||||
"PropertyDuration": "PT6S",
|
||||
"PropertyGuid@odata.type": "#Guid",
|
||||
"PropertyGuid": "01234567-89ab-cdef-0123-456789abcdef",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 32767,
|
||||
"PropertyInt32@odata.type": "#Int32",
|
||||
"PropertyInt32": 2147483647,
|
||||
"PropertyInt64@odata.type": "#Int64",
|
||||
"PropertyInt64": 92233725807,
|
||||
"PropertySByte@odata.type": "#SByte",
|
||||
"PropertySByte": 127,
|
||||
"PropertyTimeOfDay@odata.type": "#TimeOfDay",
|
||||
"PropertyTimeOfDay": "21:05:59"
|
||||
}
|
||||
},
|
||||
"CollPropertyComp@odata.type": "#Collection(olingo.odata.test1.CTPrimComp)",
|
||||
"CollPropertyComp": [],
|
||||
"CollPropertyCompNav@odata.type": "#Collection(olingo.odata.test1.CTNavFiveProp)",
|
||||
"CollPropertyCompNav": [
|
||||
{
|
||||
"@odata.type": "#olingo.odata.test1.CTNavFiveProp",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 1
|
||||
}
|
||||
],
|
||||
"CollPropertyString@odata.type": "#Collection(String)",
|
||||
"CollPropertyString": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"PropertyCompTwoPrim": {
|
||||
"@odata.type": "#olingo.odata.test1.CTTwoPrim",
|
||||
"PropertyInt16@odata.type": "#Int16",
|
||||
"PropertyInt16": 11,
|
||||
"PropertyString": "11"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue