CollaborationInfoElement { public static OMElement createElement(final OMElement umElement, final ICollaborationInfo data) { final OMFactory f = umElement.getOMFactory(); final OMElement collabInfo = f.createOMElement(Q_ELEMENT_NAME, umElement); if (data.getAgreement() != null) AgreementRefElement.createElement(collabInfo, data.getAgreement()); ServiceElement.createElement(collabInfo, data.getService()); final OMElement action = f.createOMElement(Q_ACTION, collabInfo); action.setText(data.getAction()); final OMElement convId = f.createOMElement(Q_CONVERSATIONID, collabInfo); convId.setText(data.getConversationId()); return collabInfo; }  static OMElement createElement(final OMElement umElement, final ICollaborationInfo data); static OMElement getElement(final OMElement parent); static org.holodeckb2b.common.messagemodel.CollaborationInfo readElement(final OMElement ciElement); static final QName Q_ELEMENT_NAME; }
@Test public void testCreateElement() throws Exception { CollaborationInfo ciData = new CollaborationInfo(); String aName = "agreement_name"; String aType = "agreement_type"; String aPmode = "some_pmode_id"; ciData.setAgreement(new AgreementReference(aName, aType, aPmode)); ciData.setService(new Service("PackagingTest")); ciData.setAction("some action"); ciData.setConversationId("conv id"); OMElement ciElement = CollaborationInfoElement.createElement(createParent(), ciData); assertNotNull(ciElement); assertEquals(COLLABORATION_INFO_ELEMENT_NAME, ciElement.getQName()); OMElement arElement = AgreementRefElement.getElement(ciElement); assertEquals(AGREEMENT_REF_INFO_ELEMENT_NAME, arElement.getQName()); assertEquals(aName, arElement.getText()); assertEquals(aType, arElement.getAttribute(new QName("type")).getAttributeValue()); assertEquals(aPmode, arElement.getAttribute(new QName("pmode")).getAttributeValue()); OMElement sElement = ServiceElement.getElement(ciElement); assertEquals(SERVICE_ELEMENT_NAME, sElement.getQName()); assertNotNull(ciElement.getChildrenWithName(ACTION_ELEMENT_NAME).next()); assertNotNull(ciElement.getChildrenWithName( CONVERSATIONID_ELEMENT_NAME).next()); }