public static <T, K, U> AggregateOperation1<T, Map<K, U>, Map<K, U>> toMap(
            FunctionEx<? super T, ? extends K> keyFn,
            FunctionEx<? super T, ? extends U> valueFn
    ) {
        checkSerializable(keyFn, "keyFn");
        checkSerializable(valueFn, "valueFn");
        return toMap(keyFn, valueFn,
                (k, v) -> {
                    throw new IllegalStateException("Duplicate key: " + k);
                },
                HashMap::new);
    }
@Test
    public void when_toMapDuplicateAccumulate_then_exception() {
        AggregateOperation1<Entry<Integer, Integer>, Map<Integer, Integer>, Map<Integer, Integer>> op =
                toMap(Entry::getKey, Entry::getValue);

        Map<Integer, Integer> acc = op.createFn().get();
        BiConsumerEx<? super Map<Integer, Integer>, ? super Entry<Integer, Integer>> biConsumerEx = op.accumulateFn();
        biConsumerEx.accept(acc, entry(1, 1));

        Entry<Integer, Integer> entry = entry(1, 2);
        assertThrows(IllegalStateException.class, () -> biConsumerEx.accept(acc, entry));
    }