Search in sources :

Example 11 with Voidable

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());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Date(java.util.Date) Test(org.junit.Test)

Example 12 with Voidable

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());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 13 with Voidable

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());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 14 with Voidable

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());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 15 with Voidable

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());
}
Also used : User(org.openmrs.User) Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Aggregations

Voidable (org.openmrs.Voidable)16 Test (org.junit.Test)14 Person (org.openmrs.Person)14 Date (java.util.Date)5 User (org.openmrs.User)5 OpenmrsObject (org.openmrs.OpenmrsObject)2 PropertyDescriptor (java.beans.PropertyDescriptor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 Obs (org.openmrs.Obs)1 Retireable (org.openmrs.Retireable)1 AllowEmptyStrings (org.openmrs.annotation.AllowEmptyStrings)1 AllowLeadingOrTrailingWhitespace (org.openmrs.annotation.AllowLeadingOrTrailingWhitespace)1 APIException (org.openmrs.api.APIException)1 ConceptNameSaveHandler (org.openmrs.api.handler.ConceptNameSaveHandler)1 SaveHandler (org.openmrs.api.handler.SaveHandler)1 UnretireHandler (org.openmrs.api.handler.UnretireHandler)1 UnvoidHandler (org.openmrs.api.handler.UnvoidHandler)1 Reflect (org.openmrs.util.Reflect)1