Is there any way to test infinite flux stream created in controller method using VirualTimeScheduler/ or any other means to test . e,g, i have following code in RestController
final String[] names = new String []{"Shailesh", "Josh", "Loredana", "Eugen", "Roger"};
final Random randomGenerator = new Random();
IntStream streamOfRandomIndexes = IntStream.iterate(0, nextInt ->
randomGenerator.nextInt(names.length));
Stream<String> fooNameStream = streamOfRandomIndexes.mapToObj(nextIndex -> names[nextIndex]);
Flux<String> fooNames = Flux.fromStream(fooNameStream);
Flux<Long> fooIds = Flux.interval(Duration.ofSeconds(1));
return Flux.zip(fooNames,fooIds) .map(fooTuple -> new Foo(fooTuple.getT1(),fooTuple.getT2()));
I am clueless how to verify that every element is in turn returned after 1 sec. Like if i change the delay in controller the particular test testing the time interval should fail. I searched a lot but in vain. I have some idea that because getBody() is blocking, i cannot use virtualTimescheduler. But then how to get around this?