@Test public void testSettingConsentsOnARecordWithNonExistentConsents() throws Exception { BaseObject idsHolder = mock(BaseObject.class); Patient patient = mock(Patient.class); XWikiContext context = mock(XWikiContext.class); XWiki wiki = mock(XWiki.class); XWikiDocument patientDoc = mock(XWikiDocument.class); this.setUpSettingConsents(idsHolder, patient, patientDoc, context, wiki); List<String> existingIds = new LinkedList<>(); List<String> testIds = new LinkedList<>(); existingIds.add(ConsentConfigurationMocks.TEST_ID1); existingIds.add(ConsentConfigurationMocks.TEST_ID2); testIds.add("id_nonexistent"); testIds.addAll(existingIds); this.mocker.getComponentUnderTest().setPatientConsents(patient, testIds); verify(idsHolder, times(1)).set(eq("granted"), eq(existingIds), eq(context)); verify(wiki, times(1)).saveDocument(eq(patientDoc), anyString(), eq(true), eq(context)); }
@Override public boolean setPatientConsents(Patient patient, Iterable<String> consents) { try { List<Consent> existingConsents = this.selectFromSystem(consents); SaveablePatientConsentHolder holder = this.getPatientConsentHolder(patient); holder.setConsents(convertToIds(existingConsents)); holder.save(); return true; } catch (Exception ex) { this.logger.error("Could not update consents in patient record {}. {}", patient, ex.getMessage()); } return false; }
PhenoTipsPatientConsentManager implements ConsentManager, Initializable { @Override public boolean setPatientConsents(Patient patient, Iterable<String> consents) { try { List<Consent> existingConsents = this.selectFromSystem(consents); SaveablePatientConsentHolder holder = this.getPatientConsentHolder(patient); holder.setConsents(convertToIds(existingConsents)); holder.save(); return true; } catch (Exception ex) { this.logger.error("Could not update consents in patient record {}. {}", patient, ex.getMessage()); } return false; } }
PhenoTipsPatientConsentManager implements ConsentManager, Initializable { @Override public boolean setPatientConsents(Patient patient, Iterable<String> consents) { try { List<Consent> existingConsents = this.selectFromSystem(consents); SaveablePatientConsentHolder holder = this.getPatientConsentHolder(patient); holder.setConsents(convertToIds(existingConsents)); holder.save(); return true; } catch (Exception ex) { this.logger.error("Could not update consents in patient record {}. {}", patient, ex.getMessage()); } return false; }  }
PhenoTipsPatientConsentManager implements ConsentManager, Initializable { @Override public boolean setPatientConsents(Patient patient, Iterable<String> consents) { try { List<Consent> existingConsents = this.selectFromSystem(consents); SaveablePatientConsentHolder holder = this.getPatientConsentHolder(patient); holder.setConsents(convertToIds(existingConsents)); holder.save(); return true; } catch (Exception ex) { this.logger.error("Could not update consents in patient record {}. {}", patient, ex.getMessage()); } return false; }  @Override void initialize(); @Override Set<Consent> getSystemConsents(); @Override boolean isValidConsentId(String consentId); @Override Set<Consent> getMissingConsentsForPatient(String patientId); @Override Set<Consent> getMissingConsentsForPatient(Patient patient); @Override Set<Consent> getAllConsentsForPatient(String patientId); @Override Set<Consent> getAllConsentsForPatient(Patient patient); @Override boolean setPatientConsents(Patient patient, Iterable<String> consents); @Override boolean hasConsent(String patientId, String consentId); @Override boolean hasConsent(Patient patient, String consentId); @Override boolean grantConsent(Patient patient, String consentId); @Override boolean revokeConsent(Patient patient, String consentId); @Override JSONArray toJSON(Collection<Consent> consents); @Override Set<Consent> fromJSON(JSONArray consentsJSON); }
PhenoTipsPatientConsentManager implements ConsentManager, Initializable { @Override public boolean setPatientConsents(Patient patient, Iterable<String> consents) { try { List<Consent> existingConsents = this.selectFromSystem(consents); SaveablePatientConsentHolder holder = this.getPatientConsentHolder(patient); holder.setConsents(convertToIds(existingConsents)); holder.save(); return true; } catch (Exception ex) { this.logger.error("Could not update consents in patient record {}. {}", patient, ex.getMessage()); } return false; }  @Override void initialize(); @Override Set<Consent> getSystemConsents(); @Override boolean isValidConsentId(String consentId); @Override Set<Consent> getMissingConsentsForPatient(String patientId); @Override Set<Consent> getMissingConsentsForPatient(Patient patient); @Override Set<Consent> getAllConsentsForPatient(String patientId); @Override Set<Consent> getAllConsentsForPatient(Patient patient); @Override boolean setPatientConsents(Patient patient, Iterable<String> consents); @Override boolean hasConsent(String patientId, String consentId); @Override boolean hasConsent(Patient patient, String consentId); @Override boolean grantConsent(Patient patient, String consentId); @Override boolean revokeConsent(Patient patient, String consentId); @Override JSONArray toJSON(Collection<Consent> consents); @Override Set<Consent> fromJSON(JSONArray consentsJSON);  }