OLINGO-981: Allowing the null value in non-collection navigation binding property

This commit is contained in:
Ramesh Reddy 2016-07-27 09:28:16 -05:00
parent aa8f2cfc2f
commit 37fe8e19b0
2 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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