Count true values in list

This example will count number of boolean true values in an arraylist by calling Iterable.count passing true as a parameter values. A related example of showing how to count false values from arraylist in java.

@Test
void count_boolean_in_arraylist() {

    def occurrences = [
        true,
        false,
        true,
        false,
        false
    ].count (true)

    assert 2, occurrences
}