Search in sources :

Example 76 with Person

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

the class AuditableInterceptorTest method onSave_shouldPopulateCreatorForPersonIfNull.

@Test
public void onSave_shouldPopulateCreatorForPersonIfNull() {
    Person person = createPersonWithNameAndAddress();
    Context.getPersonService().savePerson(person);
    Assert.assertNotNull(person.getCreator());
    Assert.assertNotNull(person.getPersonCreator());
}
Also used : Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 77 with Person

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

the class BaseVoidHandlerTest method handle_shouldSetDateVoided.

/**
 * @see BaseVoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldSetDateVoided() {
    Date d = new Date();
    VoidHandler<Voidable> handler = new BaseVoidHandler();
    Voidable voidable = new Person();
    handler.handle(voidable, null, d, " ");
    Assert.assertEquals(d, voidable.getDateVoided());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Date(java.util.Date) Test(org.junit.Test)

Example 78 with Person

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

the class BaseVoidHandlerTest method handle_shouldNotSetVoidedByIfNonNull.

/**
 * @see BaseVoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldNotSetVoidedByIfNonNull() {
    VoidHandler<Voidable> handler = new BaseVoidHandler();
    Voidable voidable = new Person();
    voidable.setVoidedBy(new User(3));
    handler.handle(voidable, new User(2), null, " ");
    Assert.assertEquals(3, voidable.getVoidedBy().getId().intValue());
}
Also used : User(org.openmrs.User) Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Example 79 with Person

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

the class BaseVoidHandlerTest method handle_shouldNotSetDateVoidedIfNonNull.

/**
 * @see BaseVoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldNotSetDateVoidedIfNonNull() {
    // a time that is not "now"
    Date d = new Date(new Date().getTime() - 1000);
    VoidHandler<Voidable> handler = new BaseVoidHandler();
    Voidable voidable = new Person();
    // make dateVoided non null
    voidable.setDateVoided(d);
    handler.handle(voidable, null, new Date(), " ");
    Assert.assertEquals(d, voidable.getDateVoided());
}
Also used : Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Date(java.util.Date) Test(org.junit.Test)

Example 80 with Person

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

the class BaseVoidHandlerTest method handle_shouldNotSetTheVoidReasonIfAlreadyVoided.

/**
 * @see BaseVoidHandler#handle(Voidable,User,Date,String)
 */
@Test
public void handle_shouldNotSetTheVoidReasonIfAlreadyVoided() {
    VoidHandler<Voidable> handler = new BaseVoidHandler();
    Voidable voidable = new Person();
    voidable.setVoided(true);
    voidable.setVoidedBy(new User(1));
    handler.handle(voidable, null, null, "THE REASON");
    Assert.assertNull(voidable.getVoidReason());
}
Also used : User(org.openmrs.User) Voidable(org.openmrs.Voidable) Person(org.openmrs.Person) Test(org.junit.Test)

Aggregations

Person (org.openmrs.Person)172 Test (org.junit.Test)140 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)107 PersonName (org.openmrs.PersonName)41 User (org.openmrs.User)36 Date (java.util.Date)33 Relationship (org.openmrs.Relationship)19 Obs (org.openmrs.Obs)16 Patient (org.openmrs.Patient)15 BindException (org.springframework.validation.BindException)15 Message (ca.uhn.hl7v2.model.Message)14 Concept (org.openmrs.Concept)14 Provider (org.openmrs.Provider)14 Voidable (org.openmrs.Voidable)14 Errors (org.springframework.validation.Errors)14 ArrayList (java.util.ArrayList)10 PersonMergeLog (org.openmrs.person.PersonMergeLog)9 RelationshipType (org.openmrs.RelationshipType)8 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)7 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)7