computerluca / lambdaj

Automatically exported from code.google.com/p/lambdaj
1 stars 0 forks source link

LambdaList.forEach(Matcher) Exception points to inexistent overloaded method for empty match #106

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
java.lang.IllegalArgumentException: forEach() is unable to introspect on an 
empty iterator. Use the overloaded method accepting a class instead

What steps will reproduce the problem?

Given a class Person with attribute name:

    @Test
    public void testForEachWithEmptyList() {
        List<Person> persons = Collections.emptyList();
        with(persons).forEach(having(on(Person.class).getName(), isEmptyString()))
                     .setName("Smith");
    }

    @Test
    public void testForEachMatcherWithoutMatch() {
        List<Person> persons = asList(aPerson().withName("Miller"));
        with(persons).forEach(having(on(Person.class).getName(), isEmptyString()))
                     .setName("Smith");
    }

What is the expected output? What do you see instead?
For an empty list or an empty match, forEach should not throw an exception, but 
do nothing. Or the overloaded method mentioned by the exception should be added.

What version of the product are you using? On what operating system?
2.3.3

Please provide any additional information below.

Original issue reported on code.google.com by dietrich...@gmail.com on 27 Mar 2013 at 7:40