SchematronCriteria extends GeonetEntity { @Override protected Element asXml(IdentityHashMap<Object, Void> alreadyEncoded) { final Element element = super.asXml(alreadyEncoded); String valueElText = element.getChildText("value"); if (valueElText.length() == 0) { element.getChild("value").setText("''"); } if (element.getChild(EL_UI_TYPE) == null) { element.addContent(new Element(EL_UI_TYPE).setText(getType().toString())); } if (element.getChild(EL_UI_VALUE) == null) { element.addContent(new Element(EL_UI_VALUE).setText(getValue())); } return element; }  @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ID_SEQ_NAME) int getId(); SchematronCriteria setId(int id); @Override String toString(); @Column(nullable = false, name = "type") @Enumerated(EnumType.STRING) SchematronCriteriaType getType(); void setType(SchematronCriteriaType type); @Column(nullable = false, name = "value") String getValue(); void setValue(String value); String getUiType(); void setUiType(String uiType); String getUiValue(); void setUiValue(String uiValue); @ManyToOne(optional = false, fetch = FetchType.EAGER) @PrimaryKeyJoinColumns(value = { @PrimaryKeyJoinColumn(referencedColumnName = "name"), @PrimaryKeyJoinColumn(referencedColumnName = "schematronId") }) SchematronCriteriaGroup getGroup(); void setGroup(SchematronCriteriaGroup group); boolean accepts(ApplicationContext applicationContext, int metadataId, Element metadata, List<Namespace> metadataNamespaces); boolean accepts(ApplicationContext applicationContext, Element metadata, List<Namespace> metadataNamespaces, Integer groupOwnerId); SchematronCriteria copy(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testAsXml() throws Exception { final SchematronCriteria criteria = SchematronCriteriaGroupRepositoryTest.newSchematronCriteria(_inc); criteria.setValue(""); final Element xml = criteria.asXml(); assertEquals("''", xml.getChildText("value")); }