Search in sources :

Example 11 with Program

use of org.openmrs.Program in project openmrs-core by openmrs.

the class SerializedObjectDAOTest method saveObject_shouldSetAuditableFieldsBeforeSerializing.

@Test
public void saveObject_shouldSetAuditableFieldsBeforeSerializing() {
    Program data = new Program();
    data.setName("NewProgram");
    data.setDescription("This is to test saving a Program");
    data = dao.saveObject(data);
    Assert.assertNotNull(data.getId());
    Program newData = dao.getObject(Program.class, data.getId());
    assertEquals("NewProgram", newData.getName());
    assertNotNull(newData.getCreator());
    assertNotNull(newData.getDateCreated());
}
Also used : Program(org.openmrs.Program) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with Program

use of org.openmrs.Program in project openmrs-core by openmrs.

the class SerializedObjectDAOTest method saveObject_shouldSaveThePassedObjectIfSupported.

@Test
public void saveObject_shouldSaveThePassedObjectIfSupported() {
    Program data = new Program();
    data.setName("NewProgram");
    data.setDescription("This is to test saving a Program");
    data.setCreator(new User(1));
    data.setDateCreated(new Date());
    data = dao.saveObject(data);
    Assert.assertNotNull(data.getId());
    Program newData = dao.getObject(Program.class, data.getId());
    assertEquals("NewProgram", newData.getName());
}
Also used : Program(org.openmrs.Program) User(org.openmrs.User) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with Program

use of org.openmrs.Program in project openmrs-core by openmrs.

the class SerializedObjectDAOTest method getObject_shouldReturnTheSavedObject.

@Test
public void getObject_shouldReturnTheSavedObject() {
    Program data = dao.getObject(Program.class, 1);
    assertEquals(data.getId().intValue(), 1);
    assertEquals(data.getName(), "TestProgram");
}
Also used : Program(org.openmrs.Program) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with Program

use of org.openmrs.Program in project openmrs-core by openmrs.

the class ProgramWorkflowDAOTest method saveProgram_shouldSaveProgram.

@Test
public void saveProgram_shouldSaveProgram() {
    Program program = createProgram();
    dao.saveProgram(program);
}
Also used : Program(org.openmrs.Program) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with Program

use of org.openmrs.Program in project openmrs-core by openmrs.

the class ProgramWorkflowDAOTest method saveProgram_shouldAlsoSaveOutcomesConcept.

@Test
public void saveProgram_shouldAlsoSaveOutcomesConcept() {
    Concept outcomesConcept = Context.getConceptService().getConcept(3);
    Program program = createProgram();
    program.setOutcomesConcept(outcomesConcept);
    int id = dao.saveProgram(program).getId();
    clearHibernateCache();
    Program savedProgram = dao.getProgram(id);
    Assert.assertEquals(3, savedProgram.getOutcomesConcept().getId().intValue());
}
Also used : Concept(org.openmrs.Concept) Program(org.openmrs.Program) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

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