Search in sources :

Example 16 with Drug

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());
}
Also used : Drug(org.openmrs.Drug) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) DrugReferenceMap(org.openmrs.DrugReferenceMap) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 17 with Drug

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"));
}
Also used : Drug(org.openmrs.Drug) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) DrugReferenceMap(org.openmrs.DrugReferenceMap) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 18 with 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));
}
Also used : Drug(org.openmrs.Drug) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 19 with Drug

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());
}
Also used : Drug(org.openmrs.Drug) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 20 with Drug

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));
}
Also used : Drug(org.openmrs.Drug) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

Drug (org.openmrs.Drug)51 Test (org.junit.Test)46 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)41 Concept (org.openmrs.Concept)15 BindException (org.springframework.validation.BindException)15 Errors (org.springframework.validation.Errors)14 DrugReferenceMap (org.openmrs.DrugReferenceMap)9 ConceptMapType (org.openmrs.ConceptMapType)8 DrugOrder (org.openmrs.DrugOrder)7 OrderUtilTest (org.openmrs.order.OrderUtilTest)7 Date (java.util.Date)5 ConceptSource (org.openmrs.ConceptSource)5 ArrayList (java.util.ArrayList)4 Obs (org.openmrs.Obs)3 HashSet (java.util.HashSet)2 ConceptAnswer (org.openmrs.ConceptAnswer)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)2 Encounter (org.openmrs.Encounter)2 Person (org.openmrs.Person)2