Skip to content

Use Suppliers for ValueGenerator #51

@enqueue

Description

@enqueue

We find ourselves implementing a couple of ValueGenerators when testing a bean class. This leads to boilerplate code due to anonymous classes which could be avoided by passing a Supplier. Unless this test library needs to work with Java < 1.8, of course.

Status quo:

BeanMatchers.registerValueGenerator(new ValueGenerator<Instant>() {
        public Instant generate() {
            return Instant.now();
        }
    }, Instant.class);

Using Supplier:

BeanMatchers.registerValueGenerator(Instant::now, Instant.class)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions