use of org.openmrs.api.db.ProgramWorkflowDAO in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method getProgramByName_shouldReturnNullWhenThereIsNoProgramForGivenName.
@Test
public void getProgramByName_shouldReturnNullWhenThereIsNoProgramForGivenName() {
ProgramWorkflowDAO mockDao = Mockito.mock(ProgramWorkflowDAO.class);
List<Program> noProgramWithGivenName = new ArrayList<>();
Mockito.stub(mockDao.getProgramsByName("A name", false)).toReturn(noProgramWithGivenName);
Mockito.stub(mockDao.getProgramsByName("A name", true)).toReturn(noProgramWithGivenName);
pws.setProgramWorkflowDAO(mockDao);
Assert.assertNull(pws.getProgramByName("A name"));
}
use of org.openmrs.api.db.ProgramWorkflowDAO in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method getProgramByName_shouldCallDaoGetProgramsByName.
@Test
public void getProgramByName_shouldCallDaoGetProgramsByName() {
ProgramWorkflowDAO mockDao = Mockito.mock(ProgramWorkflowDAO.class);
pws.setProgramWorkflowDAO(mockDao);
pws.getProgramByName("A name");
Mockito.verify(mockDao).getProgramsByName("A name", false);
Mockito.verify(mockDao).getProgramsByName("A name", true);
}
use of org.openmrs.api.db.ProgramWorkflowDAO in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method getProgramByName_shouldFailWhenTwoProgramsFoundWithSameName.
@Test(expected = org.openmrs.api.ProgramNameDuplicatedException.class)
public void getProgramByName_shouldFailWhenTwoProgramsFoundWithSameName() {
ProgramWorkflowDAO mockDao = Mockito.mock(ProgramWorkflowDAO.class);
List<Program> programsWithGivenName = new ArrayList<>();
Program program1 = new Program("A name");
Program program2 = new Program("A name");
programsWithGivenName.add(program1);
programsWithGivenName.add(program2);
Mockito.stub(mockDao.getProgramsByName("A name", false)).toReturn(programsWithGivenName);
Mockito.stub(mockDao.getProgramsByName("A name", true)).toReturn(programsWithGivenName);
pws.setProgramWorkflowDAO(mockDao);
pws.getProgramByName("A name");
}
Aggregations