### Question:
PatientProgram extends BaseChangeableOpenmrsData implements Customizable<PatientProgramAttribute> { public void setStates(Set<PatientState> states) { this.states = states; } PatientProgram();  PatientProgram(Integer patientProgramId); PatientProgram copy(); boolean getActive(Date onDate); boolean getActive(); PatientState getPatientState(Integer patientStateId); void transitionToState(ProgramWorkflowState programWorkflowState, Date onDate); void voidLastState(ProgramWorkflow workflow, User voidBy, Date voidDate, String voidReason); PatientState getCurrentState(ProgramWorkflow programWorkflow); Set<PatientState> getCurrentStates(); Set<PatientState> getMostRecentStateInEachWorkflow(); List<PatientState> statesInWorkflow(ProgramWorkflow programWorkflow, boolean includeVoided); @Override String toString(); Concept getOutcome(); void setOutcome(Concept concept); Date getDateCompleted(); void setDateCompleted(Date dateCompleted); Date getDateEnrolled(); void setDateEnrolled(Date dateEnrolled); Patient getPatient(); void setPatient(Patient patient); Integer getPatientProgramId(); void setPatientProgramId(Integer patientProgramId); Program getProgram(); void setProgram(Program program); Set<PatientState> getStates(); void setStates(Set<PatientState> states); @Override Integer getId(); @Override void setId(Integer id); Location getLocation(); void setLocation(Location location); @Override Set<PatientProgramAttribute> getAttributes(); @Override Collection<PatientProgramAttribute> getActiveAttributes(); @Override List<PatientProgramAttribute> getActiveAttributes(CustomValueDescriptor ofType); @Override void addAttribute(PatientProgramAttribute attribute); void setAttributes(Set<PatientProgramAttribute> attributes); void setAttribute(PatientProgramAttribute attribute); static final long serialVersionUID; }### Answer:
@Test public void getSortedStates_shouldReturnAllStatesEvenIfTwoHaveIdenticalStartAndEndDates() throws Exception { Method getSortedStates = PatientProgram.class.getDeclaredMethod("getSortedStates"); getSortedStates.setAccessible(true); Assert.assertNotNull(getSortedStates); Set<PatientState> patientStates = new HashSet<>(); PatientState patientState = new PatientState(); patientState.setStartDate(date); patientState.setEndDate(laterDate); patientState.setVoided(false); patientStates.add(patientState); PatientState patientState2 = new PatientState(); patientState2.setStartDate(date); patientState2.setEndDate(laterDate); patientState2.setVoided(false); patientStates.add(patientState2); PatientState patientState3 = new PatientState(); patientState3.setStartDate(earlierDate); patientState3.setEndDate(date); patientState3.setVoided(false); patientStates.add(patientState3); PatientProgram program = new PatientProgram(); program.setStates(patientStates); List<PatientState> sortedStates = (List<PatientState>) getSortedStates.invoke(program); Assert.assertEquals(3, sortedStates.size()); }