UserMessageElement { public static UserMessage readElement(final OMElement umElement) { final UserMessage umData = new UserMessage(); final String mpc = umElement.getAttributeValue(new QName(LN_MPC_ATTR)); umData.setMPC(Utils.isNullOrEmpty(mpc) ? EbMSConstants.DEFAULT_MPC : mpc); OMElement child = MessageInfoElement.getElement(umElement); MessageInfoElement.readElement(child, umData); PartyInfoElement.readElement(PartyInfoElement.getElement(umElement), umData); umData.setCollaborationInfo(CollaborationInfoElement.readElement(CollaborationInfoElement.getElement(umElement))); child = MessagePropertiesElement.getElement(umElement); if (child != null) umData.setMessageProperties(MessagePropertiesElement.readElement(child)); child = PayloadInfoElement.getElement(umElement); if (child != null) umData.setPayloads(PayloadInfoElement.readElement(child)); return umData; }  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 testReadElement() throws Exception { UserMessage userMessage = UserMessageElement.readElement(createXML( "<eb3:UserMessage xmlns:eb3=\"http: " <eb3:MessageInfo>\n" + " <eb3:Timestamp>2019-08-05T10:50:09.192Z</eb3:Timestamp>\n" + " <eb3:MessageId>8fba80a5-2a4b-42c4-9c8f-f53207d21673@gecko.fritz.box</eb3:MessageId>\n" + " </eb3:MessageInfo>\n" + " <eb3:PartyInfo>\n" + " <eb3:From>\n" + " <eb3:PartyId>org:holodeckb2b:example:company:A</eb3:PartyId>\n" + " <eb3:Role>http: " </eb3:From>\n" + " <eb3:To>\n" + " <eb3:PartyId type=\"org:holodeckb2b:example:company\">partyb</eb3:PartyId>\n" + " <eb3:Role>http: " </eb3:To>\n" + " </eb3:PartyInfo>\n" + " <eb3:CollaborationInfo>\n" + " <eb3:AgreementRef>UnitTesting</eb3:AgreementRef>\n" + " <eb3:Service>PackagingTest</eb3:Service>\n" + " <eb3:Action>GetElements</eb3:Action>\n" + " <eb3:ConversationId>org:holodeckb2b:test:conversation</eb3:ConversationId>\n" + " </eb3:CollaborationInfo>\n" + " <eb3:MessageProperties>" + " <eb3:Property name=\"additional-meta-data\">message description</eb3:Property>\n" + " </eb3:MessageProperties>" + " <eb3:PayloadInfo>\n" + " <eb3:PartInfo>\n" + " <eb3:PartProperties>\n" + " <eb3:Property name=\"original-file-name\"\n" + " >simple_document.xml</eb3:Property>\n" + " </eb3:PartProperties>\n" + " </eb3:PartInfo>\n" + " <eb3:PartInfo\n" + " href=\"cid:8fba80a5-2a4b-42c4-9c8f-f53207d21673-142514300@gecko.fritz.box\"/>\n" + " </eb3:PayloadInfo>\n" + "</eb3:UserMessage>")); assertNotNull(userMessage); assertNotNull(userMessage.getMessageId()); assertNotNull(userMessage.getSender()); assertNotNull(userMessage.getReceiver()); assertNotNull(userMessage.getCollaborationInfo()); assertFalse(Utils.isNullOrEmpty(userMessage.getMessageProperties())); assertFalse(Utils.isNullOrEmpty(userMessage.getPayloads())); }