### Question:
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();  }### Answer:
@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()); }
@Test public void convertDocumentEvent() throws Exception { RecordableEvent recordableEvent = new MockedRecordableEvent(); XWikiDocument doc = mock(XWikiDocument.class); DocumentReference documentReference = new DocumentReference("xwiki", "Some", "Doc"); when(doc.getDocumentReference()).thenReturn(documentReference); when(doc.getVersion()).thenReturn("5.1"); when(doc.getRenderedTitle(any(XWikiContext.class))).thenReturn("Some title"); Event result = mocker.getComponentUnderTest().convert(recordableEvent, "source", doc); 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()); assertNull(result.getBody()); assertEquals(TARGETS, result.getTarget()); assertEquals(documentReference, result.getDocument()); assertEquals("5.1", result.getDocumentVersion()); assertEquals("Some title", result.getDocumentTitle()); }