Search in sources :

Example 26 with Location

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

the class EncounterServiceTest method saveEncounter_shouldCascadeChangeOfLocationInEncounterToContainedObs.

/**
 * When you save the encounter with a changed location, the location change should be cascaded
 * to all the obs associated with the encounter that had the same location as the encounter.
 *
 * @see EncounterService#saveEncounter(Encounter)
 */
@Test
public void saveEncounter_shouldCascadeChangeOfLocationInEncounterToContainedObs() {
    EncounterService es = Context.getEncounterService();
    Encounter enc = buildEncounter();
    es.saveEncounter(enc);
    // Now add an obs to it
    Obs newObs = new Obs();
    newObs.setConcept(Context.getConceptService().getConcept(1));
    newObs.setValueNumeric(50d);
    Location location = new Location(1);
    newObs.setLocation(location);
    enc.addObs(newObs);
    es.saveEncounter(enc);
    enc.setLocation(location);
    es.saveEncounter(enc);
    assertEquals(enc.getLocation(), newObs.getLocation());
}
Also used : Obs(org.openmrs.Obs) Encounter(org.openmrs.Encounter) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 27 with Location

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

the class RequiredDataAdviceTest method isOpenmrsObjectCollection_shouldReturnTrueIfClassIsOpenmrsObjectList.

/**
 * @see RequiredDataAdvice#isOpenmrsObjectCollection(Class<*>,Object)
 */
@Test
public void isOpenmrsObjectCollection_shouldReturnTrueIfClassIsOpenmrsObjectList() throws Exception {
    List<Location> locations = new ArrayList<>();
    Location location = new Location();
    locations.add(location);
    Assert.assertTrue(RequiredDataAdvice.isOpenmrsObjectCollection(locations));
}
Also used : ArrayList(java.util.ArrayList) Location(org.openmrs.Location) BaseContextMockTest(org.openmrs.test.BaseContextMockTest) Test(org.junit.Test)

Example 28 with Location

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

the class BaseRetireHandlerTest method handle_shouldSetTheRetireReason.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldSetTheRetireReason() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    handler.handle(retireable, null, null, "THE REASON");
    Assert.assertEquals("THE REASON", retireable.getRetireReason());
}
Also used : Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 29 with Location

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

the class BaseRetireHandlerTest method handle_shouldNotSetRetiredByIfNonNull.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldNotSetRetiredByIfNonNull() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    retireable.setRetiredBy(new User(3));
    handler.handle(retireable, new User(2), null, " ");
    Assert.assertEquals(3, retireable.getRetiredBy().getId().intValue());
}
Also used : User(org.openmrs.User) Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 30 with Location

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

the class BaseRetireHandlerTest method handle_shouldSetRetiredByEvenIfRetiredBitIsSetButRetiredByIsNull.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldSetRetiredByEvenIfRetiredBitIsSetButRetiredByIsNull() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    handler.handle(retireable, null, null, "THE REASON");
    Assert.assertEquals("THE REASON", retireable.getRetireReason());
}
Also used : Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Aggregations

Location (org.openmrs.Location)235 Test (org.junit.Test)161 Date (java.util.Date)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 Encounter (org.openmrs.Encounter)38 SimpleObject (org.openmrs.ui.framework.SimpleObject)32 PatientIdentifierType (org.openmrs.PatientIdentifierType)31 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)31 Visit (org.openmrs.Visit)28 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)28 Obs (org.openmrs.Obs)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 PatientIdentifier (org.openmrs.PatientIdentifier)26 Concept (org.openmrs.Concept)19 EncounterType (org.openmrs.EncounterType)18 DateTime (org.joda.time.DateTime)17 ArrayList (java.util.ArrayList)15 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)15 BindException (org.springframework.validation.BindException)15