use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderFrequencyValidatorTest method validate_shouldFailIfOrderFrequencyIsNull.
/**
* @see OrderFrequencyValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfOrderFrequencyIsNull() {
Errors errors = new BindException(new OrderFrequency(), "orderFrequency");
new OrderFrequencyValidator().validate(null, errors);
Assert.assertTrue(errors.hasErrors());
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderFrequencyValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see OrderFrequencyValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptService cs = Context.getConceptService();
Concept concept = new Concept();
ConceptName cn = new ConceptName("new name", Context.getLocale());
concept.setDatatype(cs.getConceptDatatype(1));
concept.setConceptClass(cs.getConceptClass(19));
concept.addName(cn);
concept.addDescription(new ConceptDescription("some description", null));
cs.saveConcept(concept);
OrderFrequency orderFrequency = new OrderFrequency();
orderFrequency.setConcept(concept);
orderFrequency.setRetireReason("retireReason");
Errors errors = new BindException(orderFrequency, "orderFrequency");
new OrderFrequencyValidator().validate(orderFrequency, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderFrequencyValidatorTest method validate_shouldFailIfTheConceptIsNotOfClassFrequency.
/**
* @see OrderFrequencyValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheConceptIsNotOfClassFrequency() {
OrderFrequency orderFrequency = new OrderFrequency();
orderFrequency.setConcept(Context.getConceptService().getConcept(88));
Errors errors = new BindException(orderFrequency, "orderFrequency");
new OrderFrequencyValidator().validate(orderFrequency, errors);
Assert.assertTrue(errors.hasFieldErrors("concept"));
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderFrequencyValidatorTest method validate_shouldPassForAValidExistingOrderFrequency.
/**
* @see OrderFrequencyValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassForAValidExistingOrderFrequency() {
OrderFrequency orderFrequency = Context.getOrderService().getOrderFrequency(1);
assertNotNull(orderFrequency);
Errors errors = new BindException(orderFrequency, "orderFrequency");
new OrderFrequencyValidator().validate(orderFrequency, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderServiceTest method retireOrderFrequency_shouldRetireGivenOrderFrequency.
@Test
public void retireOrderFrequency_shouldRetireGivenOrderFrequency() {
OrderFrequency orderFrequency = orderService.getOrderFrequency(1);
assertNotNull(orderFrequency);
Assert.assertFalse(orderFrequency.getRetired());
Assert.assertNull(orderFrequency.getRetireReason());
Assert.assertNull(orderFrequency.getDateRetired());
orderService.retireOrderFrequency(orderFrequency, "retire reason");
orderFrequency = orderService.getOrderFrequency(1);
assertNotNull(orderFrequency);
assertTrue(orderFrequency.getRetired());
assertEquals("retire reason", orderFrequency.getRetireReason());
assertNotNull(orderFrequency.getDateRetired());
// Should not change the number of order frequencies.
assertEquals(3, orderService.getOrderFrequencies(true).size());
}
Aggregations