@Test public void onDocumentRenamedWithUpdateLinksOnWiki() { renameRequest.setUpdateLinks(true); renameRequest.setUpdateLinksOnFarm(false); when(this.renameJob.hasAccess(Right.EDIT, carolReference)).thenReturn(true); this.listener.onEvent(documentRenamedEvent, renameJob, renameRequest); verify(this.linkRefactoring).renameLinks(carolReference, aliceReference, bobReference); verify(this.linkRefactoring, never()).renameLinks(eq(denisReference), any(), any()); assertEquals("Updating the back-links for document [foo:Users.Alice] in wiki [foo].", logCapture.getMessage(0)); }
@Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean updateLinks = true; boolean updateLinksOnFarm = true; Predicate<EntityReference> canEdit = entityReference -> this.authorization.hasAccess(Right.EDIT, entityReference); if (source instanceof MoveJob) { MoveRequest request = (MoveRequest) data; updateLinks = request.isUpdateLinks(); updateLinksOnFarm = request.isUpdateLinksOnFarm(); canEdit = entityReference -> ((MoveJob) source).hasAccess(Right.EDIT, entityReference); } if (updateLinks) { updateBackLinks((DocumentRenamedEvent) event, canEdit, updateLinksOnFarm); } } }
BackLinkUpdaterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean updateLinks = true; boolean updateLinksOnFarm = true; Predicate<EntityReference> canEdit = entityReference -> this.authorization.hasAccess(Right.EDIT, entityReference); if (source instanceof MoveJob) { MoveRequest request = (MoveRequest) data; updateLinks = request.isUpdateLinks(); updateLinksOnFarm = request.isUpdateLinksOnFarm(); canEdit = entityReference -> ((MoveJob) source).hasAccess(Right.EDIT, entityReference); } if (updateLinks) { updateBackLinks((DocumentRenamedEvent) event, canEdit, updateLinksOnFarm); } } } }
BackLinkUpdaterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean updateLinks = true; boolean updateLinksOnFarm = true; Predicate<EntityReference> canEdit = entityReference -> this.authorization.hasAccess(Right.EDIT, entityReference); if (source instanceof MoveJob) { MoveRequest request = (MoveRequest) data; updateLinks = request.isUpdateLinks(); updateLinksOnFarm = request.isUpdateLinksOnFarm(); canEdit = entityReference -> ((MoveJob) source).hasAccess(Right.EDIT, entityReference); } if (updateLinks) { updateBackLinks((DocumentRenamedEvent) event, canEdit, updateLinksOnFarm); } } } BackLinkUpdaterListener(); }
BackLinkUpdaterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean updateLinks = true; boolean updateLinksOnFarm = true; Predicate<EntityReference> canEdit = entityReference -> this.authorization.hasAccess(Right.EDIT, entityReference); if (source instanceof MoveJob) { MoveRequest request = (MoveRequest) data; updateLinks = request.isUpdateLinks(); updateLinksOnFarm = request.isUpdateLinksOnFarm(); canEdit = entityReference -> ((MoveJob) source).hasAccess(Right.EDIT, entityReference); } if (updateLinks) { updateBackLinks((DocumentRenamedEvent) event, canEdit, updateLinksOnFarm); } } } BackLinkUpdaterListener(); @Override void onEvent(Event event, Object source, Object data); }
BackLinkUpdaterListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean updateLinks = true; boolean updateLinksOnFarm = true; Predicate<EntityReference> canEdit = entityReference -> this.authorization.hasAccess(Right.EDIT, entityReference); if (source instanceof MoveJob) { MoveRequest request = (MoveRequest) data; updateLinks = request.isUpdateLinks(); updateLinksOnFarm = request.isUpdateLinksOnFarm(); canEdit = entityReference -> ((MoveJob) source).hasAccess(Right.EDIT, entityReference); } if (updateLinks) { updateBackLinks((DocumentRenamedEvent) event, canEdit, updateLinksOnFarm); } } } BackLinkUpdaterListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }