Search in sources :

Example 6 with Retireable

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

the class BaseUnretireHandlerTest method handle_shouldUnsetTheRetiredBit.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheRetiredBit() {
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    // make sure isRetired is set
    retireable.setRetired(true);
    handler.handle(retireable, null, null, null);
    Assert.assertFalse(retireable.getRetired());
}
Also used : Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 7 with Retireable

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

the class BaseRetireHandlerTest method handle_shouldSetRetiredBy.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldSetRetiredBy() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    handler.handle(retireable, new User(2), null, " ");
    Assert.assertEquals(2, retireable.getRetiredBy().getId().intValue());
}
Also used : User(org.openmrs.User) Retireable(org.openmrs.Retireable) Location(org.openmrs.Location) Test(org.junit.Test)

Example 8 with Retireable

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

the class BaseRetireHandlerTest method handle_shouldNotSetDateRetiredIfNonNull.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldNotSetDateRetiredIfNonNull() {
    // a time that is not "now"
    Date d = new Date(new Date().getTime() - 1000);
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    // make dateRetired non null
    retireable.setDateRetired(d);
    handler.handle(retireable, null, new Date(), " ");
    Assert.assertEquals(d, retireable.getDateRetired());
}
Also used : Retireable(org.openmrs.Retireable) Date(java.util.Date) Location(org.openmrs.Location) Test(org.junit.Test)

Example 9 with Retireable

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

the class BaseRetireHandlerTest method handle_shouldSetDateRetired.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldSetDateRetired() {
    Date d = new Date();
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    handler.handle(retireable, null, d, " ");
    Assert.assertEquals(d, retireable.getDateRetired());
}
Also used : Retireable(org.openmrs.Retireable) Date(java.util.Date) Location(org.openmrs.Location) Test(org.junit.Test)

Example 10 with Retireable

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

the class BaseRetireHandlerTest method handle_shouldSetTheRetiredBit.

/**
 * @see BaseRetireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldSetTheRetiredBit() {
    RetireHandler<Retireable> handler = new BaseRetireHandler();
    Retireable retireable = new Location();
    // make sure isRetired is false
    retireable.setRetired(false);
    handler.handle(retireable, null, null, " ");
    Assert.assertTrue(retireable.getRetired());
}
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