PullRequestElement { public static OMElement createElement(final OMElement messaging, final IPullRequest pullRequest) { final OMElement signalmessage = SignalMessageElement.createElement(messaging); MessageInfoElement.createElement(signalmessage, pullRequest); final OMFactory f = messaging.getOMFactory(); final OMElement prElement = f.createOMElement(Q_ELEMENT_NAME, signalmessage); final String mpc = pullRequest.getMPC(); if (!Utils.isNullOrEmpty(mpc) && !EbMSConstants.DEFAULT_MPC.equals(mpc)) prElement.addAttribute(MPC_ATTR, mpc, null); if (pullRequest instanceof ISelectivePullRequest) { ISelectivePullRequest selectivePull = (ISelectivePullRequest) pullRequest; if (!Utils.isNullOrEmpty(selectivePull.getReferencedMessageId())) { final OMElement refToMsgIdElement = f.createOMElement(Q_REFTO_MESSAGEID, prElement); refToMsgIdElement.setText(selectivePull.getReferencedMessageId()); } if (!Utils.isNullOrEmpty(selectivePull.getConversationId())) { final OMElement convIdElement = f.createOMElement(Q_CONVERSATIONID, prElement); convIdElement.setText(selectivePull.getConversationId()); } final IAgreementReference agreementRef = selectivePull.getAgreementRef(); if (agreementRef != null && !Utils.isNullOrEmpty(agreementRef.getName())) AgreementRefElement.createElement(prElement, agreementRef); final IService service = selectivePull.getService(); if (service != null && !Utils.isNullOrEmpty(service.getName())) ServiceElement.createElement(prElement, service); if (!Utils.isNullOrEmpty(selectivePull.getAction())) { final OMElement actionElement = f.createOMElement(Q_ACTION, prElement); actionElement.setText(selectivePull.getAction()); } } return signalmessage; }  static org.holodeckb2b.common.messagemodel.PullRequest readElement(final OMElement prElement); static OMElement getElement(final SOAPHeaderBlock messaging); static OMElement createElement(final OMElement messaging, final IPullRequest pullRequest); static final QName Q_ELEMENT_NAME; }
@Test public void testCreateElement() throws Exception { PullRequest pullRequest = new PullRequest(); pullRequest.setMPC("some_mpc"); OMElement prSignalElement = PullRequestElement.createElement(headerBlock, pullRequest); assertEquals(SIGNAL_MESSAGE_ELEMENT_NAME, prSignalElement.getQName()); OMElement miElement = prSignalElement.getFirstElement(); assertEquals(MESSAGE_INFO_ELEMENT_NAME, miElement.getQName()); Iterator it = miElement.getChildrenWithName(TIMESTAMP_ELEMENT_NAME); assertTrue(it.hasNext()); it = miElement.getChildrenWithName(MESSAGE_ID_ELEMENT_NAME); assertTrue(it.hasNext()); it = prSignalElement.getChildrenWithName(PULLREQUEST_ELEMENT_NAME); assertTrue(it.hasNext()); OMElement pr = (OMElement)it.next(); assertEquals("some_mpc", pr.getAttributeValue(new QName("mpc"))); }