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