@Test public void readWithDoubleInlineContent() throws Exception { String content = readFile("double_expanded_team.xml"); assertNotNull(content); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams"); InputStream reqContent = createContentAsStream(content); XmlEntityDeserializer xec = new XmlEntityDeserializer(); DeserializerProperties consumerProperties = DeserializerProperties.init().build(); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(consumerProperties); ODataEntry entry = xec.readEntry(entitySet, stream); assertNotNull(entry); Map<String, Object> properties = entry.getProperties(); assertEquals("1", properties.get("Id")); assertEquals("Team 1", properties.get("Name")); assertEquals(Boolean.FALSE, properties.get("isScrumTeam")); ODataFeed employeesFeed = (ODataFeed) properties.get("nt_Employees"); List<ODataEntry> employees = employeesFeed.getEntries(); assertEquals(3, employees.size()); ODataEntry employeeNo2 = employees.get(1); Map<String, Object> employessNo2Props = employeeNo2.getProperties(); assertEquals("Frederic Fall", employessNo2Props.get("EmployeeName")); assertEquals("2", employessNo2Props.get("RoomId")); assertEquals(32, employessNo2Props.get("Age")); @SuppressWarnings("unchecked") Map<String, Object> emp2Location = (Map<String, Object>) employessNo2Props.get("Location"); @SuppressWarnings("unchecked") Map<String, Object> emp2City = (Map<String, Object>) emp2Location.get("City"); assertEquals("69190", emp2City.get("PostalCode")); assertEquals("Walldorf", emp2City.get("CityName")); ODataEntry inlinedTeam = (ODataEntry) employessNo2Props.get("ne_Team"); assertEquals("1", inlinedTeam.getProperties().get("Id")); assertEquals("Team 1", inlinedTeam.getProperties().get("Name")); }
public ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); return new XmlEntryDeserializer().readEntry(reader, eia, entity.getReadProperties(), false); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } }
XmlEntityDeserializer { public ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); return new XmlEntryDeserializer().readEntry(reader, eia, entity.getReadProperties(), false); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } }
XmlEntityDeserializer { public ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); return new XmlEntryDeserializer().readEntry(reader, eia, entity.getReadProperties(), false); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); }
XmlEntityDeserializer { public ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); return new XmlEntryDeserializer().readEntry(reader, eia, entity.getReadProperties(), false); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity); ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity); Object readCollection(final EntityPropertyInfo info, EntityStream entityStream); Map<String, Object> readProperty(final EntityPropertyInfo propertyInfo, final EntityStream entityStream); }
XmlEntityDeserializer { public ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity) throws EntityProviderException { XMLStreamReader reader = null; EntityProviderException cachedException = null; try { reader = XmlHelper.createStreamReader(entity.getContent()); EntityInfoAggregator eia = EntityInfoAggregator.create(entitySet); return new XmlEntryDeserializer().readEntry(reader, eia, entity.getReadProperties(), false); } catch (EntityProviderException e) { cachedException = e; throw cachedException; } finally { if (reader != null) { try { reader.close(); } catch (XMLStreamException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED. addContent(e.getClass() .getSimpleName()), e); } } } } } XmlEntityDeserializer(); ODataDeltaFeed readFeed(final EdmEntitySet entitySet, final EntityStream entity); ODataEntry readEntry(final EdmEntitySet entitySet, final EntityStream entity); Object readCollection(final EntityPropertyInfo info, EntityStream entityStream); Map<String, Object> readProperty(final EntityPropertyInfo propertyInfo, final EntityStream entityStream);  }