@Test public void convert() throws Exception { RecordableEvent recordableEvent = new MockedRecordableEvent(); Event result = mocker.getComponentUnderTest().convert(recordableEvent, "source", "some data"); assertEquals("org.xwiki.eventstream.internal.DefaultRecordableEventConverterTest.MockedRecordableEvent", result.getType()); assertEquals("source", result.getApplication()); assertNotNull(result.getDate()); assertEquals(CURRENT_USER, result.getUser()); assertEquals(CURRENT_WIKI, result.getWiki()); assertEquals("some data", result.getBody()); assertEquals(TARGETS, result.getTarget()); }
@Override public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception { XWikiContext context = contextProvider.get(); Event convertedEvent = new DefaultEvent(); convertedEvent.setType(recordableEvent.getClass().getCanonicalName()); convertedEvent.setApplication(source); convertedEvent.setDate(new Date()); convertedEvent.setUser(context.getUserReference()); convertedEvent.setWiki(context.getWikiReference()); if (recordableEvent instanceof TargetableEvent) { convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget()); } if (data instanceof String) { convertedEvent.setBody((String) data); } else if (data instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) data; convertedEvent.setDocument(document.getDocumentReference()); convertedEvent.setDocumentVersion(document.getVersion()); convertedEvent.setDocumentTitle(document.getRenderedTitle(context)); } return convertedEvent; }
DefaultRecordableEventConverter implements RecordableEventConverter { @Override public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception { XWikiContext context = contextProvider.get(); Event convertedEvent = new DefaultEvent(); convertedEvent.setType(recordableEvent.getClass().getCanonicalName()); convertedEvent.setApplication(source); convertedEvent.setDate(new Date()); convertedEvent.setUser(context.getUserReference()); convertedEvent.setWiki(context.getWikiReference()); if (recordableEvent instanceof TargetableEvent) { convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget()); } if (data instanceof String) { convertedEvent.setBody((String) data); } else if (data instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) data; convertedEvent.setDocument(document.getDocumentReference()); convertedEvent.setDocumentVersion(document.getVersion()); convertedEvent.setDocumentTitle(document.getRenderedTitle(context)); } return convertedEvent; } }
DefaultRecordableEventConverter implements RecordableEventConverter { @Override public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception { XWikiContext context = contextProvider.get(); Event convertedEvent = new DefaultEvent(); convertedEvent.setType(recordableEvent.getClass().getCanonicalName()); convertedEvent.setApplication(source); convertedEvent.setDate(new Date()); convertedEvent.setUser(context.getUserReference()); convertedEvent.setWiki(context.getWikiReference()); if (recordableEvent instanceof TargetableEvent) { convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget()); } if (data instanceof String) { convertedEvent.setBody((String) data); } else if (data instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) data; convertedEvent.setDocument(document.getDocumentReference()); convertedEvent.setDocumentVersion(document.getVersion()); convertedEvent.setDocumentTitle(document.getRenderedTitle(context)); } return convertedEvent; }  }
DefaultRecordableEventConverter implements RecordableEventConverter { @Override public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception { XWikiContext context = contextProvider.get(); Event convertedEvent = new DefaultEvent(); convertedEvent.setType(recordableEvent.getClass().getCanonicalName()); convertedEvent.setApplication(source); convertedEvent.setDate(new Date()); convertedEvent.setUser(context.getUserReference()); convertedEvent.setWiki(context.getWikiReference()); if (recordableEvent instanceof TargetableEvent) { convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget()); } if (data instanceof String) { convertedEvent.setBody((String) data); } else if (data instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) data; convertedEvent.setDocument(document.getDocumentReference()); convertedEvent.setDocumentVersion(document.getVersion()); convertedEvent.setDocumentTitle(document.getRenderedTitle(context)); } return convertedEvent; }  @Override Event convert(RecordableEvent recordableEvent, String source, Object data); @Override List<RecordableEvent> getSupportedEvents(); }
DefaultRecordableEventConverter implements RecordableEventConverter { @Override public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception { XWikiContext context = contextProvider.get(); Event convertedEvent = new DefaultEvent(); convertedEvent.setType(recordableEvent.getClass().getCanonicalName()); convertedEvent.setApplication(source); convertedEvent.setDate(new Date()); convertedEvent.setUser(context.getUserReference()); convertedEvent.setWiki(context.getWikiReference()); if (recordableEvent instanceof TargetableEvent) { convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget()); } if (data instanceof String) { convertedEvent.setBody((String) data); } else if (data instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) data; convertedEvent.setDocument(document.getDocumentReference()); convertedEvent.setDocumentVersion(document.getVersion()); convertedEvent.setDocumentTitle(document.getRenderedTitle(context)); } return convertedEvent; }  @Override Event convert(RecordableEvent recordableEvent, String source, Object data); @Override List<RecordableEvent> getSupportedEvents();  }