### Question:
ReportExporterAction extends FormAction { public Event exportOptions(RequestContext context) throws Exception{ MutableAttributeMap flowScope = context.getFlowScope(); String type = getExporterType(context); if (!configuredExporters.containsKey(type)) { throw new JSException(messageSource.getMessage( EXPORT_TYPE_NOT_SUPPORTED_MESSAGE_KEY, new String[]{getSupportedExportTypesAsString()}, LocaleContextHolder.getLocale())); } flowScope.put(ReportExporterAction.EXPORTER_TYPE, type); ExporterConfigurationBean exporterConfiguration = (ExporterConfigurationBean)getConfiguredExporters().get(type); if(type!= null && StringUtils.isNotEmpty(exporterConfiguration.getParameterDialogName())){ exportParameters=exporterConfiguration.getExportParameters(); String parameterDialogName = exporterConfiguration.getParameterDialogName(); setFormObjectClass(exportParameters.getClass()); setFormObjectName(parameterDialogName); setFormObjectScope(ScopeType.FLOW); if(configuration.isReportLevelConfigurable()){ flowScope.put(ReportExporterAction.PARAMETER_DIALOG_NAME, parameterDialogName); ExportParameters formObject = (ExportParameters) getFormObject(context); formObject.setOverrideReportHints(true); context.getRequestScope().put(parameterDialogName, formObject); flowScope.put(ReportExporterAction.REPORT_EXPORT_OPTION, ReportExporterAction.REPORT_EXPORT_PARAMS); }else{ flowScope.put(parameterDialogName, getFormObject(context)); flowScope.put(ReportExporterAction.REPORT_EXPORT_OPTION, ReportExporterAction.REPORT_EXPORT); } }else{ flowScope.put(ReportExporterAction.REPORT_EXPORT_OPTION, ReportExporterAction.REPORT_EXPORT); } return success(); }  Event exportStart(RequestContext context); Event exportOptions(RequestContext context); void export(RequestContext context); Map getConfiguredExporters(); void setConfiguredExporters(Map configuredExporters); Object getExportParameters(); void setExportParameters(Object exportParameters); Object createFormObject(RequestContext context); ReportEngineConfiguration getConfiguration(); void setConfiguration(ReportEngineConfiguration configuration); MessageSource getMessageSource(); void setMessageSource(MessageSource messageSource); ViewReportAction getViewReportAction(); void setViewReportAction(ViewReportAction viewReportAction); static final String REPORT_EXPORT; static final String REPORT_EXPORT_PARAMS; static final String REPORT_EXPORT_OPTION; static final String PARAMETER_DIALOG_NAME; static final String OUTPUT; static final String REPORT_OUTPUT; static final String EXPORTER_TYPE; static final String EXPORT_TYPE_NOT_SUPPORTED_MESSAGE_KEY; }### Answer:
@Test(expected = JSException.class) public void ensureExceptionThrownWhenExportTypeNotSupported() throws Exception{ when(messageSource.getMessage( eq(ReportExporterAction.EXPORT_TYPE_NOT_SUPPORTED_MESSAGE_KEY), any(), any())).thenReturn("Exception message"); when(configuredExporters.containsKey("xml")).thenReturn(false); when(configuredExporters.keySet()).thenReturn(new HashSet()); when(parameterMapMock.get(ReportExporterAction.OUTPUT)).thenReturn("xml"); when(requestContextMock.getRequestParameters()).thenReturn(parameterMapMock); reportExporterAction.exportOptions(requestContextMock); }