ServiceElement { public static OMElement createElement(final OMElement ciElement, final IService data) { final OMFactory f = ciElement.getOMFactory(); final OMElement service = f.createOMElement(Q_ELEMENT_NAME, ciElement); service.setText(data.getName()); final String type = data.getType(); if ( type != null && !type.isEmpty()) service.addAttribute(LN_ATTR_TYPE, type, null); return service; }  static OMElement createElement(final OMElement ciElement, final IService data); static OMElement getElement(final OMElement ciElement); static org.holodeckb2b.common.messagemodel.Service readElement(final OMElement svcElement); static final QName Q_ELEMENT_NAME; static final String LN_ATTR_TYPE; }
@Test public void testCreateElementWithTypeAttr() throws Exception { Service service = new Service("some_name", "some_type"); OMElement sElement = ServiceElement.createElement(createParent(), service); assertEquals(SERVICE_ELEMENT_NAME, sElement.getQName()); assertEquals("some_type", sElement.getAttributeValue(new QName("type"))); assertEquals("some_name", sElement.getText()); }
@Test public void testCreateElementNoTypeAttr() throws Exception { Service service = new Service("some_name"); OMElement sElement = ServiceElement.createElement(createParent(), service); assertEquals(SERVICE_ELEMENT_NAME, sElement.getQName()); assertNull(sElement.getAttributeValue(new QName("type"))); assertEquals("some_name", sElement.getText()); }