On Mon, 23 Aug 2021 at 15:51, <[email protected]> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> ggregory pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-lang.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new be5ff9f  Add BooleanConsumer.
> be5ff9f is described below
>
> commit be5ff9f9c1dad2067cd6971931d7361f928cd23e
> Author: Gary Gregory <[email protected]>
> AuthorDate: Mon Aug 23 10:51:10 2021 -0400
>
>     Add BooleanConsumer.
> ---
>  src/changes/changes.xml                            |  1 +
>  .../commons/lang3/function/BooleanConsumer.java    | 68
> ++++++++++++++++++++++
>  .../lang3/function/BooleanConsumerTest.java        | 61
> +++++++++++++++++++
>  3 files changed, 130 insertions(+)
>
>
<-- SNIP -->


> +
> +    @Test
> +    public void testAndThen() throws Throwable {
> +        final BooleanConsumer nop = BooleanConsumer.nop();
> +        nop.andThen(nop);
> +        // Documented in Javadoc edge-case.
> +        assertThrows(NullPointerException.class, () -> nop.andThen(null));
> +        //
> +        final AtomicBoolean aBool1 = new AtomicBoolean();
> +        final AtomicBoolean aBool2 = new AtomicBoolean();
> +        accept(aBool1::lazySet, true).andThen(aBool2::lazySet);
> +        accept(aBool1::lazySet, true);
> +        accept(aBool2::lazySet, true);
>

This is not actually asserting the lambda function returned from the
andThen method.

Surely you should be testing what is returned from 'andThen', e.g.

BooleanConsumer bc = aBool1::lazySet;
BooleanConsumer composite = bc.andThen(aBool2::lazySet);

composite.accept(true);
assertTrue(aBool1.get());
assertTrue(aBool2.get());

composite.accept(false);
assertFalse(aBool1.get());
assertFalse(aBool2.get());

Reply via email to