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"));
}
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"));
}
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"));
}
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());
}
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"));
}
Aggregations