ExporterImpl implements Exporter { public List<File> exportReport(ExportSettings settings, List<Participant> participants, Trip trip, ResourceResolver resourceResolver, ActivityResolver activityResolver, AmountFactory amountFactory) { List<File> filesCreated = new ArrayList<>(); StringBuilder fileNamePrefix = new StringBuilder(resourceResolver.resolve(R.string.fileExportPrefix)) .append(FILE_NAME_SEPARATOR) .append(ExporterFileNameUtils.clean(trip.getName())); StringBuilder timestamp = new StringBuilder(ExporterFileNameUtils.getTimeStamp(resourceResolver.getLocale())); HtmlExportCharResolver htmlExportCharResolver = null; CsvExportCharResolver csvExportCharResolver = null; TxtExportCharResolver txtExportCharResolver = null; if (settings.isFormatHtml()) { htmlExportCharResolver = new HtmlExportCharResolver(); htmlExportCharResolver.setLang(resourceResolver.getLocale().getLanguage()); } if (settings.isFormatCsv()) { csvExportCharResolver = new CsvExportCharResolver(); } if (settings.isFormatTxt()) { txtExportCharResolver = new TxtExportCharResolver(); } if (participants.size() > 1 && settings.isSeparateFilesForIndividuals()) { ArrayList<Participant> participantsSubset; for (Participant p : participants) { participantsSubset = new ArrayList<>(1); participantsSubset.add(p); createAndWriteFiles(settings, participantsSubset, trip, resourceResolver, fileWriter, filesCreated, fileNamePrefix, timestamp, htmlExportCharResolver, csvExportCharResolver, txtExportCharResolver, amountFactory); } } else { createAndWriteFiles(settings, participants, trip, resourceResolver, fileWriter, filesCreated, fileNamePrefix, timestamp, htmlExportCharResolver, csvExportCharResolver, txtExportCharResolver, amountFactory); } StreamSender streamSender = new StreamSenderImpl(); StringBuilder exportSubject = new StringBuilder() .append(resourceResolver.resolve(R.string.fileExportEmailSubjectPrefix)) .append(SPACE) .append(trip.getName()) .append(SPACE) .append(timestamp); if (activityResolver.getActivity() != null) { List<Uri> contentUrisFromFiles = FileUtils.getContentUrisFromFiles(filesCreated, TrickyTripperFileProvider.AUTHORITY); if (settings.getOutputChannel() != null) { streamSender.sendStream( (Activity) activityResolver.getActivity(), exportSubject.toString(), resourceResolver.resolve(R.string.fileExportEmailContent), contentUrisFromFiles, settings.getOutputChannel()); } } return filesCreated; } ExporterImpl(FileWriter fileWriter); List<File> exportReport(ExportSettings settings, List<Participant> participants, Trip trip,
                                   ResourceResolver resourceResolver, ActivityResolver activityResolver, AmountFactory amountFactory);  }
@Test public void testOutputEverythingForAll() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(6, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(5).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputCsvForAll() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, false, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(4, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(3).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputHtmlForAll() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, true, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternHtmlAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTxtForAll() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, false, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternTxtAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsForAll() { ExportSettings exportSettings = createExportSettings(false, false, false, true, true, true, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(1).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersForAll() { ExportSettings exportSettings = createExportSettings(false, true, false, false, true, true, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(1).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsForAll() { ExportSettings exportSettings = createExportSettings(false, false, true, false, true, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(2).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputDebtsForAll() { ExportSettings exportSettings = createExportSettings(true, false, false, false, true, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(2).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsAndDebtsForAll() { ExportSettings exportSettings = createExportSettings(true, false, true, false, true, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(4, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(3).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersAndDebtsForAll() { ExportSettings exportSettings = createExportSettings(true, true, false, false, true, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(4, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlAll.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(3).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsAndDebtsOnlyHtmlForAll() { ExportSettings exportSettings = createExportSettings(true, false, true, false, false, true, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternHtmlAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndTransfersOnlyHtmlForAll() { ExportSettings exportSettings = createExportSettings(false, true, false, true, false, true, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternHtmlAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsAndDebtsOnlyCsvForAll() { ExportSettings exportSettings = createExportSettings(true, false, true, false, true, false, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersAndSpendingsOnlyCsvForAll() { ExportSettings exportSettings = createExportSettings(false, true, true, false, true, false, false, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(patternCsvAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvAll.matcher(result.get(1).getName()).matches()); for (File f : result) { Assert.assertTrue(nameContains(f, resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsAndDebtsOnlyTxtForAll() { ExportSettings exportSettings = createExportSettings(true, false, true, false, false, false, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternTxtAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersAndDebtsOnlyTxtForAll() { ExportSettings exportSettings = createExportSettings(true, true, false, false, false, false, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(patternTxtAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsAndDebtsHtmlAndTxtForAll() { ExportSettings exportSettings = createExportSettings(true, false, true, false, false, true, false, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(patternHtmlAll.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternTxtAll.matcher(result.get(1).getName()).matches()); Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportrFix_Scope_All))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputEverythingForAllSplit() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, true, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(18, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(8).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(9).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(10).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(11).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(12).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(13).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(14).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(15).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(16).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(17).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 5) { name = factory.chris.getName(); } else if (i <= 11) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsForAllSplit() { ExportSettings exportSettings = createExportSettings(false, false, false, true, true, true, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(9, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(8).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 2) { name = factory.chris.getName(); } else if (i <= 5) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); if (i % 3 == 0) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); } } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersForAllSplit() { ExportSettings exportSettings = createExportSettings(false, true, false, false, true, true, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(9, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(8).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 2) { name = factory.chris.getName(); } else if (i <= 5) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); if (i % 3 == 0) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); } } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndSpendingsForAllSplit() { ExportSettings exportSettings = createExportSettings(false, false, true, true, true, true, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(12, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(8).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(9).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(10).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(11).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 3) { name = factory.chris.getName(); } else if (i <= 7) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); if (i % 4 == 0) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); } else if (i % 4 == 1) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersAndSpendingsForAllSplit() { ExportSettings exportSettings = createExportSettings(false, true, true, false, true, true, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(12, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(8).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(9).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(10).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(11).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 3) { name = factory.chris.getName(); } else if (i <= 7) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); if (i % 4 == 0) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); } else if (i % 4 == 1) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndSpendingsOnlyHtmlForAllSplit() { ExportSettings exportSettings = createExportSettings(false, false, true, true, false, true, true, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(2).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i == 0) { name = factory.chris.getName(); } else if (i == 1) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndSpendingsOnlyTxtForAllSplit() { ExportSettings exportSettings = createExportSettings(false, false, true, true, false, false, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(2).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i == 0) { name = factory.chris.getName(); } else if (i == 1) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndSpendingsOnlyCsvForAllSplit() { ExportSettings exportSettings = createExportSettings(false, false, true, true, true, false, true, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(6, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(5).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 1) { name = factory.chris.getName(); } else if (i <= 3) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); if (i % 2 == 0) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); } else if (i % 2 == 1) { Assert.assertTrue(nameContains(result.get(i), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputCsvForAllSplit() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, false, true, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(12, result.size()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(2).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(3).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(4).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(5).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(6).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(7).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(8).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(9).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(10).getName()).matches()); Assert.assertTrue(patternCsvIndividual.matcher(result.get(11).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i <= 3) { name = factory.chris.getName(); } else if (i <= 7) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputHtmlForAllSplit() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, true, true, false, false); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternHtmlIndividual.matcher(result.get(2).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i == 0) { name = factory.chris.getName(); } else if (i == 1) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTxtForAllSplit() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, false, true, false, true); List<File> result = exporter.exportReport(exportSettings, tripToExport.getParticipant(), tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(0).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(1).getName()).matches()); Assert.assertTrue(patternTxtIndividual.matcher(result.get(2).getName()).matches()); for (int i = 0; i < result.size(); i++) { String name; if (i == 0) { name = factory.chris.getName(); } else if (i == 1) { name = factory.niko.getName(); } else { name = factory.wolfram.getName(); } Assert.assertTrue(nameContains(result.get(i), name)); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputEverythingForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(6, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternCsvIndividual)); Assert.assertTrue(match(result.get(2), patternCsvIndividual)); Assert.assertTrue(match(result.get(3), patternCsvIndividual)); Assert.assertTrue(match(result.get(4), patternHtmlIndividual)); Assert.assertTrue(match(result.get(5), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsForOneParticipant() { ExportSettings exportSettings = createExportSettings(false, false, false, true, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternHtmlIndividual)); Assert.assertTrue(match(result.get(2), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTransfersForOneParticipant() { ExportSettings exportSettings = createExportSettings(false, true, false, false, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternHtmlIndividual)); Assert.assertTrue(match(result.get(2), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Transfers))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputSpendingsForOneParticipant() { ExportSettings exportSettings = createExportSettings(false, false, true, false, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternHtmlIndividual)); Assert.assertTrue(match(result.get(2), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Spendings))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputDebtsForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, false, false, false, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(3, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternHtmlIndividual)); Assert.assertTrue(match(result.get(2), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndDebtsForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, false, false, true, true, true, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(4, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternCsvIndividual)); Assert.assertTrue(match(result.get(2), patternHtmlIndividual)); Assert.assertTrue(match(result.get(3), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndDebtsOnlyHtmlForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, false, false, true, false, true, false, false, false); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(match(result.get(0), patternHtmlIndividual)); Assert.assertTrue(nameContains(result.get(0), participant.getName())); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndDebtsOnlyCsvForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, false, false, true, true, false, false, false, false); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(2, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternCsvIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } Assert.assertTrue(nameContains(result.get(0), resourceResolver.resolve(R.string.fileExportPostfix_Payments))); Assert.assertTrue(nameContains(result.get(1), resourceResolver.resolve(R.string.fileExportPostfix_Debts))); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputPaymentsAndDebtsOnlyTxtForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, false, false, true, false, false, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(match(result.get(0), patternTxtIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputCsvForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, true, true, true, true, false, false, false, false); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(4, result.size()); Assert.assertTrue(match(result.get(0), patternCsvIndividual)); Assert.assertTrue(match(result.get(1), patternCsvIndividual)); Assert.assertTrue(match(result.get(2), patternCsvIndividual)); Assert.assertTrue(match(result.get(3), patternCsvIndividual)); for (File f : result) { Assert.assertTrue(nameContains(f, participant.getName())); } } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputHtmlForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, true, false, false, false); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(match(result.get(0), patternHtmlIndividual)); Assert.assertTrue(nameContains(result.get(0), participant.getName())); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }
@Test public void testOutputTxtForOneParticipant() { ExportSettings exportSettings = createExportSettings(true, true, true, true, false, false, false, false, true); List<Participant> participants = new ArrayList<>(); participants.add(participant); List<File> result = exporter.exportReport(exportSettings, participants, tripToExport, resourceResolver, new ActivityResolver() { @Override public Object getActivity() { return null; } }, amountFactory); Throwable exceptionCaught = null; try { Assert.assertEquals(1, result.size()); Assert.assertTrue(match(result.get(0), patternTxtIndividual)); Assert.assertTrue(nameContains(result.get(0), participant.getName())); } catch (Exception e) { exceptionCaught = e; } finally { deleteCreatedFiles(result); } if (exceptionCaught != null) { throw new RuntimeException(exceptionCaught); } }