Search in sources :

Example 1 with Voidable

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

the class BaseUnvoidHandlerTest method handle_shouldUnsetTheVoidedBit.

/**
 * @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheVoidedBit() {
    UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(true);
    handler.handle(voidable, null, null, null);
    Assert.assertFalse(voidable.getVoided());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 2 with Voidable

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

the class BaseUnvoidHandlerTest method handle_shouldUnsetTheVoider.

/**
 * @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheVoider() {
    UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(true);
    voidable.setVoidedBy(new User(1));
    handler.handle(voidable, null, null, null);
    Assert.assertNull(voidable.getVoidedBy());
}
Also used : User(org.openmrs.User) Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 3 with Voidable

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

the class BaseUnvoidHandlerTest method handle_shouldUnsetTheDateVoided.

/**
 * @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheDateVoided() {
    UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(true);
    voidable.setDateVoided(new Date());
    handler.handle(voidable, null, null, null);
    Assert.assertNull(voidable.getDateVoided());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Voidable

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

the class BaseUnvoidHandlerTest method handle_shouldOnlyActOnAlreadyVoidedObjects.

/**
 * @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldOnlyActOnAlreadyVoidedObjects() {
    UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(false);
    handler.handle(voidable, null, null, "SOME REASON");
    Assert.assertNull(voidable.getVoidReason());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 5 with Voidable

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

the class BaseUnvoidHandlerTest method handle_shouldUnsetTheVoidReason.

/**
 * @see BaseUnvoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheVoidReason() {
    UnvoidHandler<Voidable> handler = new BaseUnvoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(true);
    voidable.setVoidReason("SOME REASON");
    handler.handle(voidable, null, null, null);
    Assert.assertNull(voidable.getVoidReason());
}
Also used : 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