AgreementRefElement { public static OMElement createElement(final OMElement ciElement, final IAgreementReference data) { final OMFactory f = ciElement.getOMFactory(); final OMElement agreementRef = f.createOMElement(Q_ELEMENT_NAME, ciElement); agreementRef.setText(data.getName()); final String type = data.getType(); if ( type != null && !type.isEmpty()) agreementRef.addAttribute(LN_ATTR_TYPE, type, null); final String pmode = data.getPModeId(); if ( pmode != null && !pmode.isEmpty()) agreementRef.addAttribute(LN_ATTR_PMODE, pmode, null); return agreementRef; }  static OMElement createElement(final OMElement ciElement, final IAgreementReference data); static OMElement getElement(final OMElement ciElement); static AgreementReference readElement(final OMElement element); static final QName Q_ELEMENT_NAME; static final String LN_ATTR_TYPE; static final String LN_ATTR_PMODE; }
@Test public void testCreateElement() throws Exception { String name = "agreement_name"; String type = "agreement_type"; String pmodeId = "some pmode id string"; AgreementReference agreementReference = new AgreementReference(name, type, pmodeId); OMElement agreementRefElement = AgreementRefElement.createElement(createParent(), agreementReference); assertEquals(AGREEMENT_REF_INFO_ELEMENT_NAME, agreementRefElement.getQName()); assertEquals(name, agreementRefElement.getText()); assertEquals(type, agreementRefElement.getAttributeValue(new QName("type"))); assertEquals(pmodeId, agreementRefElement.getAttributeValue(new QName("pmode"))); }