@Test public void convertEventToLegacyActivity() throws Exception { WikiReference wikiReference = new WikiReference("xwiki"); DocumentReference documentReference = new DocumentReference("xwiki", "Some", "Page"); DocumentReference useReference = new DocumentReference("xwiki", "XWiki", "User"); Set<String> target = new HashSet<>(); target.add("xwiki:XWiki.Target"); Event event = mock(Event.class); when(event.getImportance()).thenReturn(Event.Importance.MAJOR); when(event.getApplication()).thenReturn("app"); when(event.getBody()).thenReturn("body"); when(event.getDate()).thenReturn(new Date(10)); when(event.getId()).thenReturn("eventId"); when(event.getWiki()).thenReturn(wikiReference); when(event.getDocument()).thenReturn(documentReference); when(compactSerializer.serialize(documentReference, wikiReference)).thenReturn("Some.Page"); when(event.getDocumentTitle()).thenReturn("docTitle"); when(event.getGroupId()).thenReturn("groupId"); when(event.getSpace()).thenReturn(documentReference.getLastSpaceReference()); when(event.getStream()).thenReturn("stream"); when(event.getTitle()).thenReturn("title"); when(event.getType()).thenReturn("type"); when(event.getUrl()).thenReturn(new URL("http: when(event.getUser()).thenReturn(useReference); when(event.getDocumentVersion()).thenReturn("10.2"); when(event.getTarget()).thenReturn(target); when(event.getHidden()).thenReturn(true); DocumentReference relatedEntity = new DocumentReference("xwiki", "Related", "Entity"); when(event.getRelatedEntity()).thenReturn(relatedEntity); when(serializer.serialize(relatedEntity)).thenReturn("xwiki:Related.Entity"); when(compactSerializer.serialize(documentReference.getLastSpaceReference(), wikiReference)).thenReturn("Some"); when(serializer.serialize(useReference)).thenReturn("xwiki:XWiki.User"); when(serializer.serialize(wikiReference)).thenReturn("xwiki"); LegacyEvent result = legacyEventConverter.convertEventToLegacyActivity(event); assertNotNull(result); assertEquals(40, result.getPriority()); assertEquals("app", result.getApplication()); assertEquals("body", result.getBody()); assertEquals(new Date(10), result.getDate()); assertEquals("eventId", result.getEventId()); assertEquals("Some.Page", result.getPage()); assertEquals("docTitle", result.getParam1()); assertEquals("xwiki:Related.Entity", result.getParam2()); assertEquals("groupId", result.getRequestId()); assertEquals("Some", result.getSpace()); assertEquals("stream", result.getStream()); assertEquals("title", result.getTitle()); assertEquals("type", result.getType()); assertEquals("http: assertEquals("xwiki:XWiki.User", result.getUser()); assertEquals("10.2", result.getVersion()); assertEquals("xwiki", result.getWiki()); assertEquals(target, result.getTarget()); assertTrue(result.isHidden()); }
@Override public LegacyEvent convertEventToLegacyActivity(Event e) { LegacyEventConverter converter = this.getConverterForType(e.getType()); LegacyEvent result; if (converter == null) { result = super.convertEventToLegacyActivity(e); } else { result = converter.convertEventToLegacyActivity(e); } return result; }
DefaultLegacyEventConverter extends AbstractLegacyEventConverter { @Override public LegacyEvent convertEventToLegacyActivity(Event e) { LegacyEventConverter converter = this.getConverterForType(e.getType()); LegacyEvent result; if (converter == null) { result = super.convertEventToLegacyActivity(e); } else { result = converter.convertEventToLegacyActivity(e); } return result; } }
DefaultLegacyEventConverter extends AbstractLegacyEventConverter { @Override public LegacyEvent convertEventToLegacyActivity(Event e) { LegacyEventConverter converter = this.getConverterForType(e.getType()); LegacyEvent result; if (converter == null) { result = super.convertEventToLegacyActivity(e); } else { result = converter.convertEventToLegacyActivity(e); } return result; }  }
DefaultLegacyEventConverter extends AbstractLegacyEventConverter { @Override public LegacyEvent convertEventToLegacyActivity(Event e) { LegacyEventConverter converter = this.getConverterForType(e.getType()); LegacyEvent result; if (converter == null) { result = super.convertEventToLegacyActivity(e); } else { result = converter.convertEventToLegacyActivity(e); } return result; }  @Override LegacyEvent convertEventToLegacyActivity(Event e); @Override Event convertLegacyActivityToEvent(LegacyEvent e); @Override LegacyEventStatus convertEventStatusToLegacyActivityStatus(EventStatus eventStatus); @Override EventStatus convertLegacyActivityStatusToEventStatus(LegacyEventStatus eventStatus); }
DefaultLegacyEventConverter extends AbstractLegacyEventConverter { @Override public LegacyEvent convertEventToLegacyActivity(Event e) { LegacyEventConverter converter = this.getConverterForType(e.getType()); LegacyEvent result; if (converter == null) { result = super.convertEventToLegacyActivity(e); } else { result = converter.convertEventToLegacyActivity(e); } return result; }  @Override LegacyEvent convertEventToLegacyActivity(Event e); @Override Event convertLegacyActivityToEvent(LegacyEvent e); @Override LegacyEventStatus convertEventStatusToLegacyActivityStatus(EventStatus eventStatus); @Override EventStatus convertLegacyActivityStatusToEventStatus(LegacyEventStatus eventStatus);  }