### Question:
TradeReportFormatter extends ReportFormatter<TradeReport> { @Override protected List<Class<?>> getColumnTypes(TradeReport report) { return IntStream.range(0, report.getColumnCount()) .mapToObj(columnIndex -> columnType(report, columnIndex)) .collect(toImmutableList()); } private  TradeReportFormatter();  static final TradeReportFormatter INSTANCE; }### Answer:
@Test public void getColumnTypes() { ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(INDICES, INDICES); table.put(0, 0, Result.success(1)); table.put(0, 1, Result.success("abc")); table.put(1, 0, Result.success(2)); table.put(1, 1, Result.success("def")); List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table)); assertThat(columnTypes).isEqualTo(ImmutableList.of(Integer.class, String.class)); }
@Test public void getColumnTypesWithSomeFailures() { ImmutableList<Integer> indices = ImmutableList.of(0, 1); ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(indices, indices); table.put(0, 0, Result.failure(FailureReason.ERROR, "fail")); table.put(0, 1, Result.failure(FailureReason.ERROR, "fail")); table.put(1, 0, Result.success(2)); table.put(1, 1, Result.success("def")); List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table)); assertThat(columnTypes).isEqualTo(ImmutableList.of(Integer.class, String.class)); }
@Test public void getColumnTypesWithAllFailures() { ImmutableList<Integer> indices = ImmutableList.of(0, 1); ArrayTable<Integer, Integer, Result<?>> table = ArrayTable.create(indices, indices); table.put(0, 0, Result.failure(FailureReason.ERROR, "fail")); table.put(0, 1, Result.failure(FailureReason.ERROR, "fail")); table.put(1, 0, Result.failure(FailureReason.ERROR, "fail")); table.put(1, 1, Result.failure(FailureReason.ERROR, "fail")); List<Class<?>> columnTypes = TradeReportFormatter.INSTANCE.getColumnTypes(report(table)); assertThat(columnTypes).isEqualTo(ImmutableList.of(Object.class, Object.class)); }