Search in sources :

Example 16 with AssemblySnapshot

use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.

the class FluxCallableOnAssemblyTest method stepNameAndToString.

@Test
public void stepNameAndToString() {
    AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
    FluxCallableOnAssembly<?> test = new FluxCallableOnAssembly<>(Flux.empty(), stacktrace);
    assertThat(test.toString()).isEqualTo(test.stepName()).startsWith("reactor.core.publisher.FluxCallableOnAssemblyTest.stepNameAndToString(FluxCallableOnAssemblyTest.java:");
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Example 17 with AssemblySnapshot

use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.

the class Mono method onAssembly.

/**
 * To be used by custom operators: invokes assembly {@link Hooks} pointcut given a
 * {@link Mono}, potentially returning a new {@link Mono}. This is for example useful
 * to activate cross-cutting concerns at assembly time, eg. a generalized
 * {@link #checkpoint()}.
 *
 * @param <T> the value type
 * @param source the source to apply assembly hooks onto
 *
 * @return the source, potentially wrapped with assembly time cross-cutting behavior
 */
@SuppressWarnings("unchecked")
protected static <T> Mono<T> onAssembly(Mono<T> source) {
    Function<Publisher, Publisher> hook = Hooks.onEachOperatorHook;
    if (hook != null) {
        source = (Mono<T>) hook.apply(source);
    }
    if (Hooks.GLOBAL_TRACE) {
        AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
        source = (Mono<T>) Hooks.addAssemblyInfo(source, stacktrace);
    }
    return source;
}
Also used : CorePublisher(reactor.core.CorePublisher) Publisher(org.reactivestreams.Publisher) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot)

Example 18 with AssemblySnapshot

use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.

the class FluxOnAssemblyTest method stepNameAndToString.

@Test
void stepNameAndToString() {
    int baseline = getBaseline();
    FluxOnAssembly<?> test = new FluxOnAssembly<>(Flux.empty(), new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get()));
    assertThat(test.toString()).isEqualTo(test.stepName()).isEqualTo("reactor.core.publisher.FluxOnAssemblyTest.stepNameAndToString(FluxOnAssemblyTest.java:" + (baseline + 1) + ")");
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Example 19 with AssemblySnapshot

use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.

the class FluxOnAssemblyTest method scanOperator.

@Test
void scanOperator() {
    Flux<?> source = Flux.empty();
    FluxOnAssembly<?> test = new FluxOnAssembly<>(source, new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get()));
    assertThat(test.scan(Scannable.Attr.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue();
    assertThat(test.scan(Scannable.Attr.PREFETCH)).as("PREFETCH").isEqualTo(-1);
    assertThat(test.scan(Scannable.Attr.PARENT)).as("PARENT").isSameAs(source);
    assertThat(test.scan(Scannable.Attr.RUN_STYLE)).isSameAs(Scannable.Attr.RunStyle.SYNC);
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Aggregations

AssemblySnapshot (reactor.core.publisher.FluxOnAssembly.AssemblySnapshot)19 Test (org.junit.jupiter.api.Test)15 Publisher (org.reactivestreams.Publisher)4 CorePublisher (reactor.core.CorePublisher)4 Subscription (org.reactivestreams.Subscription)1