use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
order.setDateActivated(new Date());
order.setAutoExpireDate(cal.getTime());
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
Assert.assertTrue(errors.hasFieldErrors("autoExpireDate"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE.
/**
* @see OrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ROUTINE);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("urgency"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfEncounterIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfEncounterIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setEncounter(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("encounter"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfUrgencyIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfUrgencyIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setUrgency(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfActionIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfActionIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setAction(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("action"));
}
Aggregations