Search in sources :

Example 1 with PersonMergeLog

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

the class PersonServiceTest method getLosingPersonMergeLog_shouldFindPersonMergeLogByLoser.

/**
 * @see PersonService#getLosingPersonMergeLog(Person)
 */
@Test
public void getLosingPersonMergeLog_shouldFindPersonMergeLogByLoser() throws Exception {
    // log merge 1 >> 2
    PersonMergeLog personMergeLog12 = getTestPersonMergeLog();
    personMergeLog12.setLoser(new Person(1));
    personMergeLog12.setWinner(new Person(2));
    Context.getPersonService().savePersonMergeLog(personMergeLog12);
    // log merge 2 >> 6
    PersonMergeLog personMergeLog26 = getTestPersonMergeLog();
    personMergeLog26.setLoser(new Person(2));
    personMergeLog26.setWinner(new Person(6));
    Context.getPersonService().savePersonMergeLog(personMergeLog26);
    // find where loser is 2
    PersonMergeLog l = Context.getPersonService().getLosingPersonMergeLog(new Person(2), true);
    Assert.assertEquals("Incorrect PersonMergeLog found by loser", l.getUuid(), personMergeLog26.getUuid());
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 2 with PersonMergeLog

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

the class PersonServiceTest method savePersonMergeLog_shouldRequirePersonMergeLogData.

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

Example 3 with PersonMergeLog

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

the class PersonServiceTest method savePersonMergeLog_shouldSetCreatorIfNull.

/**
 * @see PersonService#savePersonMergeLog(PersonMergeLog)
 */
@Test
public void savePersonMergeLog_shouldSetCreatorIfNull() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    personMergeLog.setCreator(null);
    PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog);
    Assert.assertEquals("creator has not been correctly set", Context.getAuthenticatedUser().getUserId(), persisted.getCreator().getUserId());
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with PersonMergeLog

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

the class PersonServiceTest method getWinningPersonMergeLogs_shouldRetrievePersonMergeLogsByWinner.

/**
 * @see PersonService#getWinningPersonMergeLogs(Person)
 */
@Test
public void getWinningPersonMergeLogs_shouldRetrievePersonMergeLogsByWinner() throws Exception {
    // log merge 1 >> 2
    PersonMergeLog personMergeLog12 = getTestPersonMergeLog();
    personMergeLog12.setLoser(new Person(1));
    personMergeLog12.setWinner(new Person(2));
    Context.getPersonService().savePersonMergeLog(personMergeLog12);
    // log merge 1 >> 6
    PersonMergeLog personMergeLog16 = getTestPersonMergeLog();
    personMergeLog16.setLoser(new Person(1));
    personMergeLog16.setWinner(new Person(6));
    Context.getPersonService().savePersonMergeLog(personMergeLog16);
    // log merge 2 >> 6
    PersonMergeLog personMergeLog26 = getTestPersonMergeLog();
    personMergeLog26.setLoser(new Person(2));
    personMergeLog26.setWinner(new Person(6));
    Context.getPersonService().savePersonMergeLog(personMergeLog26);
    // find where winner is 6
    List<PersonMergeLog> lst = Context.getPersonService().getWinningPersonMergeLogs(new Person(6), true);
    Assert.assertEquals("Incorrect number of PersonMergeLog objects found by winner", 2, lst.size());
    for (PersonMergeLog l : lst) {
        if (!l.getUuid().equals(personMergeLog16.getUuid()) && !l.getUuid().equals(personMergeLog26.getUuid())) {
            fail("Unexpected PersonMergeLog found by winner");
        }
    }
}
Also used : PersonMergeLog(org.openmrs.person.PersonMergeLog) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with PersonMergeLog

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

the class PersonServiceTest method getPersonMergeLogByUuid_shouldRetrievePersonMergeLogAndDeserializeData.

/**
 * @see PersonService#getPersonMergeLogByUuid(String,boolean)
 */
@Test
public void getPersonMergeLogByUuid_shouldRetrievePersonMergeLogAndDeserializeData() throws Exception {
    PersonMergeLog personMergeLog = getTestPersonMergeLog();
    int originalHashValue = personMergeLog.getPersonMergeLogData().computeHashValue();
    PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog);
    PersonMergeLog retrieved = Context.getPersonService().getPersonMergeLogByUuid(persisted.getUuid(), true);
    Assert.assertNotNull("problem retrieving PersonMergeLog by UUID", retrieved);
    Assert.assertEquals("deserialized data is not identical to original data", originalHashValue, retrieved.getPersonMergeLogData().computeHashValue());
}
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