Skip to content

Instantly share code, notes, and snippets.

@haigopi
Created December 11, 2018 20:44
Show Gist options
  • Save haigopi/1b4451e5f75aab9593de14b67053e38b to your computer and use it in GitHub Desktop.
Save haigopi/1b4451e5f75aab9593de14b67053e38b to your computer and use it in GitHub Desktop.
@Slf4j
public class FluxTest {
@Test
public void test() {
Flux<String> b = Flux.just("Bob cat", "is in the ", "party").delayElements(Duration.ofSeconds(2));
Flux.first(b)
.toIterable()
.forEach(log::info);
}
}
//14:43:31.455 [main] INFO com.capitalone.fs.marketingone.FluxTest - Bob cat
//14:43:33.460 [main] INFO com.capitalone.fs.marketingone.FluxTest - is in the
//14:43:35.463 [main] INFO com.capitalone.fs.marketingone.FluxTest - party
@rucko24
Copy link

rucko24 commented Jan 30, 2021

Hi,

why not testing with StepVerifier ?

@Test
void fluxElements() {
       final Flux<String> elements = Flux.just("Bob cat", "is in the", "party");
       StepVerifier.withVirtualTime(() -> elements
               .delayElements(Duration.ofSeconds(2)))
               .expectSubscription()
               .thenAwait(Duration.ofSeconds(6))
               .expectNextMatches(predicate -> predicate.equals("Bob cat"))
               .expectNextMatches(predicate -> predicate.equals("is in the"))
               .expectNextMatches(predicate -> predicate.equals("party"))
               .verifyComplete();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment