@Test public void returnsFalseAfterXWikiExceptionWhileRetrievingDocument() throws ComponentLookupException, XWikiException { Mockito.doThrow(new XWikiException()).when(this.xwiki).getDocument(this.patientDocumentReference, this.context); PatientRecordLockManager mockedLockManager = this.mocker.getComponentUnderTest(); Assert.assertFalse(mockedLockManager.lockPatientRecord(this.patient)); }
@Override public boolean lockPatientRecord(Patient patient) { try { XWikiDocument patientDocument = patient.getXDocument(); if (!this.isDocumentLocked(patientDocument) && this.hasLockingPermission(patient)) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); patientDocument.createXObject(this.lockClassReference, context); xwiki.saveDocument(patientDocument, "Locked patient record", true, context); return true; } else { return false; } } catch (XWikiException | NullPointerException e) { return false; } }
DefaultPatientRecordLockManager implements org.phenotips.recordLocking.PatientRecordLockManager { @Override public boolean lockPatientRecord(Patient patient) { try { XWikiDocument patientDocument = patient.getXDocument(); if (!this.isDocumentLocked(patientDocument) && this.hasLockingPermission(patient)) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); patientDocument.createXObject(this.lockClassReference, context); xwiki.saveDocument(patientDocument, "Locked patient record", true, context); return true; } else { return false; } } catch (XWikiException | NullPointerException e) { return false; } } }
DefaultPatientRecordLockManager implements org.phenotips.recordLocking.PatientRecordLockManager { @Override public boolean lockPatientRecord(Patient patient) { try { XWikiDocument patientDocument = patient.getXDocument(); if (!this.isDocumentLocked(patientDocument) && this.hasLockingPermission(patient)) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); patientDocument.createXObject(this.lockClassReference, context); xwiki.saveDocument(patientDocument, "Locked patient record", true, context); return true; } else { return false; } } catch (XWikiException | NullPointerException e) { return false; } }  }
DefaultPatientRecordLockManager implements org.phenotips.recordLocking.PatientRecordLockManager { @Override public boolean lockPatientRecord(Patient patient) { try { XWikiDocument patientDocument = patient.getXDocument(); if (!this.isDocumentLocked(patientDocument) && this.hasLockingPermission(patient)) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); patientDocument.createXObject(this.lockClassReference, context); xwiki.saveDocument(patientDocument, "Locked patient record", true, context); return true; } else { return false; } } catch (XWikiException | NullPointerException e) { return false; } }  @Override boolean lockPatientRecord(Patient patient); @Override boolean unlockPatientRecord(Patient patient); @Override boolean isLocked(Patient patient); }
DefaultPatientRecordLockManager implements org.phenotips.recordLocking.PatientRecordLockManager { @Override public boolean lockPatientRecord(Patient patient) { try { XWikiDocument patientDocument = patient.getXDocument(); if (!this.isDocumentLocked(patientDocument) && this.hasLockingPermission(patient)) { XWikiContext context = this.contextProvider.get(); XWiki xwiki = context.getWiki(); patientDocument.createXObject(this.lockClassReference, context); xwiki.saveDocument(patientDocument, "Locked patient record", true, context); return true; } else { return false; } } catch (XWikiException | NullPointerException e) { return false; } }  @Override boolean lockPatientRecord(Patient patient); @Override boolean unlockPatientRecord(Patient patient); @Override boolean isLocked(Patient patient);  }