@Test public void onDocumentRenamedWithAutomaticRedirect() { renameRequest.setAutoRedirect(true); this.listener.onEvent(documentRenamedEvent, null, renameRequest); verify(this.modelBridge).createRedirect(oldReference, newReference); assertEquals("Creating automatic redirect from [wiki:Users.Alice] to [wiki:Users.Bob].", logCapture.getMessage(0)); }
@Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean autoRedirect = true; if (data instanceof MoveRequest) { autoRedirect = ((MoveRequest) data).isAutoRedirect(); } if (autoRedirect) { DocumentRenamedEvent documentRenamedEvent = (DocumentRenamedEvent) event; this.logger.info("Creating automatic redirect from [{}] to [{}].", documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); this.modelBridge.createRedirect(documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); } } }
AutomaticRedirectCreatorListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean autoRedirect = true; if (data instanceof MoveRequest) { autoRedirect = ((MoveRequest) data).isAutoRedirect(); } if (autoRedirect) { DocumentRenamedEvent documentRenamedEvent = (DocumentRenamedEvent) event; this.logger.info("Creating automatic redirect from [{}] to [{}].", documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); this.modelBridge.createRedirect(documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); } } } }
AutomaticRedirectCreatorListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean autoRedirect = true; if (data instanceof MoveRequest) { autoRedirect = ((MoveRequest) data).isAutoRedirect(); } if (autoRedirect) { DocumentRenamedEvent documentRenamedEvent = (DocumentRenamedEvent) event; this.logger.info("Creating automatic redirect from [{}] to [{}].", documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); this.modelBridge.createRedirect(documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); } } } AutomaticRedirectCreatorListener(); }
AutomaticRedirectCreatorListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean autoRedirect = true; if (data instanceof MoveRequest) { autoRedirect = ((MoveRequest) data).isAutoRedirect(); } if (autoRedirect) { DocumentRenamedEvent documentRenamedEvent = (DocumentRenamedEvent) event; this.logger.info("Creating automatic redirect from [{}] to [{}].", documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); this.modelBridge.createRedirect(documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); } } } AutomaticRedirectCreatorListener(); @Override void onEvent(Event event, Object source, Object data); }
AutomaticRedirectCreatorListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (event instanceof DocumentRenamedEvent) { boolean autoRedirect = true; if (data instanceof MoveRequest) { autoRedirect = ((MoveRequest) data).isAutoRedirect(); } if (autoRedirect) { DocumentRenamedEvent documentRenamedEvent = (DocumentRenamedEvent) event; this.logger.info("Creating automatic redirect from [{}] to [{}].", documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); this.modelBridge.createRedirect(documentRenamedEvent.getSourceReference(), documentRenamedEvent.getTargetReference()); } } } AutomaticRedirectCreatorListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }