use of org.openmrs.Concept in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassIfTheConceptIsBeingUpdatedWithNoNameChange.
@Test
public void validate_shouldPassIfTheConceptIsBeingUpdatedWithNoNameChange() {
Concept conceptToUpdate = cd4Count;
conceptToUpdate.setCreator(Context.getAuthenticatedUser());
Errors errors = new BindException(conceptToUpdate, "concept");
validator.validate(conceptToUpdate, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassIfTheConceptBeingValidatedIsRetiredAndHasADuplicateName.
@Test
public void validate_shouldPassIfTheConceptBeingValidatedIsRetiredAndHasADuplicateName() {
Context.setLocale(new Locale("en", "GB"));
Concept concept = cd4Count;
conceptService.saveConcept(concept);
String duplicateName = concept.getFullySpecifiedName(Context.getLocale()).getName();
Concept anotherConcept = weight;
anotherConcept.setRetired(true);
anotherConcept.getFullySpecifiedName(Context.getLocale()).setName(duplicateName);
Errors errors = new BindException(anotherConcept, "concept");
validator.validate(anotherConcept, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldFailIfCodedConceptContainsItselfAsAnAnswer.
@Test
public void validate_shouldFailIfCodedConceptContainsItselfAsAnAnswer() {
Concept concept = conceptService.getConcept(30);
ConceptAnswer conceptAnswer = new ConceptAnswer(concept);
concept.addAnswer(conceptAnswer);
Errors errors = new BindException(concept, "concept");
validator.validate(concept, errors);
assertThat(errors, hasGlobalErrors("Concept.contains.itself.as.answer"));
}
use of org.openmrs.Concept 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.Concept in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassIfTheConceptWithADuplicateNameIsRetired.
@Test
public void validate_shouldPassIfTheConceptWithADuplicateNameIsRetired() {
Context.setLocale(new Locale("en", "GB"));
Concept concept = cd4Count;
concept.setRetired(true);
conceptService.saveConcept(concept);
String duplicateName = concept.getFullySpecifiedName(Context.getLocale()).getName();
Concept anotherConcept = weight;
anotherConcept.getFullySpecifiedName(Context.getLocale()).setName(duplicateName);
Errors errors = new BindException(anotherConcept, "concept");
validator.validate(anotherConcept, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations