@Test
public void testFindPerson() {
System.out.println("JUnit Test getData - findPerson");
String instanceName = Mediator.getProperty("Instance.Name");
System.out.println("Instance.Name = '" + instanceName + "'");
PersonRequest requestData = new PersonRequest();
Person p = new Person();
requestData.setPerson(p);
Object result;
PersonResponse pr;
List<Person> pList;
// Name that will not be found
p.setFirstName("O<NotAFirstName");
p.setClanName("O\"NotAClanName");
result = mediator.getData(RequestTypeId.FIND_PERSON_MPI, requestData);
assertNotNull(result);
assertSame(PersonResponse.class, result.getClass());
pr = (PersonResponse) result;
assertTrue(pr.isSuccessful());
assertNull(pr.getPersonList());
// Clan name having 8 matches in the first 100 people
p.setClanName("KONYANGO");
result = mediator.getData(RequestTypeId.FIND_PERSON_MPI, requestData);
assertNotNull(result);
assertSame(PersonResponse.class, result.getClass());
pr = (PersonResponse) result;
assertTrue(pr.isSuccessful());
pList = pr.getPersonList();
assertNotNull(pList);
int pCount = pList.size();
assertEquals(pCount, 8);
for (Person person : pList) {
System.out.println("guid: " + person.getPersonGuid()
+ " score: " + person.getMatchScore()
+ " name: " + n(person.getFirstName()) + " " + n(person.getMiddleName()) + " " + n(person.getLastName()) + " [" + n(person.getOtherName()) + "]"
+ " sex: " + n(person.getSex())
+ " birth/death: " + n(person.getBirthdate()) + "/" + n(person.getDeathdate())
+ " clan: " + n(person.getClanName())
+ " mother: " + n(person.getMothersFirstName()) + " " + n(person.getMothersMiddleName()) + " " + n(person.getMothersLastName())
+ " father: " + n(person.getFathersFirstName()) + " " + n(person.getFathersMiddleName()) + " " + n(person.getFathersLastName())
+ " compHead: " + n(person.getCompoundHeadFirstName()) + " " + n(person.getCompoundHeadMiddleName()) + " " + n(person.getCompoundHeadLastName())
+ " village: " + n(person.getVillageName())
+ " marital: " + n(person.getMaritalStatus()));
}
for (int i = 0; i < pList.size(); i++) {
Person person = pList.get(i);
assertNotNull(person.getFirstName());
assertNotNull(person.getMiddleName());
assertNotNull(person.getLastName());
// Make sure every returned person GUID is unique:
// Make sure every returned birthdate is unique:
for (int j = 0; j < i; j++) {
Person pj = pList.get(j);
assertFalse(pj.getPersonGuid().equals(person.getPersonGuid()));
assertFalse(pj.getBirthdate().equals(person.getBirthdate()));
}
}
Person p0 = pList.get(0);
int score = p0.getMatchScore();
assertEquals(score, 100);
requestData.setPerson(p0);
requestData.setRequestReference(pr.getRequestReference());
result = mediator.getData(RequestTypeId.MODIFY_PERSON_MPI, requestData);
// Exercise fingerprint matching code
p0 = new Person();
List<Fingerprint> fpList = new ArrayList<Fingerprint>();
byte[] b = {1, 2, 3};
Fingerprint f = new Fingerprint();
f.setTemplate(b);
f.setFingerprintType(Fingerprint.Type.rightRingFinger);
f.setTechnologyType(Fingerprint.TechnologyType.griauleTemplate);
fpList.add(f);
p0.setFingerprintList(fpList);
requestData.setPerson(p0);
pr = callFindPerson(requestData);
}