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());
}
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));
}
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());
}
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());
}
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());
}
Aggregations