use of org.openmrs.Voidable in project openmrs-core by openmrs.
the class BaseUnvoidHandlerTest method handle_shouldNotActOnObjectsWithADifferentDateVoided.
/**
* @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldNotActOnObjectsWithADifferentDateVoided() {
// a time that isn't right now
Date d = new Date(new Date().getTime() - 1000);
UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
Voidable voidable = new Person();
voidable.setVoided(true);
voidable.setDateVoided(d);
handler.handle(voidable, null, new Date(), "SOME REASON");
Assert.assertTrue(voidable.getVoided());
}
use of org.openmrs.Voidable in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldSetTheVoidedBit.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldSetTheVoidedBit() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
voidable.setVoided(false);
handler.handle(voidable, null, null, " ");
Assert.assertTrue(voidable.getVoided());
}
use of org.openmrs.Voidable in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldSetTheVoidReason.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldSetTheVoidReason() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
handler.handle(voidable, null, null, "THE REASON");
Assert.assertEquals("THE REASON", voidable.getVoidReason());
}
use of org.openmrs.Voidable in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldSetVoidedByEvenIfVoidedBitIsSetButVoidedByIsNull.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldSetVoidedByEvenIfVoidedBitIsSetButVoidedByIsNull() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
voidable.setVoided(true);
handler.handle(voidable, null, null, "THE REASON");
Assert.assertEquals("THE REASON", voidable.getVoidReason());
}
use of org.openmrs.Voidable in project openmrs-core by openmrs.
the class BaseVoidHandlerTest method handle_shouldSetVoidedBy.
/**
* @see BaseVoidHandler#handle(Voidable,User,Date,String)
*/
@Test
public void handle_shouldSetVoidedBy() {
VoidHandler<Voidable> handler = new BaseVoidHandler();
Voidable voidable = new Person();
handler.handle(voidable, new User(2), null, " ");
Assert.assertEquals(2, voidable.getVoidedBy().getId().intValue());
}
Aggregations