use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptClassValidatorTest method validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace.
@Test
public void validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace() {
ConceptClass cc = new ConceptClass();
cc.setName("name");
cc.setDescription(null);
Errors errors = new BindException(cc, "cc");
new ConceptClassValidator().validate(cc, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
cc.setDescription("");
errors = new BindException(cc, "cc");
new ConceptClassValidator().validate(cc, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
cc.setDescription(" ");
errors = new BindException(cc, "cc");
new ConceptClassValidator().validate(cc, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptClassValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see ConceptClassValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptClass cc = new ConceptClass();
cc.setName("name");
cc.setDescription("some text");
cc.setRetireReason("some text");
Errors errors = new BindException(cc, "cc");
new ConceptClassValidator().validate(cc, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldPassIfAllFieldsAreCorrectForANewOrderType.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassIfAllFieldsAreCorrectForANewOrderType() {
OrderType orderType = new OrderType();
orderType.setName("unique name");
orderType.setJavaClassName("org.openmrs.TestDrugOrder");
Collection<ConceptClass> col = new HashSet<>();
col.add(Context.getConceptService().getConceptClass(2));
orderType.setConceptClasses(col);
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
OrderType orderType = new OrderType();
orderType.setName("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");
orderType.setJavaClassName("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");
Collection<ConceptClass> col = new HashSet<>();
col.add(Context.getConceptService().getConceptClass(2));
orderType.setConceptClasses(col);
orderType.setDescription("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 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 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 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");
orderType.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");
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
Assert.assertEquals(true, errors.hasFieldErrors("javaClassName"));
Assert.assertEquals(true, errors.hasFieldErrors("description"));
Assert.assertEquals(true, errors.hasFieldErrors("retireReason"));
}
use of org.openmrs.ConceptClass in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassIfTheConceptHasASynonymThatIsAlsoAShortName.
@Test
public void validate_shouldPassIfTheConceptHasASynonymThatIsAlsoAShortName() {
concept.addName(new ConceptName("CD4", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass());
concept.setDatatype(new ConceptDatatype());
// Add the short name. Because the short name is not counted as a Synonym.
// ConceptValidator will not record any errors.
ConceptName name = new ConceptName("CD4", Context.getLocale());
name.setConceptNameType(ConceptNameType.SHORT);
concept.addName(name);
validator.validate(concept, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations