use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldFailIfAnyNameIsANullValue.
@Test
public void validate_shouldFailIfAnyNameIsANullValue() {
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass(1));
concept.setDatatype(new ConceptDatatype(1));
concept.addName(new ConceptName("name", Context.getLocale()));
concept.addName(new ConceptName(null, Context.getLocale()));
validator.validate(concept, errors);
assertThat(errors, hasGlobalErrors("Concept.name.empty"));
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldFailIfAnyNameIsAnEmptyString.
@Test
public void validate_shouldFailIfAnyNameIsAnEmptyString() {
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass(1));
concept.setDatatype(new ConceptDatatype(1));
concept.addName(new ConceptName("name", Context.getLocale()));
concept.addName(new ConceptName("", Context.getLocale()));
validator.validate(concept, errors);
assertThat(errors, hasGlobalErrors("Concept.name.empty"));
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
concept.addName(new ConceptName("CD4", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setVersion("version");
concept.setRetireReason("retireReason");
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_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt.
@Test
public void validate_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt() {
concept.addName(new ConceptName("one name", Context.getLocale()));
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_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept.
@Test
public void validate_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept() {
concept.setConceptClass(new ConceptClass());
concept.setDatatype(new ConceptDatatype());
concept.addName(new ConceptName("my name", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
ConceptMap map1 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
concept.addConceptMapping(map1);
ConceptMap map2 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
concept.addConceptMapping(map2);
validator.validate(concept, errors);
assertThat(errors, hasFieldErrors("conceptMappings[1]"));
}
Aggregations