本文整理了Java中reactor.core.publisher.Mono.hide()
方法的一些代码示例,展示了Mono.hide()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.hide()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:hide
[英]Hides the identity of this Mono instance.
The main purpose of this operator is to prevent certain identity-based optimizations from happening, mostly for diagnostic purposes.
[中]隐藏此Mono实例的标识。
此运算符的主要目的是防止发生某些基于身份的优化,主要用于诊断目的。
代码示例来源:origin: reactor/reactor-core
@Test
public void normal() {
Mono<Integer> f = Mono.just(1);
assertThat(f instanceof Fuseable.ScalarCallable).isTrue();
f = f.hide();
assertThat(f instanceof Fuseable.ScalarCallable).isFalse();
assertThat(f instanceof MonoHide).isTrue();
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalHidden() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.just(1).hide().flatMap(v -> Mono.just(2).hide()).subscribe(ts);
ts.assertValues(2)
.assertComplete()
.assertNoError();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void namedHideMonoTest() {
Mono<Integer> named1 =
Mono.just(1)
.hide()
.name("100s");
Mono<Integer> named2 = named1.filter(i -> i % 3 == 0)
.name("multiple of 3 100s")
.hide();
assertThat(Scannable.from(named1).name()).isEqualTo("100s");
assertThat(Scannable.from(named2).name()).isEqualTo("multiple of 3 100s");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void MonoMetricsNoOp() {
assertThatCode(() -> Mono.just("foo").hide().metrics().block())
.doesNotThrowAnyException();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void namedOverridenMonoTest() {
Mono<Integer> named1 =
Mono.just(1)
.name("1s")
.name("100s");
Mono<Integer> named2 = named1.filter(i -> i % 3 == 0)
.name("multiple of 3 100s")
.hide();
assertThat(Scannable.from(named1).name()).isEqualTo("100s");
assertThat(Scannable.from(named2).name()).isEqualTo("multiple of 3 100s");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void errorHide() {
StepVerifier.create(Mono.error(new RuntimeException("forced failure"))
.hide()
.defaultIfEmpty("blah"))
.verifyErrorMessage("forced failure");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void taggedAppendedHideMonoTest() {
Mono<Integer> tagged1 = Mono
.just(1)
.hide()
.tag("1", "One")
.tag("2", "Two");
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void errorIsImmediate() {
Mono<String> source = Mono.<String>error(new IllegalStateException("boom")).hide();
Duration d = StepVerifier.create(new MonoDelayElement<>(source, 10, TimeUnit.SECONDS, defaultSchedulerForDelay()).log())
.expectSubscription()
.verifyErrorMessage("boom");
assertThat(d).isLessThan(Duration.ofSeconds(1));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void errorHide() {
StepVerifier.create(Mono.error(new RuntimeException("forced failure"))
.hide()
.subscribeOn(Schedulers.single()))
.verifyErrorMessage("forced failure");
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalSync() {
StepVerifier.create(Flux.range(1, 10)
.filterWhen(v -> Mono.just(v % 2 == 0).hide()))
.expectNext(2, 4, 6, 8, 10)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void verifyNoFusion() {
Mono<String> flux = Mono.just("foo")
.hide();
StepVerifier.create(flux)
.expectNoFusionSupport()
.expectNext("foo")
.expectComplete()
.verify();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void errorHide() {
StepVerifier.create(Mono.error(new RuntimeException("forced failure"))
.hide()
.publishOn(Schedulers.single()))
.verifyErrorMessage("forced failure");
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void nonEmptyHide() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.just(1).hide().defaultIfEmpty(10).subscribe(ts);
ts.assertValues(1)
.assertComplete()
.assertNoError();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void emptyHide() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.<Integer>empty().hide().defaultIfEmpty(10).subscribe(ts);
ts.assertValues(10)
.assertComplete()
.assertNoError();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalInnerJust() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.just(1).hide().flatMapMany(v -> Flux.just(2))
.subscribe(ts);
ts.assertValues(2)
.assertNoError()
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalInnerEmpty() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.just(1).hide().flatMapMany(v -> Flux.<Integer>empty())
.subscribe(ts);
ts.assertNoValues()
.assertNoError()
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalJust() {
StepVerifier.create(Mono.just(1).hide().doFinally(this))
.expectNoFusionSupport()
.expectNext(1)
.expectComplete()
.verify();
assertEquals(1, calls);
assertEquals(SignalType.ON_COMPLETE, signalType);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void testConcatMapDelayError() {
ParallelFlux<Integer> pf = ParallelFlux.from(Flux.range(1, 4), 2)
.concatMapDelayError(i -> {
if (i == 1)
return Mono.<Integer>error(new IllegalStateException("boom")).hide();
return Flux.just(i, 100 * i);
});
StepVerifier.create(pf)
.expectNext(2, 200, 3, 300, 4, 400)
.verifyErrorMessage("boom");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normalBackpressured() {
AssertSubscriber<Void> ts = AssertSubscriber.create(0);
Mono.<Void>fromRunnable(() -> {
})
.hide()
.subscribe(ts);
ts.assertNoValues()
.assertComplete()
.assertNoError();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void emptyBackpressuredHide() {
AssertSubscriber<Integer> ts = AssertSubscriber.create(0);
Mono.<Integer>empty().hide().defaultIfEmpty(10).subscribe(ts);
ts.assertNoValues()
.assertNoError()
.assertNotComplete();
ts.request(2);
ts.assertValues(10)
.assertComplete()
.assertNoError();
}
内容来源于网络,如有侵权,请联系作者删除!