@Test public void loadWithGroupOwnerAndMissingFields() throws Exception { 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(true); when(owner.getUser()).thenReturn(GROUP); GroupManager groups = this.mocker.getInstance(GroupManager.class); Group group = mock(Group.class); when(groups.getGroup(GROUP)).thenReturn(group); DocumentAccessBridge dab = this.mocker.getInstance(DocumentAccessBridge.class); when(group.getReference()).thenReturn(GROUP); XWikiDocument doc = mock(XWikiDocument.class); when(dab.getDocument(GROUP)).thenReturn(doc); BaseObject obj = mock(BaseObject.class); when(doc.getXObject(Group.CLASS_REFERENCE)).thenReturn(obj); when(obj.getStringValue("contact")).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(GROUP.toString(), 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);  }