Сущность: < /p>
Код: Выделить всё
class SimpleEntity{
@Id
int id;
String name;
}
< /code>
Связанный репозиторий: < /p>
class SimpleEntityRepository extends JpaRepository{
Slice findByName(String name, Pageable pageable);
}
< /code>
Связанная служба: < /p>
class SimpleEntityService{
@Autowired
SimpleEntityRepository repository;
public Mono findByName(String name, Pageable pageable){
//All business logic excluded
return Mono.just(
repository.findByName(name, pageable);
);
}
}
< /code>
Связанный контроллер: < /p>
class SimpleEntityController{
@Autowired
SimpleEntityService service;
@RequestMapping("/some-mapping")
public Mono findByName(@Requestparam String name, int pageNum){
return service.findByName(name, Pageable.of(pageNum, 100));
}
}
< /code>
Теперь, в моих тестах на интеграции, я пытаюсь нажать контроллер, используя WebTestClient, но я не могу понять, как я могу получить и починить ответ: < /p>
@Test
public void someIntegrationTest(){
WebTestClient.ResponseSpec responseSpec = webTestClient.get()
.uri(URI)
.accept(MediaType.APPLICATION_JSON)
.exchange();
responseSpec.returnResult(SliceImpl.class).getResponseBody.blockFirst();
}
< /code>
Последняя строка бросает следующее исключение: < /p>
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.springframework.data.domain.Pageable (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: org.springframework.data.domain.SliceImpl["pageable"])Что я по сути хочу, чтобы иметь возможность получить срез и иметь возможность выполнять утверждения над ним.
Подробнее здесь: https://stackoverflow.com/questions/722 ... testclient