Search in sources :

Example 6 with IPerson

use of org.jowidgets.cap.ui.impl.beans.IPerson in project jo-client-platform by jo-source.

the class BeanProxyImplTest method testValidateInvalidPersonAfterValidatorsAdded.

@Test
public void testValidateInvalidPersonAfterValidatorsAdded() {
    final IBeanProxy<IPerson> invalidPersonProxy = createPersonProxy(invalidPersonDto);
    IValidationResult validationResult = invalidPersonProxy.validate();
    Assert.assertTrue(validationResult.isOk());
    // after adding validators, bean must have validation error
    invalidPersonProxy.addBeanPropertyValidators(personValidators);
    validationResult = invalidPersonProxy.validate();
    Assert.assertFalse(validationResult.isValid());
    final IValidationMessage worstFirst = validationResult.getWorstFirst();
    Assert.assertEquals(personAttributes.getAttribute(IPerson.NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
    Assert.assertEquals(MessageType.ERROR, worstFirst.getType());
}
Also used : IPerson(org.jowidgets.cap.ui.impl.beans.IPerson) IValidationMessage(org.jowidgets.validation.IValidationMessage) IValidationResult(org.jowidgets.validation.IValidationResult) Test(org.junit.Test)

Example 7 with IPerson

use of org.jowidgets.cap.ui.impl.beans.IPerson in project jo-client-platform by jo-source.

the class BeanProxyImplTest method testValidBeanProxyCreation.

@Test
public void testValidBeanProxyCreation() {
    final IBeanProxy<IPerson> personProxy = createPersonProxy(personDto, personValidators);
    final IPerson person = personProxy.getBean();
    Assert.assertEquals(PERSON_NAME, person.getName());
    Assert.assertEquals(PERSON_LAST_NAME, person.getLastname());
    Assert.assertEquals(PERSON_GENDER, person.getGender());
    Assert.assertFalse(personProxy.isModified(IPerson.NAME_PROPERTY));
    Assert.assertFalse(personProxy.isModified(IPerson.LAST_NAME_PROPERTY));
    Assert.assertFalse(personProxy.isModified(IPerson.GENDER_PROPERTY));
    final IValidationResult validationResult = personProxy.validate();
    Assert.assertTrue(validationResult.isOk());
}
Also used : IPerson(org.jowidgets.cap.ui.impl.beans.IPerson) IValidationResult(org.jowidgets.validation.IValidationResult) Test(org.junit.Test)

Aggregations

IPerson (org.jowidgets.cap.ui.impl.beans.IPerson)7 Test (org.junit.Test)5 IValidationResult (org.jowidgets.validation.IValidationResult)4 IValidationMessage (org.jowidgets.validation.IValidationMessage)3 HashMap (java.util.HashMap)2 IFrame (org.jowidgets.api.widgets.IFrame)1