@Test(expected = EntityProviderException.class) public void collectionSimpleTypeWrong() throws Exception { final String xml = "<AllUsedRoomIds xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">" + "<m:element xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\" />" + "</AllUsedRoomIds>"; new XmlPropertyConsumer().readCollection(createReaderForTest(xml, true), EntityInfoAggregator.create(MockFacade.getMockEdm().getDefaultEntityContainer() .getFunctionImport("AllUsedRoomIds")), null); }
public List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info, final EntityProviderReadProperties properties) throws EntityProviderException { final String collectionName = info.getName(); final EntityTypeMapping typeMappings = EntityTypeMapping.create( properties == null || !properties.getTypeMappings().containsKey(collectionName) ? Collections.<String, Object> emptyMap() : Collections.<String, Object> singletonMap(FormatXml.D_ELEMENT, properties.getTypeMappings().get(collectionName))); List<Object> result = new ArrayList<Object>(); try { reader.nextTag(); reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.nextTag(); while (reader.isStartElement()) { result.add(readStartedElement(reader, FormatXml.D_ELEMENT, info, typeMappings, properties)); reader.nextTag(); } reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.next(); reader.require(XMLStreamConstants.END_DOCUMENT, null, null); return result; } catch (final XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } }
XmlPropertyConsumer { public List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info, final EntityProviderReadProperties properties) throws EntityProviderException { final String collectionName = info.getName(); final EntityTypeMapping typeMappings = EntityTypeMapping.create( properties == null || !properties.getTypeMappings().containsKey(collectionName) ? Collections.<String, Object> emptyMap() : Collections.<String, Object> singletonMap(FormatXml.D_ELEMENT, properties.getTypeMappings().get(collectionName))); List<Object> result = new ArrayList<Object>(); try { reader.nextTag(); reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.nextTag(); while (reader.isStartElement()) { result.add(readStartedElement(reader, FormatXml.D_ELEMENT, info, typeMappings, properties)); reader.nextTag(); } reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.next(); reader.require(XMLStreamConstants.END_DOCUMENT, null, null); return result; } catch (final XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } } }
XmlPropertyConsumer { public List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info, final EntityProviderReadProperties properties) throws EntityProviderException { final String collectionName = info.getName(); final EntityTypeMapping typeMappings = EntityTypeMapping.create( properties == null || !properties.getTypeMappings().containsKey(collectionName) ? Collections.<String, Object> emptyMap() : Collections.<String, Object> singletonMap(FormatXml.D_ELEMENT, properties.getTypeMappings().get(collectionName))); List<Object> result = new ArrayList<Object>(); try { reader.nextTag(); reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.nextTag(); while (reader.isStartElement()) { result.add(readStartedElement(reader, FormatXml.D_ELEMENT, info, typeMappings, properties)); reader.nextTag(); } reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.next(); reader.require(XMLStreamConstants.END_DOCUMENT, null, null); return result; } catch (final XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } }  }
XmlPropertyConsumer { public List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info, final EntityProviderReadProperties properties) throws EntityProviderException { final String collectionName = info.getName(); final EntityTypeMapping typeMappings = EntityTypeMapping.create( properties == null || !properties.getTypeMappings().containsKey(collectionName) ? Collections.<String, Object> emptyMap() : Collections.<String, Object> singletonMap(FormatXml.D_ELEMENT, properties.getTypeMappings().get(collectionName))); List<Object> result = new ArrayList<Object>(); try { reader.nextTag(); reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.nextTag(); while (reader.isStartElement()) { result.add(readStartedElement(reader, FormatXml.D_ELEMENT, info, typeMappings, properties)); reader.nextTag(); } reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.next(); reader.require(XMLStreamConstants.END_DOCUMENT, null, null); return result; } catch (final XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } }  Map<String, Object> readProperty(final XMLStreamReader reader, final EdmProperty property,
      final EntityProviderReadProperties readProperties); Map<String, Object> readProperty(final XMLStreamReader reader, final EntityPropertyInfo propertyInfo,
      final EntityProviderReadProperties readProperties); List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info,
      final EntityProviderReadProperties properties); }
XmlPropertyConsumer { public List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info, final EntityProviderReadProperties properties) throws EntityProviderException { final String collectionName = info.getName(); final EntityTypeMapping typeMappings = EntityTypeMapping.create( properties == null || !properties.getTypeMappings().containsKey(collectionName) ? Collections.<String, Object> emptyMap() : Collections.<String, Object> singletonMap(FormatXml.D_ELEMENT, properties.getTypeMappings().get(collectionName))); List<Object> result = new ArrayList<Object>(); try { reader.nextTag(); reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.nextTag(); while (reader.isStartElement()) { result.add(readStartedElement(reader, FormatXml.D_ELEMENT, info, typeMappings, properties)); reader.nextTag(); } reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, collectionName); reader.next(); reader.require(XMLStreamConstants.END_DOCUMENT, null, null); return result; } catch (final XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED .addContent(e.getClass().getSimpleName()), e); } }  Map<String, Object> readProperty(final XMLStreamReader reader, final EdmProperty property,
      final EntityProviderReadProperties readProperties); Map<String, Object> readProperty(final XMLStreamReader reader, final EntityPropertyInfo propertyInfo,
      final EntityProviderReadProperties readProperties); List<?> readCollection(XMLStreamReader reader, final EntityPropertyInfo info,
      final EntityProviderReadProperties properties);  }