Search in sources :

Example 1 with Address

use of org.openmrs.Address in project openmrs-core by openmrs.

the class PersonAddressValidatorTest method validate_shouldFailIfRequiredFieldsAreEmpty.

/**
 * @see PersonAddressValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfRequiredFieldsAreEmpty() {
    executeDataSet(PERSON_ADDRESS_VALIDATOR_DATASET_PACKAGE_PATH);
    Address personAddress = new PersonAddress();
    Errors errors = new BindException(personAddress, "personAddress");
    validator.validate(personAddress, errors);
    Assert.assertEquals(true, errors.hasErrors());
}
Also used : Errors(org.springframework.validation.Errors) PersonAddress(org.openmrs.PersonAddress) Address(org.openmrs.Address) PersonAddress(org.openmrs.PersonAddress) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 2 with Address

use of org.openmrs.Address in project openmrs-core by openmrs.

the class PersonAddressValidatorTest method validate_shouldPassIfRequiredFieldsAreNotEmpty.

/**
 * @see PersonAddressValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPassIfRequiredFieldsAreNotEmpty() {
    executeDataSet(PERSON_ADDRESS_VALIDATOR_DATASET_PACKAGE_PATH);
    Address personAddress = new PersonAddress();
    personAddress.setAddress1("Address1");
    Errors errors = new BindException(personAddress, "personAddress");
    validator.validate(personAddress, errors);
    Assert.assertEquals(false, errors.hasErrors());
}
Also used : Errors(org.springframework.validation.Errors) PersonAddress(org.openmrs.PersonAddress) Address(org.openmrs.Address) PersonAddress(org.openmrs.PersonAddress) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Test (org.junit.Test)2 Address (org.openmrs.Address)2 PersonAddress (org.openmrs.PersonAddress)2 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)2 BindException (org.springframework.validation.BindException)2 Errors (org.springframework.validation.Errors)2