use of org.openmrs.Program in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method saveProgram_shouldFailIfProgramWorkFlowStateConceptIsNull.
@Test
public void saveProgram_shouldFailIfProgramWorkFlowStateConceptIsNull() {
exception.expect(APIException.class);
exception.expectMessage("ProgramWorkflowState concept, initial, terminal are required");
Program program = new Program();
program.setName("TEST PROGRAM");
program.setDescription("TEST PROGRAM DESCRIPTION");
program.setConcept(new Concept(1));
ProgramWorkflow workflow = new ProgramWorkflow();
workflow.setConcept(new Concept(2));
ProgramWorkflowState state1 = new ProgramWorkflowState();
state1.setInitial(true);
state1.setTerminal(false);
workflow.addState(state1);
program.addWorkflow(workflow);
pws.saveProgram(program);
}
use of org.openmrs.Program in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method purgeProgram_shouldFailGivenNonEmptyWorkFlowsAndTrueCascade.
@Test
public void purgeProgram_shouldFailGivenNonEmptyWorkFlowsAndTrueCascade() {
exception.expect(APIException.class);
exception.expectMessage("Cascade purging of Programs is not implemented yet");
Program program = new Program(1);
ProgramWorkflow workflow = new ProgramWorkflow(1);
program.addWorkflow(workflow);
pws.purgeProgram(program, true);
}
use of org.openmrs.Program in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method saveProgram_shouldFailIfProgramWorkFlowConceptIsNull.
@Test
public void saveProgram_shouldFailIfProgramWorkFlowConceptIsNull() {
exception.expect(APIException.class);
exception.expectMessage("ProgramWorkflow concept is required");
Program program = new Program();
program.setName("TEST PROGRAM");
program.setDescription("TEST PROGRAM DESCRIPTION");
program.setConcept(new Concept(1));
program.addWorkflow(new ProgramWorkflow());
pws.saveProgram(program);
}
use of org.openmrs.Program in project openmrs-core by openmrs.
the class ProgramWorkflowServiceUnitTest method saveProgram_shouldFailIfProgramConceptIsNull.
@Test
public void saveProgram_shouldFailIfProgramConceptIsNull() {
exception.expect(APIException.class);
exception.expectMessage("Program concept is required");
Program program1 = new Program(1);
pws.saveProgram(program1);
}
use of org.openmrs.Program 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