[OLINGO-590] Fix: Single value navigation properties with null values will be correctly deserialized
This commit is contained in:
parent
8b4947b868
commit
f6fa1eeca7
|
@ -250,7 +250,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
|
|||
EntitySetImpl inlineEntitySet = new EntitySetImpl();
|
||||
inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode));
|
||||
link.setInlineEntitySet(inlineEntitySet);
|
||||
} else if (!jsonNode.isArray() && !jsonNode.isValueNode() && !edmNavigationProperty.isCollection()) {
|
||||
} else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
|
||||
&& !edmNavigationProperty.isCollection()) {
|
||||
link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
|
||||
if (!jsonNode.isNull()) {
|
||||
Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode);
|
||||
|
|
|
@ -121,7 +121,25 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void expandedToOneValidNullValue() throws Exception {
|
||||
String entityString =
|
||||
"{\"PropertyInt16\":32767,"
|
||||
+ "\"NavPropertyETAllPrimOne\":null"
|
||||
+ "}";
|
||||
InputStream stream = new ByteArrayInputStream(entityString.getBytes());
|
||||
EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoPrim"));
|
||||
final Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType);
|
||||
|
||||
assertEquals(1, entity.getNavigationLinks().size());
|
||||
final Link link = entity.getNavigationLinks().get(0);
|
||||
|
||||
assertEquals("NavPropertyETAllPrimOne", link.getTitle());
|
||||
assertNull(link.getInlineEntity());
|
||||
assertNull(link.getInlineEntitySet());
|
||||
}
|
||||
|
||||
@Test(expected = DeserializerException.class)
|
||||
public void expandedToOneInvalidStringValue() throws Exception {
|
||||
String entityString =
|
||||
|
|
Loading…
Reference in New Issue