### Question:
ReplaceUserJob extends AbstractReplaceUserJob { @Override protected void update(DocumentReference documentReference) { XWikiContext xcontext = this.xcontextProvider.get(); try { update(xcontext.getWiki().getDocument(documentReference, xcontext)); } catch (XWikiException e) { this.logger.error("Failed to update document [{}]. Root cause is [{}].", documentReference, ExceptionUtils.getRootCauseMessage(e)); } }    }### Answer:
@Test public void updateCreator() throws Exception { this.request.setReplaceDocumentCreator(true); this.request.setReplaceDocumentAuthor(true); when(this.document.getCreatorReference()).thenReturn(this.alice); this.replaceUserJob.update(this.document.getDocumentReference()); verify(this.document).setCreatorReference(this.bob); verify(this.xwiki).saveDocument(this.document, "Replaced user [test:Users.Alice] in fields [creator] to user [test:Users.Bob]", this.xcontext); }
@Test public void updateAuthor() throws Exception { this.request.setReplaceDocumentAuthor(true); this.request.setReplaceDocumentContentAuthor(true); when(this.document.getAuthorReference()).thenReturn(alice); when(this.document.getContentAuthorReference()).thenReturn(alice); this.replaceUserJob.update(this.document.getDocumentReference()); verify(this.document).setAuthorReference(bob); verify(this.document).setContentAuthorReference(bob); verify(this.xwiki).saveDocument(this.document, "Replaced user [test:Users.Alice] in fields [author, contentAuthor] to user [test:Users.Bob]", this.xcontext); }