Flux.fromIterable() creates a Project Reactor Flux from a Java Iterable. Pass it a List, Set, or another Iterable when you have existing collection data but want to work with a Flux. section 11.3.1
Create and check a Flux
A list of fruit names can become a Flux<String> with Flux.fromIterable(fruitList). StepVerifier can then check that the Flux publishes the expected names and completes. section 11.3.1
@Test
public void createAFlux_fromIterable() {
List<String> fruitList = new ArrayList<>();
fruitList.add("Apple");
fruitList.add("Orange");
fruitList.add("Grape");
fruitList.add("Banana");
fruitList.add("Strawberry");
Flux<String> fruitFlux = Flux.fromIterable(fruitList);
StepVerifier.create(fruitFlux)
.expectNext("Apple")
.expectNext("Orange")
.expectNext("Grape")
.expectNext("Banana")
.expectNext("Strawberry")
.verifyComplete();
}
The complete test shows the source list, the factory call, and StepVerifier assertions together. section 11.3.1
The same conversion can bridge a conventional repository and a reactive controller: `Flux.fromIterable(tacoRepo.findAll()).take(12)` returns a Flux containing at most 12 tacos. This is a limited bridge, not an end-to-end reactive stack. A repository that already returns a Flux lets the controller use `tacoRepo.findAll().take(12)` without converting an Iterable. section 12.1.2
