use of org.openmrs.Person in project openmrs-core by openmrs.
the class AuditableInterceptorTest method onSave_shouldPopulateCreatorForPersonIfNull.
@Test
public void onSave_shouldPopulateCreatorForPersonIfNull() {
Person person = createPersonWithNameAndAddress();
Context.getPersonService().savePerson(person);
Assert.assertNotNull(person.getCreator());
Assert.assertNotNull(person.getPersonCreator());
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldSetDateVoided.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldSetDateVoided() {
Date d = new Date();
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
handler.handle(voidable, null, d, " ");
Assert.assertEquals(d, voidable.getDateVoided());
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldNotSetVoidedByIfNonNull.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldNotSetVoidedByIfNonNull() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
voidable.setVoidedBy(new User(3));
handler.handle(voidable, new User(2), null, " ");
Assert.assertEquals(3, voidable.getVoidedBy().getId().intValue());
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldNotSetDateVoidedIfNonNull.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldNotSetDateVoidedIfNonNull() {
// a time that is not "now"
Date d = new Date(new Date().getTime() - 1000);
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
// make dateVoided non null
voidable.setDateVoided(d);
handler.handle(voidable, null, new Date(), " ");
Assert.assertEquals(d, voidable.getDateVoided());
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldNotSetTheVoidReasonIfAlreadyVoided.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldNotSetTheVoidReasonIfAlreadyVoided() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
voidable.setVoided(true);
voidable.setVoidedBy(new User(1));
handler.handle(voidable, null, null, "THE REASON");
Assert.assertNull(voidable.getVoidReason());
}
Aggregations