use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldNotFailIfTheConceptNameTagIsTheSame.
@Test
public void validate_shouldNotFailIfTheConceptNameTagIsTheSame() {
String objectName = "duplicate concept name tag";
ConceptNameTag cnt = Context.getConceptService().getConceptNameTag(1);
Errors errors = new BindException(cnt, objectName);
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertFalse(errors.hasErrors());
Assert.assertEquals(false, errors.hasFieldErrors("tag"));
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues.
/**
* @see ConceptNameTagValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
ConceptNameTag cnt = new ConceptNameTag();
cnt.setTag("tag");
Errors errors = new BindException(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see ConceptNameTagValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
ConceptNameTag cnt = new ConceptNameTag();
cnt.setTag("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");
cnt.setVoidReason("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(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertEquals(true, errors.hasFieldErrors("tag"));
Assert.assertEquals(true, errors.hasFieldErrors("voidReason"));
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see ConceptNameTagValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
ConceptNameTag cnt = new ConceptNameTag();
cnt.setTag("tag");
cnt.setVoidReason("VoidReason");
Errors errors = new BindException(cnt, "cnt");
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameTagValidatorTest method validate_shouldFailIfTheConceptNameTagIsADuplicate.
/**
* @see ConceptNameTagValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheConceptNameTagIsADuplicate() {
String objectName = "duplicate concept name tag";
ConceptNameTag existing = Context.getConceptService().getConceptNameTag(1);
ConceptNameTag cnt = new ConceptNameTag();
cnt.setTag(existing.getTag());
Errors errors = new BindException(cnt, objectName);
new ConceptNameTagValidator().validate(cnt, errors);
Assert.assertTrue(errors.hasErrors());
Assert.assertEquals(true, errors.hasFieldErrors("tag"));
}
Aggregations