use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldFailValidationIfConceptNameTagIsNull.
@Test(expected = IllegalArgumentException.class)
public void validate_shouldFailValidationIfConceptNameTagIsNull() {
Errors errors = new BindException(new ConceptNameTag(), "cnt");
new ConceptNameTagValidator().validate(null, errors);
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldFailValidationIfTagIsNullOrEmptyOrWhitespace.
/**
* @see ConceptNameTagValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfTagIsNullOrEmptyOrWhitespace() {
ConceptNameTag cnt = new ConceptNameTag();
Errors errors = new BindException(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertTrue(errors.hasFieldErrors("tag"));
cnt.setTag("");
errors = new BindException(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertTrue(errors.hasFieldErrors("tag"));
cnt.setTag(" ");
errors = new BindException(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertTrue(errors.hasFieldErrors("tag"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class ConceptSourceValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptSource conceptSource = new ConceptSource();
conceptSource.setName("New name");
conceptSource.setDescription("Some description");
conceptSource.setHl7Code("Hl7Code");
conceptSource.setRetireReason("RetireReason");
Errors errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class ConceptSourceValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues.
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
ConceptSource conceptSource = new ConceptSource();
conceptSource.setName("New name");
conceptSource.setDescription("Some description");
Errors errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class ConceptSourceValidatorTest method validate_shouldPassValidationIfHl7CodeIsNullOrEmptyOrWhitespace.
@Test
public void validate_shouldPassValidationIfHl7CodeIsNullOrEmptyOrWhitespace() {
ConceptSource conceptSource = new ConceptSource();
conceptSource.setName("New name");
conceptSource.setDescription("Some description");
conceptSource.setHl7Code(null);
Errors errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertFalse(errors.hasFieldErrors("Hl7Code"));
conceptSource.setHl7Code("");
errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertFalse(errors.hasFieldErrors("Hl7Code"));
conceptSource.setHl7Code(" ");
errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertFalse(errors.hasFieldErrors("Hl7Code"));
}
Aggregations