use of org.openmrs.ConceptDescription in project openmrs-core by openmrs.
the class OrderFrequencyValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see OrderFrequencyValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptService cs = Context.getConceptService();
Concept concept = new Concept();
ConceptName cn = new ConceptName("new name", Context.getLocale());
concept.setDatatype(cs.getConceptDatatype(1));
concept.setConceptClass(cs.getConceptClass(19));
concept.addName(cn);
concept.addDescription(new ConceptDescription("some description", null));
cs.saveConcept(concept);
OrderFrequency orderFrequency = new OrderFrequency();
orderFrequency.setConcept(concept);
orderFrequency.setRetireReason("retireReason");
Errors errors = new BindException(orderFrequency, "orderFrequency");
new OrderFrequencyValidator().validate(orderFrequency, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptDescription 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.ConceptDescription 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.ConceptDescription 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.ConceptDescription 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());
}
Aggregations