UserMessageElement { public static OMElement createElement(final OMElement messaging, final IUserMessage data) { final OMFactory f = messaging.getOMFactory(); final OMElement usermessage = f.createOMElement(Q_ELEMENT_NAME, messaging); final String mpc = data.getMPC(); if (mpc != null && !mpc.equals(EbMSConstants.DEFAULT_MPC)) usermessage.addAttribute(LN_MPC_ATTR, mpc, null); MessageInfoElement.createElement(usermessage, data); PartyInfoElement.createElement(usermessage, data); CollaborationInfoElement.createElement(usermessage, data.getCollaborationInfo()); final Collection<IProperty> msgProps = data.getMessageProperties(); if (!Utils.isNullOrEmpty(msgProps)) MessagePropertiesElement.createElement(usermessage, msgProps); PayloadInfoElement.createElement(usermessage, data.getPayloads()); return usermessage; }  static OMElement createElement(final OMElement messaging, final IUserMessage data); static Iterator<OMElement> getElements(final OMElement messaging); static UserMessage readElement(final OMElement umElement); static final QName Q_ELEMENT_NAME; static final String LN_MPC_ATTR; }
@Test public void testCreateElement() throws Exception { UserMessage userMessage = new UserMessage(); userMessage.setMessageId(UUID.randomUUID().toString()); userMessage.setTimestamp(new Date()); TradingPartner sender = new TradingPartner(); sender.addPartyId(new PartyId("TheSender", null)); sender.setRole("Sender"); userMessage.setSender(sender); TradingPartner receiver = new TradingPartner(); receiver.addPartyId(new PartyId("TheRecipient", null)); receiver.setRole("Receiver"); userMessage.setReceiver(receiver); CollaborationInfo collabInfo = new CollaborationInfo(); collabInfo.setService(new Service("PackagingTest")); collabInfo.setAction("Create"); userMessage.setCollaborationInfo(collabInfo); userMessage.addMessageProperty(new Property("some-meta-data", "description")); Payload p = new Payload(); p.setPayloadURI("cid:as_attachment"); p.addProperty(new Property("p1", "v1")); userMessage.addPayload(p); OMElement umElement = UserMessageElement.createElement(createParent(), userMessage); assertNotNull(umElement); assertEquals(USER_MESSAGE_ELEMENT_NAME, umElement.getQName()); assertNotNull(MessageInfoElement.getElement(umElement)); assertNotNull(CollaborationInfoElement.getElement(umElement)); assertNotNull(MessagePropertiesElement.getElement(umElement)); assertNotNull(PayloadInfoElement.getElement(umElement)); }