Search in sources :

Example 11 with Retireable

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

the class BaseRetireHandlerTest method handle_shouldNotSetTheRetireReasonIfAlreadyVoided.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldNotSetTheRetireReasonIfAlreadyVoided() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    retireable.setRetiredBy(new User());
    handler.handle(retireable, null, null, "THE REASON");
    Assert.assertNull(retireable.getRetireReason());
}
Also used : User(org.openmrs.User) Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 12 with Retireable

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

the class BaseUnretireHandlerTest method handle_shouldNotActOnRetiredObjectsWithADifferentDateRetired.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldNotActOnRetiredObjectsWithADifferentDateRetired() {
    // a time that isn't right now
    Date d = new Date(new Date().getTime() - 1000);
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    retireable.setDateRetired(d);
    handler.handle(retireable, null, new Date(), "SOME REASON");
    Assert.assertTrue(retireable.getRetired());
}
Also used : Retireable(org.openmrs.Retireable) Date(java.util.Date) Location(org.openmrs.Location) Test(org.junit.Test)

Example 13 with Retireable

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

the class BaseUnretireHandlerTest method handle_shouldUnsetTheRetirer.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheRetirer() {
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    retireable.setRetiredBy(new User(1));
    handler.handle(retireable, null, null, null);
    Assert.assertNull(retireable.getRetiredBy());
}
Also used : User(org.openmrs.User) Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 14 with Retireable

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

the class BaseUnretireHandlerTest method handle_shouldUnsetTheRetireReason.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheRetireReason() {
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    retireable.setRetireReason("SOME REASON");
    handler.handle(retireable, null, null, null);
    Assert.assertNull(retireable.getRetireReason());
}
Also used : Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 15 with Retireable

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

the class BaseUnretireHandlerTest method handle_shouldNotActOnAlreadyUnretiredObjects.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldNotActOnAlreadyUnretiredObjects() {
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(false);
    handler.handle(retireable, null, null, "SOME REASON");
    Assert.assertNull(retireable.getRetireReason());
}
Also used : Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Aggregations

Retireable (org.openmrs.Retireable)15 Test (org.junit.Test)14 Location (org.openmrs.Location)14 Date (java.util.Date)5 User (org.openmrs.User)5 Collection (java.util.Collection)1 OpenmrsObject (org.openmrs.OpenmrsObject)1 Voidable (org.openmrs.Voidable)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