|
13 | 13 | import static org.junit.Assert.assertFalse; |
14 | 14 | import static org.junit.Assert.assertNotNull; |
15 | 15 | import static org.junit.Assert.assertNull; |
| 16 | +import static org.junit.Assert.assertTrue; |
16 | 17 |
|
17 | 18 | import java.util.Set; |
18 | 19 | import java.util.Vector; |
|
22 | 23 | import org.openmrs.Concept; |
23 | 24 | import org.openmrs.ConceptName; |
24 | 25 | import org.openmrs.PatientProgram; |
| 26 | +import org.openmrs.PatientState; |
25 | 27 | import org.openmrs.ProgramWorkflow; |
26 | 28 | import org.openmrs.ProgramWorkflowState; |
27 | 29 | import org.openmrs.api.context.Context; |
@@ -160,4 +162,22 @@ public void getProgramByName_shouldReturnNullWhenThereIsNoProgramWorkflowForGive |
160 | 162 | assertNull(workflow); |
161 | 163 | } |
162 | 164 |
|
| 165 | + @Test |
| 166 | + @Verifies(value = "last state should be voided", method = "voidLastState") |
| 167 | + public void voidLastState_shouldVoidTheLastState() throws Exception { |
| 168 | + executeDataSet(PROGRAM_NEXT_STATES_XML); |
| 169 | + |
| 170 | + Integer programId = 11; |
| 171 | + Integer workflowId = 501; |
| 172 | + String voidReason = "Remove it"; |
| 173 | + String patientStateUuid = "e2d62091-7b57-11eb-b6f7-0242c0a82003"; |
| 174 | + |
| 175 | + PatientState patientState = Context.getProgramWorkflowService().getPatientStateByUuid(patientStateUuid); |
| 176 | + |
| 177 | + assertFalse(patientState.getVoided()); |
| 178 | + |
| 179 | + dwrProgramWorkflowService.voidLastState(programId, workflowId, voidReason); |
| 180 | + patientState = Context.getProgramWorkflowService().getPatientStateByUuid(patientStateUuid); |
| 181 | + assertTrue(patientState.getVoided()); |
| 182 | + } |
163 | 183 | } |
0 commit comments