Search in sources :

Example 21 with LocationTag

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

the class LocationTagValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.

/**
 * @see LocationTagValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
    LocationTag locationTag = new LocationTag();
    locationTag.setName("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    locationTag.setDescription("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    locationTag.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    Errors errors = new BindException(locationTag, "location");
    new LocationTagValidator().validate(locationTag, errors);
    Assert.assertTrue(errors.hasFieldErrors("name"));
    Assert.assertTrue(errors.hasFieldErrors("description"));
    Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
Also used : LocationTag(org.openmrs.LocationTag) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

LocationTag (org.openmrs.LocationTag)21 Test (org.junit.Test)17 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)16 Location (org.openmrs.Location)8 BindException (org.springframework.validation.BindException)2 Errors (org.springframework.validation.Errors)2 Criteria (org.hibernate.Criteria)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 Patient (org.openmrs.Patient)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 Visit (org.openmrs.Visit)1 APIException (org.openmrs.api.APIException)1 LocationService (org.openmrs.api.LocationService)1 VisitService (org.openmrs.api.VisitService)1 AdtService (org.openmrs.module.emrapi.adt.AdtService)1 LocationDescriptor (org.openmrs.module.metadatadeploy.descriptor.LocationDescriptor)1 PaperRecord (org.openmrs.module.paperrecord.PaperRecord)1 PaperRecordServiceImpl (org.openmrs.module.paperrecord.PaperRecordServiceImpl)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1