use of org.openmrs.ConceptDatatype 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.ConceptDatatype 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.ConceptDatatype 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.ConceptDatatype 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);
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class ConceptDatatypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see ConceptDatatypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptDatatype cd = new ConceptDatatype();
cd.setName("name");
cd.setDescription("some text");
cd.setHl7Abbreviation("hl7");
cd.setRetireReason("retireReason");
Errors errors = new BindException(cd, "cd");
new ConceptDatatypeValidator().validate(cd, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations