use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailIfNameIsADuplicate.
/**
* @see OrderTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfNameIsADuplicate() {
OrderType orderType = new OrderType();
orderType.setName(orderService.getOrderType(1).getName());
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailIfTheOrderTypeObjectIsNull.
/**
* @see OrderTypeValidator#validate(Object,Errors)
*/
@Test(expected = IllegalArgumentException.class)
public void validate_shouldFailIfTheOrderTypeObjectIsNull() {
Errors errors = new BindException(new OrderType(), "orderType");
new OrderTypeValidator().validate(null, errors);
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailIfNameIsWhiteSpace.
/**
* @see OrderTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfNameIsWhiteSpace() {
OrderType orderType = new OrderType();
orderType.setName(" ");
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldBeInvokedWhenAnOrderTypeIsSaved.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldBeInvokedWhenAnOrderTypeIsSaved() {
OrderType orderType = orderService.getOrderType(1);
orderType.setName(null);
expectedException.expect(APIException.class);
String expectedMsg = "'" + orderType + "' failed to validate with reason: name: " + Context.getMessageSourceService().getMessage("error.name");
expectedException.expectMessage(expectedMsg);
orderService.saveOrderType(orderType);
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class HibernateOrderDAO method getOrderType.
/**
* @see org.openmrs.api.db.OrderDAO#getOrderType(Integer)
*/
@Override
public OrderType getOrderType(Integer orderTypeId) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(OrderType.class);
criteria.add(Restrictions.eq("orderTypeId", orderTypeId));
return (OrderType) criteria.uniqueResult();
}
Aggregations