use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestValidateDataObject method testValidate_1.
public void testValidate_1() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
try {
DataObject content = this.createNewVoid("ART", insertedDescr, DataObject.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
List<FieldError> errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
String monolistAttributeName = "Autori";
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
monolist.addAttribute();
assertEquals(1, monolist.getAttributes().size());
errors = content.validate(this._groupManager);
assertEquals(2, errors.size());
error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
error = errors.get(1);
// Verifica non valido elemento 1 in attributo lista "Autori"
assertEquals("Monolist:Monotext:Autori_0", error.getFieldCode());
assertEquals(FieldError.INVALID, error.getErrorCode());
} catch (Throwable t) {
throw t;
}
}
Aggregations