@Test public void onEvent() throws Exception { doAnswer(invocationOnMock -> { EventStreamWikiCleanerJobRequest request = invocationOnMock.getArgument(1); assertEquals("someWiki", request.getWikiId()); assertEquals(Arrays.asList("EventStreamWikiCleanerJob", "someWiki"), request.getId()); return null; }).when(jobExecutor).execute(eq("EventStreamWikiCleanerJob"), any(EventStreamWikiCleanerJobRequest.class)); WikiDeletedEvent wikiDeletedEvent = new WikiDeletedEvent("someWiki"); mocker.getComponentUnderTest().onEvent(wikiDeletedEvent, null, null); EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest("someWiki"); request.setId(Arrays.asList("EventStreamWikiCleanerJob", "someWiki")); verify(jobExecutor).execute(eq("EventStreamWikiCleanerJob"), any(EventStreamWikiCleanerJobRequest.class)); }
@Override public void onEvent(Event event, Object source, Object data) { WikiDeletedEvent wikiDeletedEvent = (WikiDeletedEvent) event; try { EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest( wikiDeletedEvent.getWikiId()); request.setId(Arrays.asList(EventStreamWikiCleanerJob.JOB_TYPE, wikiDeletedEvent.getWikiId())); jobExecutor.execute(EventStreamWikiCleanerJob.JOB_TYPE, request); } catch (Exception e) { logger.error("Failed to start a job [EventStreamWikiCleanerJob] for the deleted wiki [{}]", wikiDeletedEvent.getWikiId(), e); } }
WikiDeletedListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { WikiDeletedEvent wikiDeletedEvent = (WikiDeletedEvent) event; try { EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest( wikiDeletedEvent.getWikiId()); request.setId(Arrays.asList(EventStreamWikiCleanerJob.JOB_TYPE, wikiDeletedEvent.getWikiId())); jobExecutor.execute(EventStreamWikiCleanerJob.JOB_TYPE, request); } catch (Exception e) { logger.error("Failed to start a job [EventStreamWikiCleanerJob] for the deleted wiki [{}]", wikiDeletedEvent.getWikiId(), e); } } }
WikiDeletedListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { WikiDeletedEvent wikiDeletedEvent = (WikiDeletedEvent) event; try { EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest( wikiDeletedEvent.getWikiId()); request.setId(Arrays.asList(EventStreamWikiCleanerJob.JOB_TYPE, wikiDeletedEvent.getWikiId())); jobExecutor.execute(EventStreamWikiCleanerJob.JOB_TYPE, request); } catch (Exception e) { logger.error("Failed to start a job [EventStreamWikiCleanerJob] for the deleted wiki [{}]", wikiDeletedEvent.getWikiId(), e); } } WikiDeletedListener(); }
WikiDeletedListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { WikiDeletedEvent wikiDeletedEvent = (WikiDeletedEvent) event; try { EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest( wikiDeletedEvent.getWikiId()); request.setId(Arrays.asList(EventStreamWikiCleanerJob.JOB_TYPE, wikiDeletedEvent.getWikiId())); jobExecutor.execute(EventStreamWikiCleanerJob.JOB_TYPE, request); } catch (Exception e) { logger.error("Failed to start a job [EventStreamWikiCleanerJob] for the deleted wiki [{}]", wikiDeletedEvent.getWikiId(), e); } } WikiDeletedListener(); @Override void onEvent(Event event, Object source, Object data); }
WikiDeletedListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { WikiDeletedEvent wikiDeletedEvent = (WikiDeletedEvent) event; try { EventStreamWikiCleanerJobRequest request = new EventStreamWikiCleanerJobRequest( wikiDeletedEvent.getWikiId()); request.setId(Arrays.asList(EventStreamWikiCleanerJob.JOB_TYPE, wikiDeletedEvent.getWikiId())); jobExecutor.execute(EventStreamWikiCleanerJob.JOB_TYPE, request); } catch (Exception e) { logger.error("Failed to start a job [EventStreamWikiCleanerJob] for the deleted wiki [{}]", wikiDeletedEvent.getWikiId(), e); } } WikiDeletedListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }