Search in sources :

Example 16 with ConceptName

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

the class ConceptValidatorTest method validate_shouldFailIfThereIsNoNameExplicitlyMarkedAsFullySpecified.

@Test
public void validate_shouldFailIfThereIsNoNameExplicitlyMarkedAsFullySpecified() {
    Concept concept = cd4Count;
    for (ConceptName name : concept.getNames()) {
        name.setConceptNameType(null);
    }
    Errors errors = new BindException(concept, "concept");
    validator.validate(concept, errors);
    assertThat(errors, hasGlobalErrors("Concept.error.no.FullySpecifiedName"));
}
Also used : Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) ConceptName(org.openmrs.ConceptName) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 17 with ConceptName

use of org.openmrs.ConceptName 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 18 with ConceptName

use of org.openmrs.ConceptName 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 19 with ConceptName

use of org.openmrs.ConceptName 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 20 with ConceptName

use of org.openmrs.ConceptName 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)

Aggregations

ConceptName (org.openmrs.ConceptName)100 Test (org.junit.Test)78 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)71 Concept (org.openmrs.Concept)62 ConceptDescription (org.openmrs.ConceptDescription)42 ConceptDatatype (org.openmrs.ConceptDatatype)34 ConceptClass (org.openmrs.ConceptClass)33 Locale (java.util.Locale)32 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)22 ArrayList (java.util.ArrayList)11 Date (java.util.Date)9 Obs (org.openmrs.Obs)9 BindException (org.springframework.validation.BindException)8 ConceptMap (org.openmrs.ConceptMap)7 Errors (org.springframework.validation.Errors)7 LinkedList (java.util.LinkedList)6 List (java.util.List)6 Patient (org.openmrs.Patient)6 Encounter (org.openmrs.Encounter)5 OrderFrequency (org.openmrs.OrderFrequency)5