TsvGeneResultsWriter implements ResultsWriter { @Override public String writeString(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings) { StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter printer = new CSVPrinter(stringBuilder, format)) { writeData(modeOfInheritance, analysisResults, printer); } catch (IOException ex) { logger.error("Unable to write results to string {}", stringBuilder, ex); } return stringBuilder.toString(); } TsvGeneResultsWriter(); @Override void writeFile(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings); @Override String writeString(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings);  }
@Test public void testWriteString() { OutputSettings settings = OutputSettings.builder() .outputFormats(EnumSet.of(OutputFormat.TSV_GENE)) .build(); String outString = instance.writeString(ModeOfInheritance.AUTOSOMAL_DOMINANT, analysis, analysisResults, settings); assertThat(outString, equalTo(HEADER + FGFR2_GENE_STRING + RBM8A_GENE_STRING)); }
@Test public void testWriteStringStartsWithAHeaderLine() { OutputSettings settings = OutputSettings.builder() .outputFormats(EnumSet.of(OutputFormat.TSV_GENE)) .build(); String outString = instance.writeString(ModeOfInheritance.AUTOSOMAL_DOMINANT, analysis, analysisResults, settings); String[] lines = outString.split("\n"); assertThat(lines[0] + "\n", equalTo(HEADER)); }