use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfTheCodeIsNull.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheCodeIsNull() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setName("name");
term.setConceptSource(Context.getConceptService().getConceptSource(1));
Errors errors = new BindException(term, "term");
new ConceptReferenceTermValidator().validate(term, errors);
Assert.assertEquals(true, errors.hasFieldErrors("code"));
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfATermIsMappedToItself.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfATermIsMappedToItself() {
ConceptReferenceTerm term = Context.getConceptService().getConceptReferenceTerm(1);
Set<ConceptReferenceTermMap> maps = term.getConceptReferenceTermMaps();
ConceptReferenceTermMap invalidMap = maps.iterator().next();
invalidMap.setTermB(term);
term.setConceptReferenceTermMaps(maps);
Errors errors = new BindException(term, "term");
new ConceptReferenceTermValidator().validate(term, errors);
Assert.assertEquals(true, errors.hasFieldErrors("conceptReferenceTermMaps[0].termB"));
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfTheConceptReferenceTermCodeIsADuplicateInItsConceptSource.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheConceptReferenceTermCodeIsADuplicateInItsConceptSource() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setName("name");
term.setCode("WGT234");
term.setConceptSource(Context.getConceptService().getConceptSource(1));
Errors errors = new BindException(term, "term");
new ConceptReferenceTermValidator().validate(term, errors);
Assert.assertEquals(true, errors.hasFieldErrors("code"));
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfTheNameIsAWhiteSpaceCharacter.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test
@Ignore
public // we might need these back when the constraint is put back
void validate_shouldFailIfTheNameIsAWhiteSpaceCharacter() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setName(" ");
term.setCode("code");
term.setConceptSource(Context.getConceptService().getConceptSource(1));
Errors errors = new BindException(term, "term");
new ConceptReferenceTermValidator().validate(term, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfTheConceptReferenceTermObjectIsNull.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test(expected = IllegalArgumentException.class)
public void validate_shouldFailIfTheConceptReferenceTermObjectIsNull() {
Errors errors = new BindException(new ConceptReferenceTerm(), "term");
new ConceptReferenceTermValidator().validate(null, errors);
}
Aggregations