@Test public void patientWithUnknownReporterReturnsEmptyContactList() throws ComponentLookupException { when(this.patient.getReporter()).thenReturn(null); List<ContactInfo> result = this.mocker.getComponentUnderTest().getContacts(this.patient); Assert.assertNotNull(result); Assert.assertTrue(result.isEmpty()); }
@Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); } list.add(contactInfo.build()); return list; }
ReporterContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); } list.add(contactInfo.build()); return list; } }
ReporterContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); } list.add(contactInfo.build()); return list; }  }
ReporterContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); } list.add(contactInfo.build()); return list; }  @Override int getPriority(); @Override List<ContactInfo> getContacts(Patient patient); }
ReporterContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); } list.add(contactInfo.build()); return list; }  @Override int getPriority(); @Override List<ContactInfo> getContacts(Patient patient);  }