PayloadInfoElement { public static Collection<IPayload> readElement(final OMElement piElement){ if (piElement == null) return null; final ArrayList<IPayload> payloads = new ArrayList<>(); final Iterator<?> it = PartInfoElement.getElements(piElement); while (it.hasNext()) payloads.add(PartInfoElement.readElement((OMElement) it.next())); return payloads; }  static OMElement createElement(final OMElement umElement, final Collection<IPayload> payloads); static OMElement getElement(final OMElement umElement); static Collection<IPayload> readElement(final OMElement piElement); static final QName Q_ELEMENT_NAME; }
@Test public void testReadElement() throws Exception { Payload p1 = new Payload(); p1.setPayloadURI("cid:first_attachment"); Payload p2 = new Payload(); p2.setPayloadURI("#second_attachment"); Collection<IPayload> payloads = PayloadInfoElement.readElement(createXML( "<eb3:PayloadInfo " + " xmlns:eb3=\"http: " <eb3:PartInfo href=\"" + p1.getPayloadURI() + "\"/>" + " <eb3:PartInfo href=\"" + p2.getPayloadURI() + "\"/>" + "</eb3:PayloadInfo>" )); assertFalse(Utils.isNullOrEmpty(payloads)); Iterator<IPayload> payloadsIt = payloads.iterator(); assertTrue(payloadsIt.hasNext()); IPayload p = payloadsIt.next(); assertEquals(IPayload.Containment.ATTACHMENT, p.getContainment()); assertTrue(payloadsIt.hasNext()); p = payloadsIt.next(); assertEquals(IPayload.Containment.BODY, p.getContainment()); assertFalse(payloadsIt.hasNext()); }