Specification in order to write the right test?


	public PatientProgram unvoidPatientProgram(PatientProgram patientProgram) {
		Date voidDate = patientProgram.getDateVoided();
		for (PatientState state : patientProgram.getStates()) {
			if (voidDate != null && voidDate.equals(state.getDateVoided())) {
		return Context.getProgramWorkflowService().savePatientProgram(patientProgram); // The savePatientProgram method handles all of the unvoiding defaults

of class org.openmrs.api.impl.ProgramWorkflowServiceImpl empties all the ‘voided’ fields in patientState but does not empty voidedBy, dateVoided and voidReason in patientProgram.

How can I know if that is correct? Is there some kind of specification I could consult in order to write the right test?

Write a test which confirms that those fields are automatically emptied for you.

Doesn’t work for the …ServiceUnitTest class since it just uses mocks.

But yes, in the …ServiceTest class extending SpringContextTests RequiredDataAdvice seems to kick in calling BaseUnvoidHandler which empties the fields and also calls setVoided(false). Very reassuring.:slight_smile:

I like the assurance. :smile: