@Test public void deepComplexPropertyOnOpenReader() throws Exception { final String complexPropertyJson = "{\"__metadata\":{\"type\":\"RefScenario.c_Location\"}," + "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\"," + "\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}"; JsonReader reader = prepareReader(complexPropertyJson); EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType() .getProperty("Location"); EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(edmProperty); JsonPropertyConsumer jpc = new JsonPropertyConsumer(); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) jpc.readPropertyValue(reader, entityPropertyInfo, null, null); assertEquals(2, result.size()); assertEquals("Germany", result.get("Country")); @SuppressWarnings("unchecked") Map<String, Object> innerResult = (Map<String, Object>) result.get("City"); assertEquals(2, innerResult.size()); assertEquals("Heidelberg", innerResult.get("CityName")); assertEquals("69124", innerResult.get("PostalCode")); }
protected Object readPropertyValue(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo, final Object typeMapping, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { return entityPropertyInfo.isComplex() ? readComplexProperty(reader, (EntityComplexPropertyInfo) entityPropertyInfo, typeMapping, readProperties) : readSimpleProperty(reader, entityPropertyInfo, typeMapping, readProperties); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
JsonPropertyConsumer { protected Object readPropertyValue(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo, final Object typeMapping, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { return entityPropertyInfo.isComplex() ? readComplexProperty(reader, (EntityComplexPropertyInfo) entityPropertyInfo, typeMapping, readProperties) : readSimpleProperty(reader, entityPropertyInfo, typeMapping, readProperties); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
JsonPropertyConsumer { protected Object readPropertyValue(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo, final Object typeMapping, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { return entityPropertyInfo.isComplex() ? readComplexProperty(reader, (EntityComplexPropertyInfo) entityPropertyInfo, typeMapping, readProperties) : readSimpleProperty(reader, entityPropertyInfo, typeMapping, readProperties); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
JsonPropertyConsumer { protected Object readPropertyValue(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo, final Object typeMapping, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { return entityPropertyInfo.isComplex() ? readComplexProperty(reader, (EntityComplexPropertyInfo) entityPropertyInfo, typeMapping, readProperties) : readSimpleProperty(reader, entityPropertyInfo, typeMapping, readProperties); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  Map<String, Object> readPropertyStandalone(JsonReader reader, final EdmProperty edmProperty,
      final EntityProviderReadProperties readProperties); Map<String, Object> readPropertyStandalone(final JsonReader reader, final EntityPropertyInfo propertyInfo,
      final EntityProviderReadProperties readProperties); List<?> readCollection(JsonReader reader, final EntityPropertyInfo propertyInfo,
        final EntityProviderReadProperties readProperties); }
JsonPropertyConsumer { protected Object readPropertyValue(final JsonReader reader, final EntityPropertyInfo entityPropertyInfo, final Object typeMapping, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { return entityPropertyInfo.isComplex() ? readComplexProperty(reader, (EntityComplexPropertyInfo) entityPropertyInfo, typeMapping, readProperties) : readSimpleProperty(reader, entityPropertyInfo, typeMapping, readProperties); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  Map<String, Object> readPropertyStandalone(JsonReader reader, final EdmProperty edmProperty,
      final EntityProviderReadProperties readProperties); Map<String, Object> readPropertyStandalone(final JsonReader reader, final EntityPropertyInfo propertyInfo,
      final EntityProviderReadProperties readProperties); List<?> readCollection(JsonReader reader, final EntityPropertyInfo propertyInfo,
        final EntityProviderReadProperties readProperties);  }