Search in sources :

Example 11 with ConceptMapType

use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.

the class ConceptMapTypeValidatorTest method validate_shouldFailIfTheConceptMapTypeObjectIsNull.

/**
 * @see ConceptMapTypeValidator#validate(Object,Errors)
 */
@Test(expected = IllegalArgumentException.class)
public void validate_shouldFailIfTheConceptMapTypeObjectIsNull() {
    Errors errors = new BindException(new ConceptMapType(), "mapType");
    new ConceptMapTypeValidator().validate(null, errors);
}
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 12 with ConceptMapType

use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.

the class ConceptServiceImplTest method purgeConceptMapType_shouldDeleteTheSpecifiedConceptMapTypeFromTheDatabase.

/**
 * @see ConceptServiceImpl#purgeConceptMapType(ConceptMapType)
 */
@Test
public void purgeConceptMapType_shouldDeleteTheSpecifiedConceptMapTypeFromTheDatabase() {
    Integer conceptMapTypeId = 8;
    ConceptMapType mapType = conceptService.getConceptMapType(conceptMapTypeId);
    assertNotNull(mapType);
    conceptService.purgeConceptMapType(mapType);
    assertNull(conceptService.getConceptMapType(conceptMapTypeId));
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with ConceptMapType

use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.

the class ConceptServiceTest method getDefaultConceptMapType_shouldReturnTypeAsSetInGp.

/**
 * @see ConceptService#getDefaultConceptMapType()
 */
@Test
public void getDefaultConceptMapType_shouldReturnTypeAsSetInGp() {
    final String testName = "is a";
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("concept.defaultConceptMapType", testName));
    ConceptMapType conceptMapType = conceptService.getDefaultConceptMapType();
    Assert.assertNotNull(conceptMapType);
    Assert.assertEquals(testName, conceptMapType.getName());
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 14 with ConceptMapType

use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.

the class ConceptServiceTest method retireConceptMapType_shouldRetireTheSpecifiedConceptMapTypeWithTheGivenRetireReason.

/**
 * @see ConceptService#retireConceptMapType(ConceptMapType,String)
 */
@Test
public void retireConceptMapType_shouldRetireTheSpecifiedConceptMapTypeWithTheGivenRetireReason() {
    ConceptMapType mapType = Context.getConceptService().getConceptMapType(1);
    Assert.assertFalse(mapType.getRetired());
    Assert.assertNull(mapType.getRetiredBy());
    Assert.assertNull(mapType.getDateRetired());
    Assert.assertNull(mapType.getRetireReason());
    ConceptMapType retiredMapType = Context.getConceptService().retireConceptMapType(mapType, "test retire reason");
    Assert.assertTrue(retiredMapType.getRetired());
    Assert.assertEquals(retiredMapType.getRetireReason(), "test retire reason");
    Assert.assertNotNull(retiredMapType.getRetiredBy());
    Assert.assertNotNull(retiredMapType.getDateRetired());
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 15 with ConceptMapType

use of org.openmrs.ConceptMapType in project openmrs-core by openmrs.

the class ConceptServiceTest method saveConceptMapType_shouldAddTheSpecifiedConceptMapTypeToTheDatabaseAndAssignToItAnId.

/**
 * @see ConceptService#saveConceptMapType(ConceptMapType)
 */
@Test
public void saveConceptMapType_shouldAddTheSpecifiedConceptMapTypeToTheDatabaseAndAssignToItAnId() {
    ConceptMapType mapType = new ConceptMapType();
    mapType.setName("test type");
    mapType = Context.getConceptService().saveConceptMapType(mapType);
    Assert.assertNotNull(mapType.getId());
    Assert.assertNotNull(Context.getConceptService().getConceptMapTypeByName("test type"));
}
Also used : ConceptMapType(org.openmrs.ConceptMapType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

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