PropertyElement { public static OMElement createElement(final OMElement parent, final IProperty data) { final OMFactory f = parent.getOMFactory(); final OMElement property = f.createOMElement(Q_ELEMENT_NAME, parent); property.setText(data.getValue()); property.addAttribute(LN_ATTR_NAME, data.getName(), null); String type = data.getType(); if (!Utils.isNullOrEmpty(type)) property.addAttribute(LN_ATTR_TYPE, type, null); return property; }  static OMElement createElement(final OMElement parent, final IProperty data); static Iterator<OMElement> getElements(final OMElement parent); static Property readElement(final OMElement propElement); static final QName Q_ELEMENT_NAME; static final String LN_ATTR_NAME; static final String LN_ATTR_TYPE; }
@Test public void testCreateElementWithType() throws Exception { Property property = new Property("some_new_property01", "some_new_value01", "some_new_type01"); OMElement pElement = PropertyElement.createElement(createParent(), property); assertNotNull(pElement); assertEquals(Q_ELEMENT_NAME, pElement.getQName()); assertEquals(property.getName(), pElement.getAttributeValue(new QName("name"))); assertEquals(property.getType(), pElement.getAttributeValue(new QName("type"))); assertEquals(property.getValue(), pElement.getText()); }
@Test public void testCreateElementNoType() throws Exception { Property property = new Property("some_new_property01", "some_new_value01"); OMElement pElement = PropertyElement.createElement(createParent(), property); assertNotNull(pElement); assertEquals(Q_ELEMENT_NAME, pElement.getQName()); assertEquals(property.getName(), pElement.getAttributeValue(new QName("name"))); assertNull(pElement.getAttributeValue(new QName("type"))); assertEquals(property.getValue(), pElement.getText()); }