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());
}
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);
}
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());
}
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");
}
}
}
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());
}
Aggregations