### Question:
EventStreamWikiCleanerJob extends AbstractJob<EventStreamWikiCleanerJobRequest, DefaultJobStatus<EventStreamWikiCleanerJobRequest>> { @Override protected void runInternal() throws Exception { String wikiId = request.getWikiId(); List<Event> eventsToDelete = null; do { try { Query query = queryManager.createQuery("where event.wiki = :wiki", Query.HQL); query.bindValue("wiki", wikiId); query.setLimit(1024); eventsToDelete = eventStream.searchEvents(query); for (org.xwiki.eventstream.Event toDelete : eventsToDelete) { eventStream.deleteEvent(toDelete); } } catch (Exception e) { logger.error("Failed to delete events related to the deleted wiki [{}] in the event stream.", wikiId, e); } } while (eventsToDelete != null && !eventsToDelete.isEmpty()); }  @Override String getType(); static final String JOB_TYPE; }### Answer:
@Test public void run() throws Exception { Query query = mock(Query.class); when(queryManager.createQuery("where event.wiki = :wiki", Query.HQL)).thenReturn(query); Event event1 = mock(Event.class); Event event2 = mock(Event.class); Event event3 = mock(Event.class); Event event4 = mock(Event.class); when(eventStream.searchEvents(query)).thenReturn(Arrays.asList(event1, event2), Arrays.asList(event3, event4), Collections.emptyList()); EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest("someWiki"); EventStreamWikiCleanerJob job = mocker.getComponentUnderTest(); job.initialize(request); job.runInternal(); verify(eventStream).deleteEvent(event1); verify(eventStream).deleteEvent(event2); verify(eventStream).deleteEvent(event3); verify(eventStream).deleteEvent(event4); verify(query, times(3)).bindValue("wiki", "someWiki"); }