Search in sources :

Example 6 with PersonMergeLog

use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.

the class PersonServiceTest method getTestPersonMergeLog.

private PersonMergeLog getTestPersonMergeLog() {
    PersonMergeLog personMergeLog = new PersonMergeLog();
    personMergeLog.setLoser(new Person(1));
    personMergeLog.setWinner(new Person(2));
    PersonMergeLogData data = new PersonMergeLogData();
    data.addCreatedAddress("1");
    data.addCreatedAttribute("2");
    data.addCreatedIdentifier("3");
    data.addCreatedName("4");
    data.addCreatedOrder("5");
    data.addCreatedProgram("6");
    data.addCreatedRelationship("7");
    data.addMovedEncounter("8");
    data.addMovedIndependentObservation("9");
    data.addMovedUser("10");
    data.addVoidedRelationship("11");
    data.setPriorCauseOfDeath("test");
    data.setPriorDateOfBirth(new Date());
    data.setPriorDateOfBirthEstimated(true);
    data.setPriorDateOfDeath(new Date());
    data.setPriorGender("F");
    personMergeLog.setPersonMergeLogData(data);
    return personMergeLog;
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Person(org.openmrs.Person) Date(java.util.Date) PersonMergeLogData(org.openmrs.person.PersonMergeLogData)

Example 7 with PersonMergeLog

use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.

the class PersonServiceTest method getPersonMergeLogByUuid_shouldRetrievePersonMergeLogWithoutDeserializingData.

/**
 * @see PersonService#getPersonMergeLogByUuid(String,boolean)
 */
@Test
public void getPersonMergeLogByUuid_shouldRetrievePersonMergeLogWithoutDeserializingData() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog);
    PersonMergeLog retrieved = Context.getPersonService().getPersonMergeLogByUuid(persisted.getUuid(), false);
    Assert.assertNotNull("problem retrieving PersonMergeLog by UUID", retrieved);
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with PersonMergeLog

use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.

the class PersonServiceTest method savePersonMergeLog_shouldRequireWinner.

/**
 * @see PersonService#savePersonMergeLog(PersonMergeLog)
 */
@Test(expected = APIException.class)
public void savePersonMergeLog_shouldRequireWinner() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    personMergeLog.setWinner(null);
    Context.getPersonService().savePersonMergeLog(personMergeLog);
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with PersonMergeLog

use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.

the class PersonServiceTest method savePersonMergeLog_shouldSavePersonMergeLog.

/**
 * @see PersonService#savePersonMergeLog(PersonMergeLog)
 */
@Test
public void savePersonMergeLog_shouldSavePersonMergeLog() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    try {
        PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog);
        Assert.assertNotNull("patientMergeLogId has not been set which indicates a problem saving the object", persisted.getPersonMergeLogId());
    } catch (Exception ex) {
        Assert.fail("should not fail when all required fields are set. " + ex.getMessage());
    }
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 10 with PersonMergeLog

use of org.openmrs.person.PersonMergeLog in project openmrs-core by openmrs.

the class PersonServiceTest method getAllPersonMergeLogs_shouldRetrieveAllPersonMergeLogsFromTheModel.

/**
 * @see PersonService#getAllPersonMergeLogs(boolean)
 */
@Test
public void getAllPersonMergeLogs_shouldRetrieveAllPersonMergeLogsFromTheModel() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    Context.getPersonService().savePersonMergeLog(personMergeLog);
    List<PersonMergeLog> result = Context.getPersonService().getAllPersonMergeLogs(false);
    Assert.assertEquals("could not retrieve expected number of PersonMergeLog objects", 1, result.size());
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PersonMergeLog (org.openmrs.person.PersonMergeLog)41 Test (org.junit.Test)37 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)37 Patient (org.openmrs.Patient)18 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)18 Person (org.openmrs.Person)9 PersonName (org.openmrs.PersonName)8 PersonMergeLogData (org.openmrs.person.PersonMergeLogData)8 Date (java.util.Date)6 BindException (org.springframework.validation.BindException)6 Errors (org.springframework.validation.Errors)6 GregorianCalendar (java.util.GregorianCalendar)4 Location (org.openmrs.Location)2 Obs (org.openmrs.Obs)2 PatientIdentifier (org.openmrs.PatientIdentifier)2 PersonAddress (org.openmrs.PersonAddress)2 PersonAttribute (org.openmrs.PersonAttribute)2 ArrayList (java.util.ArrayList)1 Encounter (org.openmrs.Encounter)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1