OLINGO-981: Allowing the null value in non-collection navigation binding property
This commit is contained in:
parent
aa8f2cfc2f
commit
37fe8e19b0
|
@ -439,12 +439,15 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
|||
bindingLink.setType(Constants.ENTITY_COLLECTION_BINDING_LINK_TYPE);
|
||||
bindingLink.setBindingLinks(bindingLinkStrings);
|
||||
} else {
|
||||
assertIsNullNode(key, jsonNode);
|
||||
if (!jsonNode.isValueNode()) {
|
||||
throw new DeserializerException("Binding annotation: " + key + " must be a string value.",
|
||||
DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, key);
|
||||
}
|
||||
if (jsonNode.isNull()) {
|
||||
bindingLink.setBindingLink(null);
|
||||
} else {
|
||||
bindingLink.setBindingLink(jsonNode.asText());
|
||||
}
|
||||
bindingLink.setType(Constants.ENTITY_BINDING_LINK_TYPE);
|
||||
}
|
||||
return bindingLink;
|
||||
|
|
|
@ -1029,8 +1029,10 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
|
|||
+ "\"PropertyString\":\"First Resource - positive values\","
|
||||
+ "\"NavPropertyETTwoPrimOne@odata.bind\":null"
|
||||
+ "}";
|
||||
expectException(entityString, "ETAllPrim",
|
||||
DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION);
|
||||
|
||||
final Entity entity = deserialize(entityString, "ETAllPrim");
|
||||
assertEquals("First Resource - positive values", entity.getProperty("PropertyString").asPrimitive());
|
||||
assertNull(entity.getNavigationBinding("NavPropertyETTwoPrimOne").getBindingLink());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue