Мой контроллер
Код: Выделить всё
@RestController
@RequestMapping("api")
@RequiredArgsConstructor
public class TestController {
private final Service service;
@PostMapping("/test")
public Mono test(@RequestBody @Valid Flux testDtoFlux) {
return testDtoFlux
.map(service::test)
.then();
}
Код: Выделить всё
void setup() {
service = Mock(Service)
controller = new TestController(service)
}
def "Should test abc"() {
setup:
def testDto = new TestDto(11L, true)
when:
def result = StepVerifier.create(controller.test(Flux.just(testDto)))
then:
result
.verifyComplete()
1 * service.test(_) >> true
}
Код: Выделить всё
public Mono test(@RequestBody @Valid Flux testDtoFlux) {
testDtoFlux
.map(service::test)
.then().block();
return Mono.empty();
}
Код: Выделить всё
result
.expectSubscription()
.thenAwait(Duration.ofSeconds(5))
.expectComplete()
.verify();
ps. Когда я запускаю приложение, все работает нормально. У меня проблема только с этим тестом.
Подробнее здесь: https://stackoverflow.com/questions/784 ... epverifier
Мобильная версия