use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptServiceImplTest method getDrugs_shouldReturnListOfMatchingDrugs.
/**
* @see ConceptServiceImpl#getDrugs(String, Concept, boolean, boolean, boolean, Integer,
* Integer)
*/
@Test
public void getDrugs_shouldReturnListOfMatchingDrugs() {
String drugName = "ASPIRIN";
String drugUuid = "05ec820a-d297-44e3-be6e-698531d9dd3f";
Concept concept = conceptService.getConceptByUuid(drugUuid);
List<Drug> drugs = conceptService.getDrugs(drugName, concept, true, true, true, 0, 100);
assertTrue(drugs.contains(conceptService.getDrug(drugName)));
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptServiceImplTest method unretireDrug_shouldNotChangeAttributesOfDrugThatIsAlreadyNotRetired.
/**
* @see ConcepTServiceImpl#unretireDrug(Drug)
*/
@Test
public void unretireDrug_shouldNotChangeAttributesOfDrugThatIsAlreadyNotRetired() {
String uuidOfDrugToCheck = "3cfcf118-931c-46f7-8ff6-7b876f0d4202";
Drug drug = conceptService.getDrugByUuid(uuidOfDrugToCheck);
assertFalse(drug.getRetired());
conceptService.unretireDrug(drug);
assertFalse(drug.getRetired());
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptDrugValidatorTest method validate_shouldFailIfAConceptIsNotSpecified.
/**
* @see ConceptDrugValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfAConceptIsNotSpecified() {
Drug drug = new Drug();
Errors errors = new BindException(drug, "drug");
new ConceptDrugValidator().validate(drug, errors);
Assert.assertTrue(errors.hasErrors());
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class DrugValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see DrugValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
Drug drug = new Drug();
drug.addDrugReferenceMap(new DrugReferenceMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1)));
drug.setName("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
drug.setStrength("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
drug.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
Errors errors = new BindException(drug, "drug");
new DrugValidator().validate(drug, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
Assert.assertTrue(errors.hasFieldErrors("strength"));
Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class DrugValidatorTest method validate_shouldRejectDrugMultipleMappingsToTheSameTerm.
/**
* @see DrugValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldRejectDrugMultipleMappingsToTheSameTerm() {
Drug drug = new Drug();
DrugReferenceMap term1 = new DrugReferenceMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
DrugReferenceMap term2 = new DrugReferenceMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(2));
drug.addDrugReferenceMap(term1);
drug.addDrugReferenceMap(term2);
Assert.assertEquals(2, drug.getDrugReferenceMaps().size());
Errors errors = new BindException(drug, "drug");
new DrugValidator().validate(drug, errors);
Assert.assertTrue(errors.hasFieldErrors("drugReferenceMaps[1].conceptReferenceTerm"));
}
Aggregations