Search in sources :

Example 51 with Errors

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);
}
Also used : Errors(org.springframework.validation.Errors) ConceptNameTag(org.openmrs.ConceptNameTag) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 52 with 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"));
}
Also used : Errors(org.springframework.validation.Errors) ConceptNameTag(org.openmrs.ConceptNameTag) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 53 with Errors

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());
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptSource(org.openmrs.ConceptSource) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 54 with Errors

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());
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptSource(org.openmrs.ConceptSource) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 55 with Errors

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"));
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptSource(org.openmrs.ConceptSource) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Errors (org.springframework.validation.Errors)468 BindException (org.springframework.validation.BindException)387 Test (org.junit.Test)376 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)356 OrderUtilTest (org.openmrs.order.OrderUtilTest)58 DrugOrder (org.openmrs.DrugOrder)56 Date (java.util.Date)53 Test (org.junit.jupiter.api.Test)36 Patient (org.openmrs.Patient)36 TestBean (org.springframework.beans.testfixture.beans.TestBean)33 Calendar (java.util.Calendar)28 Concept (org.openmrs.Concept)25 TestOrder (org.openmrs.TestOrder)23 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)23 OrderType (org.openmrs.OrderType)22 Encounter (org.openmrs.Encounter)21 Obs (org.openmrs.Obs)20 Order (org.openmrs.Order)20 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)19 PageContext (jakarta.servlet.jsp.PageContext)17