Search in sources :

Example 21 with ConceptMapType

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

Example 22 with ConceptMapType

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

Example 23 with ConceptMapType

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

Example 24 with ConceptMapType

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

Example 25 with ConceptMapType

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

Aggregations

ConceptMapType (org.openmrs.ConceptMapType)34 Test (org.junit.Test)26 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)26 BindException (org.springframework.validation.BindException)10 Errors (org.springframework.validation.Errors)10 Drug (org.openmrs.Drug)8 ConceptSource (org.openmrs.ConceptSource)6 Criteria (org.hibernate.Criteria)3 ArrayList (java.util.ArrayList)2 Concept (org.openmrs.Concept)2 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)2 DrugReferenceMap (org.openmrs.DrugReferenceMap)2 DAOException (org.openmrs.api.db.DAOException)2 ConceptBuilder (org.openmrs.module.metadatadeploy.builder.ConceptBuilder)2 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 FlushMode (org.hibernate.FlushMode)1