### Question:
FunctionUtils { public static <T> Collector<T, List<T>, ScenarioArray<T>> toScenarioArray() { return Collector.of( ArrayList<T>::new, (a, b) -> a.add(b), (l, r) -> { l.addAll(r); return l; }, list -> buildResult(list)); } private  FunctionUtils(); static Collector<T, List<T>, ScenarioArray<T>> toScenarioArray(); static Collector<MultiCurrencyAmount, List<MultiCurrencyAmount>, MultiCurrencyScenarioArray> toMultiCurrencyValuesArray(); static Collector<CurrencyAmount, List<CurrencyAmount>, CurrencyScenarioArray> toCurrencyValuesArray(); static Collector<Double, List<Double>, DoubleScenarioArray> toValuesArray(); static void duplicateResult(Measure existingKey, Measure newKey, Map<Measure, Result<?>> mutableMeasureMap);  }### Answer:
@Test public void toScenarioArray() { List<CurrencyAmount> amounts = ImmutableList.of( CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.USD, 2)); ScenarioArray<CurrencyAmount> expectedResult = ScenarioArray.of(amounts); ScenarioArray<CurrencyAmount> result = amounts.stream().collect(FunctionUtils.toScenarioArray()); assertThat(result).isEqualTo(expectedResult); }
@Test public void toScenarioArray2() { List<MultiCurrencyAmount> amounts = ImmutableList.of( MultiCurrencyAmount.of(Currency.GBP, 1), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.USD, 2), CurrencyAmount.of(Currency.GBP, 3))); ScenarioArray<MultiCurrencyAmount> expectedResult = ScenarioArray.of(amounts); ScenarioArray<MultiCurrencyAmount> result = amounts.stream().collect(FunctionUtils.toScenarioArray()); assertThat(result).isEqualTo(expectedResult); }