I have added a new querydsl controller method in my spring (not spring boot) application.
@GetMapping("/watcher")
@ResponseBody
public List<Watcher> getWatchers(final Predicate predicate) {
return repo.findAll(predicate);
}
I have also added the following annotation in my WebMvcConfigurer implementation:
@EnableSpringDataWebSupport
The application works with this new endpoint as intented. I would now like to add a Spring IT test to test this new feature.
This is the test:
@Test
public void test() {
mvc.perform(get("/watcher"));
}
The test class contains the following annotations:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringITConfig.class)
@WebAppConfiguration
Other tests are present in the same class, and perform() works for those, but it's the first time I'm adding a test to a querydsl controller.
The test fails with No primary or default constructor found for interface com.querydsl.core.types.Predicate
.
I tried adding the annotation @EnableSpringDataWebSupport
to my test, but it doesn't change anything.
What am I missing ?
Thanks
Try removing your
@ContextConfiguration
and replace it with@SpringApplicationConfiguration(classes = YOUR_MAIN_APP_CLASS)
to bootstrap all the needed querydsl repositories, and also the correct jackson mapper for your predicate class.