@Test void onEvent() throws Exception { this.likeEventListener.onEvent(null, null, null); verify(this.observationManager, never()).notify(any(), any()); EntityReference entityReference = new DocumentReference("xwiki", "Foo", "Page"); DocumentModelBridge documentModelBridge = mock(DocumentModelBridge.class); when(this.documentAccessBridge.getDocumentInstance(entityReference)).thenReturn(documentModelBridge); this.likeEventListener.onEvent(new LikeEvent(), null, entityReference); verify(this.observationManager).notify(eq(new LikeRecordableEvent()), eq(LikeEventDescriptor.EVENT_SOURCE), eq(documentModelBridge)); }
@Override public void onEvent(Event event, Object source, Object data) { if (data != null) { EntityReference likedEntity = (EntityReference) data; try { DocumentModelBridge documentInstance = this.documentAccessBridge.getDocumentInstance(likedEntity); this.observationManager.notify(new LikeRecordableEvent(), LikeEventDescriptor.EVENT_SOURCE, documentInstance); } catch (Exception e) { this.logger.error("Error while sending event about like on [{}]", likedEntity, e); } } }
LikeEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (data != null) { EntityReference likedEntity = (EntityReference) data; try { DocumentModelBridge documentInstance = this.documentAccessBridge.getDocumentInstance(likedEntity); this.observationManager.notify(new LikeRecordableEvent(), LikeEventDescriptor.EVENT_SOURCE, documentInstance); } catch (Exception e) { this.logger.error("Error while sending event about like on [{}]", likedEntity, e); } } } }
LikeEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (data != null) { EntityReference likedEntity = (EntityReference) data; try { DocumentModelBridge documentInstance = this.documentAccessBridge.getDocumentInstance(likedEntity); this.observationManager.notify(new LikeRecordableEvent(), LikeEventDescriptor.EVENT_SOURCE, documentInstance); } catch (Exception e) { this.logger.error("Error while sending event about like on [{}]", likedEntity, e); } } } LikeEventListener(); }
LikeEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (data != null) { EntityReference likedEntity = (EntityReference) data; try { DocumentModelBridge documentInstance = this.documentAccessBridge.getDocumentInstance(likedEntity); this.observationManager.notify(new LikeRecordableEvent(), LikeEventDescriptor.EVENT_SOURCE, documentInstance); } catch (Exception e) { this.logger.error("Error while sending event about like on [{}]", likedEntity, e); } } } LikeEventListener(); @Override void onEvent(Event event, Object source, Object data); }
LikeEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (data != null) { EntityReference likedEntity = (EntityReference) data; try { DocumentModelBridge documentInstance = this.documentAccessBridge.getDocumentInstance(likedEntity); this.observationManager.notify(new LikeRecordableEvent(), LikeEventDescriptor.EVENT_SOURCE, documentInstance); } catch (Exception e) { this.logger.error("Error while sending event about like on [{}]", likedEntity, e); } } } LikeEventListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }