Search in sources :

Example 6 with ConceptDescription

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

the class ConceptValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.

@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
    concept.addName(new ConceptName("CD4", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    concept.setVersion("too long text too long text too long text too long text");
    concept.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    validator.validate(concept, errors);
    assertThat(errors, hasFieldErrors("version", "error.exceededMaxLengthOfField"));
    assertThat(errors, hasFieldErrors("retireReason", "error.exceededMaxLengthOfField"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with ConceptDescription

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

the class ConceptValidatorTest method validate_shouldFailIfTheConceptClassIsNull.

@Test
public void validate_shouldFailIfTheConceptClassIsNull() {
    concept.addName(new ConceptName("some name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setDatatype(new ConceptDatatype(1));
    validator.validate(concept, errors);
    assertThat(errors, hasFieldErrors("conceptClass", "Concept.conceptClass.empty"));
}
Also used : ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with ConceptDescription

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

the class ConceptValidatorTest method validate_shouldPassIfFullySpecifiedNameIsTheSameAsShortName.

@Test
public void validate_shouldPassIfFullySpecifiedNameIsTheSameAsShortName() {
    ConceptName conceptFullySpecifiedName = new ConceptName("YES", new Locale("pl"));
    conceptFullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
    ConceptName conceptShortName = new ConceptName("yes", new Locale("pl"));
    conceptShortName.setConceptNameType(ConceptNameType.SHORT);
    concept.addName(conceptFullySpecifiedName);
    concept.addName(conceptShortName);
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Locale(java.util.Locale) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with ConceptDescription

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

the class ConceptValidatorTest method validate_shouldFailIfTheConceptDatatypeIsNull.

@Test
public void validate_shouldFailIfTheConceptDatatypeIsNull() {
    concept.addName(new ConceptName("some name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass(1));
    validator.validate(concept, errors);
    assertThat(errors, hasFieldErrors("datatype", "Concept.datatype.empty"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 10 with ConceptDescription

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

the class ConceptValidatorTest method validate_shouldFailIfAnyNamesInTheSameLocaleForThisConceptAreSimilar.

@Test
public void validate_shouldFailIfAnyNamesInTheSameLocaleForThisConceptAreSimilar() {
    concept.addName(new ConceptName("same name", Context.getLocale()));
    concept.addName(new ConceptName("same name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    expectedException.expect(DuplicateConceptNameException.class);
    expectedException.expectMessage("'same name' is a duplicate name in locale '" + Context.getLocale() + "'");
    validator.validate(concept, errors);
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Test (org.junit.Test)48 ConceptDescription (org.openmrs.ConceptDescription)48 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)47 ConceptName (org.openmrs.ConceptName)42 Concept (org.openmrs.Concept)33 ConceptDatatype (org.openmrs.ConceptDatatype)32 ConceptClass (org.openmrs.ConceptClass)31 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)20 Locale (java.util.Locale)14 OrderFrequency (org.openmrs.OrderFrequency)5 ConceptMap (org.openmrs.ConceptMap)4 ConceptNumeric (org.openmrs.ConceptNumeric)4 ConceptComplex (org.openmrs.ConceptComplex)3 ConceptService (org.openmrs.api.ConceptService)3 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 ConceptProposal (org.openmrs.ConceptProposal)2 OrderUtilTest (org.openmrs.order.OrderUtilTest)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1