use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptServiceTest method getDrugByMapping_shouldReturnNullIfNoMatchFound.
/**
* @see ConceptService#getDrugByMapping(String, org.openmrs.ConceptSource, java.util.Collection
*/
@Test
public void getDrugByMapping_shouldReturnNullIfNoMatchFound() {
executeDataSet(GET_DRUG_MAPPINGS);
List<ConceptMapType> conceptMapTypeList = conceptService.getConceptMapTypes(false, true);
Drug drug = conceptService.getDrugByMapping("random code", conceptService.getConceptSource(1), conceptMapTypeList);
assertNull(drug);
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class DrugValidatorTest method validate_shouldInvokeConceptMapTypeValidatorIfConceptMapTypeOnDrugReferenceMapIsNew.
/**
* @see DrugValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldInvokeConceptMapTypeValidatorIfConceptMapTypeOnDrugReferenceMapIsNew() {
Drug drug = new Drug();
drug.addDrugReferenceMap(new DrugReferenceMap(conceptService.getConceptReferenceTerm(1), new ConceptMapType()));
Errors errors = new BindException(drug, "drug");
new DrugValidator().validate(drug, errors);
// concept map type validator should have been called which should reject a null name
Assert.assertTrue(errors.hasFieldErrors("drugReferenceMaps[0].conceptMapType.name"));
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptMapTypeValidatorTest method validate_shouldFailIfTheNameIsNull.
/**
* @see ConceptMapTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheNameIsNull() {
ConceptMapType mapType = new ConceptMapType();
Errors errors = new BindException(mapType, "mapType");
new ConceptMapTypeValidator().validate(mapType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptMapTypeValidatorTest method validate_shouldPassIfTheNameIsUniqueAmongstAllConceptMapTypeNames.
/**
* @see ConceptMapTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassIfTheNameIsUniqueAmongstAllConceptMapTypeNames() {
ConceptMapType mapType = new ConceptMapType();
mapType.setName("unique-name");
Errors errors = new BindException(mapType, "mapType");
new ConceptMapTypeValidator().validate(mapType, errors);
Assert.assertEquals(false, errors.hasErrors());
}
use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.
the class ConceptMapTypeValidatorTest method validate_shouldFailIfTheNameIsAWhiteSpaceCharacter.
/**
* @see ConceptMapTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheNameIsAWhiteSpaceCharacter() {
ConceptMapType mapType = new ConceptMapType();
mapType.setName(" ");
Errors errors = new BindException(mapType, "mapType");
new ConceptMapTypeValidator().validate(mapType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
Aggregations