@Test public void loadWithUserOwnerAndMissingFields() throws ComponentLookupException { EntityPermissionsManager permissions = this.mocker.getInstance(EntityPermissionsManager.class); EntityAccess access = mock(EntityAccess.class); when(permissions.getEntityAccess(this.patient)).thenReturn(access); Owner owner = mock(Owner.class); when(access.getOwner()).thenReturn(owner); when(owner.isGroup()).thenReturn(false); when(owner.getUser()).thenReturn(USER); UserManager users = this.mocker.getInstance(UserManager.class); User user = mock(User.class); when(users.getUser(USER_STR)).thenReturn(user); when(user.getId()).thenReturn(USER_STR); when(user.getName()).thenReturn(null); when(user.getUsername()).thenReturn(USER.getName()); when(user.getAttribute("email")).thenReturn(""); when(user.getAttribute("company")).thenReturn(" "); List<ContactInfo> result = this.mocker.getComponentUnderTest().getContacts(this.patient); Assert.assertEquals(1, result.size()); ContactInfo contact = result.get(0); Assert.assertNull(contact.getName()); Assert.assertEquals(USER_STR, contact.getUserId()); Assert.assertTrue(contact.getEmails().isEmpty()); Assert.assertNull(contact.getInstitution()); }
@Override public List<ContactInfo> getContacts(Patient patient) { EntityAccess referenceAccess = this.entityPermissionsManager.getEntityAccess(patient); Owner owner = referenceAccess.getOwner(); ContactInfo result = getContactInfo(owner); if (result == null) { return null; } return Arrays.asList(result); }
OwnerContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { EntityAccess referenceAccess = this.entityPermissionsManager.getEntityAccess(patient); Owner owner = referenceAccess.getOwner(); ContactInfo result = getContactInfo(owner); if (result == null) { return null; } return Arrays.asList(result); } }
OwnerContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { EntityAccess referenceAccess = this.entityPermissionsManager.getEntityAccess(patient); Owner owner = referenceAccess.getOwner(); ContactInfo result = getContactInfo(owner); if (result == null) { return null; } return Arrays.asList(result); }  }
OwnerContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { EntityAccess referenceAccess = this.entityPermissionsManager.getEntityAccess(patient); Owner owner = referenceAccess.getOwner(); ContactInfo result = getContactInfo(owner); if (result == null) { return null; } return Arrays.asList(result); }  @Override int getPriority(); @Override List<ContactInfo> getContacts(Patient patient); }
OwnerContactProvider implements PatientContactProvider { @Override public List<ContactInfo> getContacts(Patient patient) { EntityAccess referenceAccess = this.entityPermissionsManager.getEntityAccess(patient); Owner owner = referenceAccess.getOwner(); ContactInfo result = getContactInfo(owner); if (result == null) { return null; } return Arrays.asList(result); }  @Override int getPriority(); @Override List<ContactInfo> getContacts(Patient patient);  }