/** * @see OrderService#getTestSpecimenSources() */ @Test public void getTestSpecimenSources_shouldReturnAListIfGPIsSet() { List<Concept> specimenSourceList = orderService.getTestSpecimenSources(); assertEquals(1, specimenSourceList.size()); assertEquals(22, specimenSourceList.get(0).getConceptId().intValue()); }
/** * @see OrderService#getTestSpecimenSources() */ @Test public void getTestSpecimenSources_shouldReturnAnEmptyListIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_TEST_SPECIMEN_SOURCES_CONCEPT_UUID, "")); assertThat(orderService.getTestSpecimenSources(), is(empty())); }
/** * Checks the form object for any inconsistencies/errors * * @see org.springframework.validation.Validator#validate(Object, * org.springframework.validation.Errors) * @should fail validation if the specimen source is invalid * @should pass validation if the specimen source is valid */ @Override public void validate(Object obj, Errors errors) { super.validate(obj, errors); TestOrder order = (TestOrder) obj; if (order == null) { errors.reject("error.general"); } else { if (order.getSpecimenSource() != null) { List<Concept> specimenSources = Context.getOrderService().getTestSpecimenSources(); if (!specimenSources.contains(order.getSpecimenSource())) { errors.rejectValue("specimenSource", "TestOrder.error.specimenSourceNotAmongAllowedConcepts"); } } } } }
try { ret.put("testSpecimenSources", ConversionUtil.convertToRepresentation(orderService.getTestSpecimenSources(), context.getRepresentation()));