use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldAcceptAVisitIfStartDateTimeIsEqualToStartDateTimeOfAnotherVoidedVisitOfTheSamePatient.
/**
* @see VisitValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldAcceptAVisitIfStartDateTimeIsEqualToStartDateTimeOfAnotherVoidedVisitOfTheSamePatient() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(DATE_TIME_2014_02_05_00_00_00_0);
Visit visit = makeVisit(42);
visit.setStartDatetime(calendar.getTime());
assertTrue(patientHasVoidedVisit(visit.getPatient(), DATE_TIME_2014_02_05_00_00_00_0, DATE_TIME_2014_02_11_00_00_00_0));
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertFalse(errors.hasFieldErrors("startDatetime"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldFailIfStartDatetimeIsNotSet.
/**
* @see VisitValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfStartDatetimeIsNotSet() {
VisitService vs = Context.getVisitService();
Visit visit = new Visit();
visit.setVisitType(vs.getVisitType(1));
visit.setPatient(Context.getPatientService().getPatient(2));
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertTrue(errors.hasFieldErrors("startDatetime"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see VisitValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
Visit visit = makeVisit(42);
visit.setVoidReason("voidReason");
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertEquals(false, errors.hasFieldErrors("voidReason"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldFailIfAnAttributeIsBad.
/**
* @see VisitValidator#validate(Object,Errors)
*/
@Test
// Once we figure it out, this test can be un-Ignored
@Ignore
public void validate_shouldFailIfAnAttributeIsBad() {
Visit visit = visitService.getVisit(1);
visit.addAttribute(makeAttribute(new Date()));
visit.addAttribute(makeAttribute("not a date"));
visit.getActiveAttributes();
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertEquals(true, errors.hasFieldErrors("attributes"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldPassIfAllFieldsAreCorrectForANewOrderType.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassIfAllFieldsAreCorrectForANewOrderType() {
OrderType orderType = new OrderType();
orderType.setName("unique name");
orderType.setJavaClassName("org.openmrs.TestDrugOrder");
Collection<ConceptClass> col = new HashSet<>();
col.add(Context.getConceptService().getConceptClass(2));
orderType.setConceptClasses(col);
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations