### Question:
LESSExportActionListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiContext xcontext = (XWikiContext) data; XWikiRequest request = xcontext.getRequest(); String format = request.get("format"); if ("html".equals(format)) { lessContext.setHtmlExport(true); } }  @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data);  }### Answer:
@Test public void onEventWhenHTMLExport() throws Exception { XWikiContext xcontext = mock(XWikiContext.class); XWikiRequest request = mock(XWikiRequest.class); when(xcontext.getRequest()).thenReturn(request); when(request.get("format")).thenReturn("html"); this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext); LESSContext lessContext = mocker.getInstance(LESSContext.class); verify(lessContext).setHtmlExport(true); }
@Test public void onEventWhenNonHTMLExport() throws Exception { XWikiContext xcontext = mock(XWikiContext.class); XWikiRequest request = mock(XWikiRequest.class); when(xcontext.getRequest()).thenReturn(request); when(request.get("format")).thenReturn("xar"); this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext); LESSContext lessContext = mocker.getInstance(LESSContext.class); verifyZeroInteractions(lessContext); }