@Test void createWithException() throws Exception { DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page"); when(this.xcontext.getWiki().getDocument(documentReference, this.xcontext)).thenThrow(new XWikiException()); this.modelBridge.create(documentReference); assertLog(Level.ERROR, "Failed to create document [{}].", documentReference); }
@Override public boolean create(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { XWikiDocument newDocument = xcontext.getWiki().getDocument(documentReference, xcontext); xcontext.getWiki().saveDocument(newDocument, xcontext); this.logger.info("Document [{}] has been created.", documentReference); return true; } catch (Exception e) { this.logger.error("Failed to create document [{}].", documentReference, e); return false; } }
DefaultModelBridge implements ModelBridge { @Override public boolean create(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { XWikiDocument newDocument = xcontext.getWiki().getDocument(documentReference, xcontext); xcontext.getWiki().saveDocument(newDocument, xcontext); this.logger.info("Document [{}] has been created.", documentReference); return true; } catch (Exception e) { this.logger.error("Failed to create document [{}].", documentReference, e); return false; } } }
DefaultModelBridge implements ModelBridge { @Override public boolean create(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { XWikiDocument newDocument = xcontext.getWiki().getDocument(documentReference, xcontext); xcontext.getWiki().saveDocument(newDocument, xcontext); this.logger.info("Document [{}] has been created.", documentReference); return true; } catch (Exception e) { this.logger.error("Failed to create document [{}].", documentReference, e); return false; } }  }
DefaultModelBridge implements ModelBridge { @Override public boolean create(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { XWikiDocument newDocument = xcontext.getWiki().getDocument(documentReference, xcontext); xcontext.getWiki().saveDocument(newDocument, xcontext); this.logger.info("Document [{}] has been created.", documentReference); return true; } catch (Exception e) { this.logger.error("Failed to create document [{}].", documentReference, e); return false; } }  @Override boolean create(DocumentReference documentReference); @Override boolean copy(DocumentReference source, DocumentReference destination); @Override boolean delete(DocumentReference reference); @Override boolean delete(DocumentReference reference, boolean skipRecycleBin); @Override boolean removeLock(DocumentReference reference); @Override void createRedirect(DocumentReference oldReference, DocumentReference newReference); @Override boolean canOverwriteSilently(DocumentReference documentReference); @Override boolean exists(DocumentReference reference); @Override List<DocumentReference> getBackLinkedReferences(DocumentReference documentReference, String wikiId); @Override List<DocumentReference> getDocumentReferences(SpaceReference spaceReference); @Override boolean updateParentField(final DocumentReference oldParentReference,
        final DocumentReference newParentReference); @Override DocumentReference setContextUserReference(DocumentReference userReference); @Override void update(DocumentReference documentReference, Map<String, String> parameters); @Override boolean restoreDeletedDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override List<Long> getDeletedDocumentIds(String batchId); @Override boolean permanentlyDeleteDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override boolean permanentlyDeleteAllDocuments(PermanentlyDeleteJob deleteJob, AbstractCheckRightsRequest request); @Override boolean rename(DocumentReference source, DocumentReference destination); }
DefaultModelBridge implements ModelBridge { @Override public boolean create(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { XWikiDocument newDocument = xcontext.getWiki().getDocument(documentReference, xcontext); xcontext.getWiki().saveDocument(newDocument, xcontext); this.logger.info("Document [{}] has been created.", documentReference); return true; } catch (Exception e) { this.logger.error("Failed to create document [{}].", documentReference, e); return false; } }  @Override boolean create(DocumentReference documentReference); @Override boolean copy(DocumentReference source, DocumentReference destination); @Override boolean delete(DocumentReference reference); @Override boolean delete(DocumentReference reference, boolean skipRecycleBin); @Override boolean removeLock(DocumentReference reference); @Override void createRedirect(DocumentReference oldReference, DocumentReference newReference); @Override boolean canOverwriteSilently(DocumentReference documentReference); @Override boolean exists(DocumentReference reference); @Override List<DocumentReference> getBackLinkedReferences(DocumentReference documentReference, String wikiId); @Override List<DocumentReference> getDocumentReferences(SpaceReference spaceReference); @Override boolean updateParentField(final DocumentReference oldParentReference,
        final DocumentReference newParentReference); @Override DocumentReference setContextUserReference(DocumentReference userReference); @Override void update(DocumentReference documentReference, Map<String, String> parameters); @Override boolean restoreDeletedDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override List<Long> getDeletedDocumentIds(String batchId); @Override boolean permanentlyDeleteDocument(long deletedDocumentId, AbstractCheckRightsRequest request); @Override boolean permanentlyDeleteAllDocuments(PermanentlyDeleteJob deleteJob, AbstractCheckRightsRequest request); @Override boolean rename(DocumentReference source, DocumentReference destination);  }