Java Code Examples for reactor.core.scheduler.Schedulers#immediate()

The following examples show how to use reactor.core.scheduler.Schedulers#immediate() . 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: WorkerRepositoryAdapterTest.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
	Scheduler scheduler = Schedulers.immediate();
	HttpRequestContextProvider requestContextProvider = Mockito.mock(HttpRequestContextProvider.class);
	relAdapter = Mockito.mock(RelationshipRepositoryAdapter.class);
	workerRelAdapter = new WorkerRelationshipRepositoryAdapter(relAdapter, scheduler, requestContextProvider);

	adapter = Mockito.mock(ResourceRepositoryAdapter.class);
	workerAdapter = new WorkerResourceRepositoryAdapter(adapter, scheduler, requestContextProvider);

	MonoResultFactory resultFactory = new MonoResultFactory();
	response = resultFactory.just(new JsonApiResponse());
	HttpRequestContext requestContext = Mockito.mock(HttpRequestContext.class);
	Result<HttpRequestContext> requestContextResult = resultFactory.just(requestContext);
	Mockito.when(requestContextProvider.getRequestContextResult()).thenReturn(requestContextResult);
}
 
Example 2
Source File: FluxOnBackpressureBufferTimeoutTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void scanSubscriber() {
	CoreSubscriber<String> actual = new LambdaSubscriber<>(null, null, null, null);
	BackpressureBufferTimeoutSubscriber<String> test = new BackpressureBufferTimeoutSubscriber<>(actual, Duration.ofSeconds(1), Schedulers.immediate(), 123, v -> {});
	Subscription s = Operators.emptySubscription();
	test.onSubscribe(s);

	assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
	assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);

	assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(Long.MAX_VALUE);
	assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
	assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();

	test.offer("foo");
	test.offer("bar");
	assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(2);

	test.error = new RuntimeException("boom");
	assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);

	assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
	assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isFalse();
	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 3
Source File: ReactiveRepositoryAdapterFactory.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public ResourceRepositoryAdapter decorate(ResourceRepositoryAdapter adapter) {
	Object implementation = adapter.getImplementation();
	if (implementation instanceof ReactiveResourceRepository) {
		return adapter;
	}

	boolean immediate = implementation.getClass().getAnnotation(ImmediateRepository.class) != null;
	LOGGER.debug("wrapping non-reactive repository {}, immediate={}", implementation, immediate);
	Scheduler scheduler = immediate ? Schedulers.immediate() : Schedulers.elastic();
	return new WorkerResourceRepositoryAdapter(adapter, scheduler, moduleRegistry.getHttpRequestContextProvider());
}
 
Example 4
Source File: ReactiveRepositoryAdapterFactory.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public RelationshipRepositoryAdapter decorate(RelationshipRepositoryAdapter adapter) {
	Object implementation = adapter.getImplementation();
	if (implementation instanceof ReactiveRelationshipRepository) {
		return adapter;
	}

	boolean immediate = implementation.getClass().getAnnotation(ImmediateRepository.class) != null;
	LOGGER.debug("wrapping non-reactive repository {}, immediate={}", implementation, immediate);
	Scheduler scheduler = immediate ? Schedulers.immediate() : workerScheduler;
	return new WorkerRelationshipRepositoryAdapter(adapter, scheduler, moduleRegistry.getHttpRequestContextProvider());
}
 
Example 5
Source File: MonoCacheTime.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
MonoCacheTime(Mono<? extends T> source) {
	this(source, sig -> DURATION_INFINITE, Schedulers.immediate());
}
 
Example 6
Source File: FluxDelaySequenceTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	FluxDelaySequence<String> test = new FluxDelaySequence<>(Flux.empty(), Duration.ofSeconds(1), Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 7
Source File: MonoSubscribeOnTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoSubscribeOn<String> test = new MonoSubscribeOn<>(Mono.empty(), Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 8
Source File: MonoPublishOnTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoPublishOn<String> test = new MonoPublishOn<>(Mono.empty(), Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 9
Source File: FluxSubscribeOnCallableTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	FluxSubscribeOnCallable test = new FluxSubscribeOnCallable<>(() -> "foo", Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 10
Source File: MonoDelayElementTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoDelayElement<String> test = new MonoDelayElement<>(Mono.empty(), 1, TimeUnit.SECONDS, Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 11
Source File: MonoElapsedTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoElapsed<String> test = new MonoElapsed<>(Mono.empty(), Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 12
Source File: FluxWindowTimeoutTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	FluxWindowTimeout<Integer> test = new FluxWindowTimeout<>(Flux.just(1), 123, 100, TimeUnit.MILLISECONDS, Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 13
Source File: MonoCancelOnTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoCancelOn<String> test = new MonoCancelOn<>(Mono.empty(), Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 14
Source File: MonoSubscribeOnCallableTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoSubscribeOnCallable<String> test = new MonoSubscribeOnCallable<>(() -> "foo", Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 15
Source File: MonoSubscribeOnValueTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoSubscribeOnValue<String> test = new MonoSubscribeOnValue<>("foo", Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}
 
Example 16
Source File: MonoDelayTest.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
@Test
public void scanOperator() {
	MonoDelay test = new MonoDelay(1, TimeUnit.SECONDS, Schedulers.immediate());

	assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.immediate());
}