ScenarioResultsWriter { public static void writeLongFormat(List<ScenarioResultModel> allScenarioResults, String fileName) throws IOException { try (Writer writer = new BufferedWriter(new FileWriter(fileName))) { writeLongFormat(allScenarioResults, writer); } } private  ScenarioResultsWriter(); static void writeLongFormat(List<ScenarioResultModel> allScenarioResults, String fileName); static void writeLongFormat(List<ScenarioResultModel> allScenarioResults, Appendable appendable); static void writeShortFormat(List<ScenarioResultModel> allScenarioResults, String fileName); static void writeShortFormat(List<ScenarioResultModel> allScenarioResults, Appendable appendable);  }
@Test public void longFormat() throws IOException { List<String> expectedList = ImmutableList.of( row("ScenarioName", "ValuationTime", "Type", "Description", "PositionId", "ParamName1", "ParamValue1", "ParamName2", "ParamValue2", "ResultName", "ResultValue"), row(_scenario1Name, _valuationTime1, "FXForward", "An FX Forward", _id1, _param1Name, _param1Value1, _param2Name, _param2Value1, _res1Name, 1), row(_scenario1Name, _valuationTime1, "FXForward", "An FX Forward", _id1, _param1Name, _param1Value1, _param2Name, _param2Value1, _res2Name, 2), row(_scenario1Name, _valuationTime1, "FRA", "A FRA", _id2, _param1Name, _param1Value1, _param2Name, _param2Value1, _res1Name, 3), row(_scenario1Name, _valuationTime1, "FRA", "A FRA", _id2, _param1Name, _param1Value1, _param2Name, _param2Value1, _res2Name, 4), row(_scenario2Name, _valuationTime2, "FXForward", "An FX Forward", _id1, _param1Name, _param1Value2, _param2Name, _param2Value2, _res1Name, 5), row(_scenario2Name, _valuationTime2, "FXForward", "An FX Forward", _id1, _param1Name, _param1Value2, _param2Name, _param2Value2, _res2Name, 6), row(_scenario2Name, _valuationTime2, "FRA", "A FRA", _id2, _param1Name, _param1Value2, _param2Name, _param2Value2, _res1Name, 7), row(_scenario2Name, _valuationTime2, "FRA", "A FRA", _id2, _param1Name, _param1Value2, _param2Name, _param2Value2, _res2Name, 8)); String expected = StringUtils.join(expectedList, "\n") + "\n"; StringBuilder builder = new StringBuilder(); ScenarioResultsWriter.writeLongFormat(scenarioResults(), builder); assertEquals(expected, builder.toString()); }