@Test public void nullContactsAreIgnored() throws ComponentLookupException { List<ContactInfo> contacts = new ArrayList<>(); contacts.add(this.contact1); contacts.add(this.contact2); when(this.provider1.getContacts(this.patient)).thenReturn(null); when(this.provider2.getContacts(this.patient)).thenReturn(contacts); List<PatientContactProvider> providers = new ArrayList<>(); providers.add(this.provider1); providers.add(this.provider2); when(this.providersProvider.get()).thenReturn(providers); List<ContactInfo> result = this.mocker.getComponentUnderTest().getAll(this.patient); Assert.assertEquals(2, result.size()); Assert.assertSame(this.contact1, result.get(0)); Assert.assertSame(this.contact2, result.get(1)); }
@Override public List<ContactInfo> getAll(Patient patient) { List<ContactInfo> contactInfos = new LinkedList<>(); for (PatientContactProvider provider : this.providers.get()) { List<ContactInfo> info = provider.getContacts(patient); if (info != null && !info.isEmpty()) { contactInfos.addAll(info); } } return contactInfos; }
DefaultPatientContactsManager implements PatientContactsManager { @Override public List<ContactInfo> getAll(Patient patient) { List<ContactInfo> contactInfos = new LinkedList<>(); for (PatientContactProvider provider : this.providers.get()) { List<ContactInfo> info = provider.getContacts(patient); if (info != null && !info.isEmpty()) { contactInfos.addAll(info); } } return contactInfos; } }
DefaultPatientContactsManager implements PatientContactsManager { @Override public List<ContactInfo> getAll(Patient patient) { List<ContactInfo> contactInfos = new LinkedList<>(); for (PatientContactProvider provider : this.providers.get()) { List<ContactInfo> info = provider.getContacts(patient); if (info != null && !info.isEmpty()) { contactInfos.addAll(info); } } return contactInfos; }  }
DefaultPatientContactsManager implements PatientContactsManager { @Override public List<ContactInfo> getAll(Patient patient) { List<ContactInfo> contactInfos = new LinkedList<>(); for (PatientContactProvider provider : this.providers.get()) { List<ContactInfo> info = provider.getContacts(patient); if (info != null && !info.isEmpty()) { contactInfos.addAll(info); } } return contactInfos; }  @Override List<ContactInfo> getAll(Patient patient); @Override ContactInfo getFirst(Patient patient); }
DefaultPatientContactsManager implements PatientContactsManager { @Override public List<ContactInfo> getAll(Patient patient) { List<ContactInfo> contactInfos = new LinkedList<>(); for (PatientContactProvider provider : this.providers.get()) { List<ContactInfo> info = provider.getContacts(patient); if (info != null && !info.isEmpty()) { contactInfos.addAll(info); } } return contactInfos; }  @Override List<ContactInfo> getAll(Patient patient); @Override ContactInfo getFirst(Patient patient);  }