Search in sources :

Example 36 with Program

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);
}
Also used : Concept(org.openmrs.Concept) ProgramWorkflow(org.openmrs.ProgramWorkflow) PatientProgram(org.openmrs.PatientProgram) Program(org.openmrs.Program) ProgramWorkflowState(org.openmrs.ProgramWorkflowState) Test(org.junit.Test)

Example 37 with 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);
}
Also used : ProgramWorkflow(org.openmrs.ProgramWorkflow) PatientProgram(org.openmrs.PatientProgram) Program(org.openmrs.Program) Test(org.junit.Test)

Example 38 with Program

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);
}
Also used : Concept(org.openmrs.Concept) ProgramWorkflow(org.openmrs.ProgramWorkflow) PatientProgram(org.openmrs.PatientProgram) Program(org.openmrs.Program) Test(org.junit.Test)

Example 39 with 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);
}
Also used : PatientProgram(org.openmrs.PatientProgram) Program(org.openmrs.Program) Test(org.junit.Test)

Example 40 with Program

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");
}
Also used : PatientProgram(org.openmrs.PatientProgram) Program(org.openmrs.Program) ArrayList(java.util.ArrayList) ProgramWorkflowDAO(org.openmrs.api.db.ProgramWorkflowDAO) Test(org.junit.Test)

Aggregations

Program (org.openmrs.Program)43 Test (org.junit.Test)35 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)26 PatientProgram (org.openmrs.PatientProgram)22 ProgramWorkflow (org.openmrs.ProgramWorkflow)8 BindException (org.springframework.validation.BindException)8 Errors (org.springframework.validation.Errors)8 Concept (org.openmrs.Concept)7 ArrayList (java.util.ArrayList)6 ProgramWorkflowState (org.openmrs.ProgramWorkflowState)6 Date (java.util.Date)4 Patient (org.openmrs.Patient)4 ProgramWorkflowDAO (org.openmrs.api.db.ProgramWorkflowDAO)2 MissingPropertyException (groovy.lang.MissingPropertyException)1 HashMap (java.util.HashMap)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 ObjectNode (org.codehaus.jackson.node.ObjectNode)1 Criteria (org.hibernate.Criteria)1 DateTime (org.joda.time.DateTime)1 Ignore (org.junit.Ignore)1