PayloadInfoElement { public static OMElement createElement(final OMElement umElement, final Collection<IPayload> payloads) { if (Utils.isNullOrEmpty(payloads)) return null; final OMFactory f = umElement.getOMFactory(); final OMElement plInfo = f.createOMElement(Q_ELEMENT_NAME, umElement); for(final IPayload p : payloads) PartInfoElement.createElement(plInfo, p); return plInfo; }  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 testCreateElement() throws Exception { Collection<IPayload> payloads = new ArrayList<>(); Payload p = new Payload(); p.setPayloadURI("cid:as_attachment"); p.addProperty(new Property("p1", "v1")); payloads.add(p); OMElement piElement = PayloadInfoElement.createElement(createParent(), payloads); assertNotNull(piElement); assertEquals(PAYLOAD_INFO_ELEMENT_NAME, piElement.getQName()); Iterator it = piElement.getChildrenWithName(PART_INFO_ELEMENT_NAME); assertTrue(it.hasNext()); it.next(); assertFalse(it.hasNext()); }