### Question:
ReportOptionsUseCase { public ReportOption createReportOption(String reportUri, String optionLabel, List<ReportParameter> parameters, boolean overwrite) throws ServiceException { try { ReportOptionEntity entity = mReportOptionRestApi.createReportOption(reportUri, optionLabel, parameters, overwrite); return mReportOptionMapper.transform(entity); } catch (HttpException e) { throw mExceptionMapper.transform(e); } catch (IOException e) { throw mExceptionMapper.transform(e); } } ReportOptionsUseCase(ServiceExceptionMapper exceptionMapper, ReportOptionRestApi reportOptionRestApi, ReportOptionMapper reportOptionMapper); Set<ReportOption> requestReportOptionsList(String reportUnitUri); ReportOption createReportOption(String reportUri,
                                           String optionLabel,
                                           List<ReportParameter> parameters,
                                           boolean overwrite); void updateReportOption(String reportUri, String optionId, List<ReportParameter> parameters); void deleteReportOption(String reportUri, String optionId);  }### Answer:
@Test public void should_create_report_option() throws Exception { reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); verify(mReportOptionMapper).transform(any(ReportOptionEntity.class)); verify(mReportOptionRestApi).createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); }
@Test public void create_report_option_adapts_io_exception() throws Exception { when(mReportOptionRestApi.createReportOption(anyString(), anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mIOException); try { reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); fail("Should adapt IO exception"); } catch (ServiceException ex) { verify(mExceptionMapper).transform(mIOException); } }
@Test public void create_report_option_adapts_http_exception() throws Exception { when(mReportOptionRestApi.createReportOption(anyString(), anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mHttpException); try { reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); fail("Should adapt HTTP exception"); } catch (ServiceException ex) { verify(mExceptionMapper).transform(mHttpException); } }