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));
  }
  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));
  }
Esempio n. 3
0
  /**
   * Tests that executing a function that returns a success result returns the underlying result
   * without wrapping it.
   */
  public void executeSuccessResultValue() {
    SupplierFunction<Result<String>> fn = SupplierFunction.of(() -> Result.success("foo"));
    CalculationTask task = new CalculationTask(TARGET, 0, 0, fn, MAPPINGS, REPORTING_RULES);
    CalculationEnvironment marketData =
        CalculationEnvironment.builder().valuationDate(date(2011, 3, 8)).build();

    CalculationResult calculationResult = task.execute(marketData);
    Result<?> result = calculationResult.getResult();
    assertThat(result).hasValue("foo");
  }