Java Code Examples for reactor.core.publisher.Flux#next()

The following examples show how to use reactor.core.publisher.Flux#next() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluxTests.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void fluxNextCallableCallsAssemblyHook() {
	Flux<Integer> source = Mono.fromCallable(() -> 1).flux();
	Assertions.assertThat(source) //smoke test that we go into the right case
	          .isInstanceOf(Callable.class)
	          .isNotInstanceOf(Mono.class)
	          .isNotInstanceOf(Fuseable.ScalarCallable.class);

	//set the hook AFTER the original operators have been invoked (since they trigger assembly themselves)
	AtomicInteger wrappedCount = new AtomicInteger();
	Hooks.onEachOperator(p -> {
		wrappedCount.incrementAndGet();
		return p;
	});

	source.next();
	Assertions.assertThat(wrappedCount).hasValue(1);
}
 
Example 2
Source File: FluxTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void fluxNextScalarEmptyCallsAssemblyHook() {
	Flux<Integer> source = Flux.empty();

	//set the hook AFTER the original operators have been invoked (since they trigger assembly themselves)
	AtomicInteger wrappedCount = new AtomicInteger();
	Hooks.onEachOperator(p -> {
		wrappedCount.incrementAndGet();
		return p;
	});

	source.next();
	Assertions.assertThat(wrappedCount).hasValue(1);
}
 
Example 3
Source File: FluxTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void fluxNextScalarValuedCallsAssemblyHook() {
	Flux<Integer> source = Flux.just(1);

	//set the hook AFTER the original operators have been invoked (since they trigger assembly themselves)
	AtomicInteger wrappedCount = new AtomicInteger();
	Hooks.onEachOperator(p -> {
		wrappedCount.incrementAndGet();
		return p;
	});

	source.next();
	Assertions.assertThat(wrappedCount).hasValue(1);
}
 
Example 4
Source File: FluxTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void fluxNextScalarErrorCallsAssemblyHook() {
	Flux<Integer> source = Flux.error(new IllegalStateException("boom"));

	//set the hook AFTER the original operators have been invoked (since they trigger assembly themselves)
	AtomicInteger wrappedCount = new AtomicInteger();
	Hooks.onEachOperator(p -> {
		wrappedCount.incrementAndGet();
		return p;
	});

	source.next();
	Assertions.assertThat(wrappedCount).hasValue(1);
}
 
Example 5
Source File: FluxTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void fluxNextNormalCallsAssemblyHook() {
	Flux<Integer> source = Flux.range(1, 10);

	//set the hook AFTER the original operators have been invoked (since they trigger assembly themselves)
	AtomicInteger wrappedCount = new AtomicInteger();
	Hooks.onEachOperator(p -> {
		wrappedCount.incrementAndGet();
		return p;
	});

	source.next();
	Assertions.assertThat(wrappedCount).hasValue(1);
}