use of org.openmrs.ConceptClass 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.ConceptClass 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.ConceptClass 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.ConceptClass 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);
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassForANewConceptWithAMapCreatedWithDeprecatedConceptMapMethods.
@Test
public void validate_shouldPassForANewConceptWithAMapCreatedWithDeprecatedConceptMapMethods() {
concept.addName(new ConceptName("test name", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass());
concept.setDatatype(new ConceptDatatype());
ConceptMap map = new ConceptMap();
map.getConceptReferenceTerm().setCode("unique code");
map.getConceptReferenceTerm().setConceptSource(conceptService.getConceptSource(1));
concept.addConceptMapping(map);
ValidateUtil.validate(concept);
}
Aggregations