use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.
the class PersonServiceTest method savePersonMergeLog_shouldSetDateCreatedIfNull.
/**
* @see PersonService#savePersonMergeLog(PersonMergeLog)
*/
@Test
public void savePersonMergeLog_shouldSetDateCreatedIfNull() throws Exception {
PersonMergeLog personMergeLog = getTestPersonMergeLog();
personMergeLog.setDateCreated(null);
PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog);
Assert.assertNotNull("dateCreated has not been set", persisted.getDateCreated());
}
use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.
the class PersonServiceTest method savePersonMergeLog_shouldRequireLoser.
/**
* @see PersonService#savePersonMergeLog(PersonMergeLog)
*/
@Test(expected = APIException.class)
public void savePersonMergeLog_shouldRequireLoser() throws Exception {
PersonMergeLog personMergeLog = getTestPersonMergeLog();
personMergeLog.setLoser(null);
Context.getPersonService().savePersonMergeLog(personMergeLog);
}
use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.
the class PersonMergeLogValidator method validate.
/**
* Checks the form object for any inconsistencies/errors
*
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
* @should fail validation if personMergeLogData is null
* @should fail validation if winner is null
* @should fail validation if loser is null
* @should pass validation if all fields are correct
* @should pass validation if field lengths are correct
* @should fail validation if field lengths are not correct
*/
@Override
public void validate(Object obj, Errors errors) {
PersonMergeLog personMergeLog = (PersonMergeLog) obj;
if (personMergeLog == null) {
errors.rejectValue("persnMergeLog", "error.general");
} else {
ValidationUtils.rejectIfEmpty(errors, "personMergeLogData", "error.null");
ValidationUtils.rejectIfEmpty(errors, "winner", "error.null");
ValidationUtils.rejectIfEmpty(errors, "loser", "error.null");
ValidateUtil.validateFieldLengths(errors, obj.getClass(), "voidReason");
}
}
use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.
the class PersonMergeLogValidatorTest method validate_shouldPassValidationIfAllFieldsAreCorrect.
/**
* @see PersonMergeLogValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfAllFieldsAreCorrect() {
PersonMergeLog personMergeLog = new PersonMergeLog();
personMergeLog.setWinner(new Person());
personMergeLog.setLoser(new Person());
personMergeLog.setPersonMergeLogData(new PersonMergeLogData());
PersonMergeLogValidator validator = new PersonMergeLogValidator();
Errors errors = new BindException(personMergeLog, "personMergeLog");
validator.validate(personMergeLog, errors);
Assert.assertFalse(errors.hasFieldErrors());
}
use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.
the class PersonMergeLogValidatorTest method validate_shouldFailValidationIfLoserIsNull.
/**
* @see PersonMergeLogValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfLoserIsNull() {
PersonMergeLog personMergeLog = new PersonMergeLog();
personMergeLog.setWinner(new Person());
personMergeLog.setPersonMergeLogData(new PersonMergeLogData());
PersonMergeLogValidator validator = new PersonMergeLogValidator();
Errors errors = new BindException(personMergeLog, "personMergeLog");
validator.validate(personMergeLog, errors);
Assert.assertTrue(errors.hasFieldErrors("loser"));
}
Aggregations