use of org.openmrs.Drug in project openmrs-core by openmrs.
the class DrugValidatorTest method validate_shouldPassIfAllFieldsAreCorrect.
/**
* @see DrugValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassIfAllFieldsAreCorrect() {
Drug drug = new Drug();
drug.addDrugReferenceMap(new DrugReferenceMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1)));
Errors errors = new BindException(drug, "drug");
new DrugValidator().validate(drug, errors);
Assert.assertFalse(errors.hasFieldErrors());
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class DrugValidatorTest method validate_shouldFailIfDrugOnDrugReferenceMapIsNull.
/**
* @see DrugValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailIfDrugOnDrugReferenceMapIsNull() {
Drug drug = new Drug();
drug.setDrugReferenceMaps(Collections.singleton(new DrugReferenceMap()));
Errors errors = new BindException(drug, "drug");
new DrugValidator().validate(drug, errors);
Assert.assertTrue(errors.hasFieldErrors("drugReferenceMaps[0].drug"));
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptServiceImplTest method getDrug_shouldReturnTheMatchingDrugObject.
/**
* @see ConceptServiceImpl#getDrug(String)
*/
@Test
public void getDrug_shouldReturnTheMatchingDrugObject() {
String drugName = "ASPIRIN";
String drugUuid = "05ec820a-d297-44e3-be6e-698531d9dd3f";
Drug drug = conceptService.getDrugByUuid(drugUuid);
assertEquals(drug, conceptService.getDrug(drugName));
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptServiceImplTest method unretireDrug_shouldMarkDrugAsNotRetired.
/**
* @see ConcepTServiceImpl#unretireDrug(Drug)
*/
@Test
public void unretireDrug_shouldMarkDrugAsNotRetired() {
String uuidOfDrugToCheck = "7e2323fa-0fa0-461f-9b59-6765997d849e";
Drug drug = conceptService.getDrugByUuid(uuidOfDrugToCheck);
conceptService.unretireDrug(drug);
assertFalse(drug.getRetired());
}
use of org.openmrs.Drug in project openmrs-core by openmrs.
the class ConceptServiceTest method getDrugs_shouldReturnDrugsByDrugConceptId.
/**
* @see ConceptService#getDrugs(String)
*/
@Test
public void getDrugs_shouldReturnDrugsByDrugConceptId() {
Integer conceptId = 792;
Drug drug = Context.getConceptService().getDrug(2);
// assert that given drug has concept with tested id
Assert.assertNotNull(drug.getConcept());
Assert.assertEquals(drug.getConcept().getConceptId(), conceptId);
List<Drug> drugs = Context.getConceptService().getDrugs(String.valueOf(conceptId));
Assert.assertTrue(drugs.contains(drug));
}
Aggregations