Dominik
Dominik

Reputation: 1431

Instancio: always getting "Unused selectors in generate(), set(), or supply()"

I would like to generate customizable test data using instancio. This is my POJO:

@Data
public class MyPojo {
    private Integer id;
    private LocalDate modifiedAt;
    private String modifiedBy;
}

The test data are produced with this method:

public List<MyPojo> dummyData() {
        return Instancio.ofList(MyPojo.class)
            .size(100)
            .generate(field(MyPojo::getId), gen -> gen.ints().range(1,100))
            .generate(field(MyPojo::getModifiedAt), gen -> gen.temporal().localDate().past())
            .generate(set(MyPojo::getModifiedBy), "static value")
            .create();
    }

This leads always to the error Unused selectors in generate(), set(), or supply() for every selector used in the example above. One solution is to use .lenient() but after that, all my customizations are ignored.

The example from https://github.com/instancio/instancio-quickstart/blob/main/src/test/java/org/example/Instancio4CollectionsTest.java runs properly and I don't see any differences to my code.

How can I fix my problem ?

Upvotes: 1

Views: 895

Answers (0)

Related Questions