Search in sources :

Example 1 with ConceptAttributeType

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

the class ConceptAttributeTypeValidatorTest method setUp.

/**
 * Run this before each unit test in this class. This adds a bit more data to the base data that
 * is done in the "@Before" method in {@link BaseContextSensitiveTest} (which is run right
 * before this method).
 *
 * @throws Exception
 */
@Before
public void setUp() {
    executeDataSet(CONCEPT_ATTRIBUTE_TYPE_XML);
    validator = new ConceptAttributeTypeValidator();
    type = new ConceptAttributeType();
    errors = new BindException(type, "type");
}
Also used : ConceptAttributeType(org.openmrs.ConceptAttributeType) BindException(org.springframework.validation.BindException) Before(org.junit.Before)

Example 2 with ConceptAttributeType

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

the class ConceptServiceTest method hasAnyConceptAttribute_shouldReturnTrueIfAnyConceptAttributeIsPresentForGivenConceptAttributeType.

/**
 * @see ConceptService#hasAnyConceptAttribute(ConceptAttributeType)
 */
@Test
public void hasAnyConceptAttribute_shouldReturnTrueIfAnyConceptAttributeIsPresentForGivenConceptAttributeType() {
    executeDataSet(CONCEPT_ATTRIBUTE_TYPE_XML);
    ConceptService conceptService = Context.getConceptService();
    ConceptAttributeType conceptAttributeType = conceptService.getConceptAttributeType(1);
    Assert.assertTrue(conceptService.hasAnyConceptAttribute(conceptAttributeType));
}
Also used : ConceptAttributeType(org.openmrs.ConceptAttributeType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 3 with ConceptAttributeType

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

the class ConceptServiceTest method retireConceptAttributeType_shouldRetireAConceptAttributeType.

/**
 * @see ConceptService#retireConceptAttributeType(ConceptAttributeType, String)
 */
@Test
public void retireConceptAttributeType_shouldRetireAConceptAttributeType() {
    executeDataSet(CONCEPT_ATTRIBUTE_TYPE_XML);
    ConceptAttributeType vat = Context.getConceptService().getConceptAttributeType(1);
    Assert.assertFalse(vat.getRetired());
    Assert.assertNull(vat.getRetiredBy());
    Assert.assertNull(vat.getDateRetired());
    Assert.assertNull(vat.getRetireReason());
    Context.getConceptService().retireConceptAttributeType(vat, "for testing");
    vat = Context.getConceptService().getConceptAttributeType(1);
    Assert.assertTrue(vat.getRetired());
    Assert.assertNotNull(vat.getRetiredBy());
    Assert.assertNotNull(vat.getDateRetired());
    Assert.assertEquals("for testing", vat.getRetireReason());
}
Also used : ConceptAttributeType(org.openmrs.ConceptAttributeType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 4 with ConceptAttributeType

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

the class HibernateConceptDAOTest method shouldGetConceptAttributeCountForAttributeType.

/**
 * @see HibernateConceptDAO#getConceptAttributeCount(ConceptAttributeType)
 */
@Test
public void shouldGetConceptAttributeCountForAttributeType() {
    executeDataSet(CONCEPT_ATTRIBUTE_TYPE_XML);
    ConceptAttributeType conceptAttributeType = Context.getConceptService().getConceptAttributeType(1);
    Assert.assertEquals(1, dao.getConceptAttributeCount(conceptAttributeType));
    Assert.assertEquals(0, dao.getConceptAttributeCount(null));
}
Also used : ConceptAttributeType(org.openmrs.ConceptAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with ConceptAttributeType

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

the class ConceptServiceTest method saveConceptAttributeType_shouldCreateANewConceptAttributeType.

/**
 * @see ConceptService#saveConceptAttributeType(org.openmrs.ConceptAttributeType)
 */
@Test
public void saveConceptAttributeType_shouldCreateANewConceptAttributeType() {
    executeDataSet(CONCEPT_ATTRIBUTE_TYPE_XML);
    ConceptService conceptService = Context.getConceptService();
    Assert.assertEquals(2, conceptService.getAllConceptAttributeTypes().size());
    ConceptAttributeType conceptAttributeType = new ConceptAttributeType();
    conceptAttributeType.setName("Another one");
    conceptAttributeType.setDatatypeClassname(FreeTextDatatype.class.getName());
    conceptService.saveConceptAttributeType(conceptAttributeType);
    Assert.assertNotNull(conceptAttributeType.getId());
    Assert.assertEquals(3, conceptService.getAllConceptAttributeTypes().size());
}
Also used : FreeTextDatatype(org.openmrs.customdatatype.datatype.FreeTextDatatype) ConceptAttributeType(org.openmrs.ConceptAttributeType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptAttributeType (org.openmrs.ConceptAttributeType)9 Test (org.junit.Test)7 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)7 BindException (org.springframework.validation.BindException)2 Before (org.junit.Before)1 ConceptService (org.openmrs.api.ConceptService)1 FreeTextDatatype (org.openmrs.customdatatype.datatype.FreeTextDatatype)1 Errors (org.springframework.validation.Errors)1