### Question:
ReactiveSentinelCircuitBreaker implements ReactiveCircuitBreaker { @Override public <T> Mono<T> run(Mono<T> toRun, Function<Throwable, Mono<T>> fallback) { Mono<T> toReturn = toRun.transform(new SentinelReactorTransformer<>( new EntryConfig(resourceName, entryType))); if (fallback != null) { toReturn = toReturn.onErrorResume(fallback); } return toReturn; } ReactiveSentinelCircuitBreaker(String resourceName, EntryType entryType,
			List<DegradeRule> rules);  ReactiveSentinelCircuitBreaker(String resourceName, List<DegradeRule> rules);  ReactiveSentinelCircuitBreaker(String resourceName); @Override Mono<T> run(Mono<T> toRun, Function<Throwable, Mono<T>> fallback); @Override Flux<T> run(Flux<T> toRun, Function<Throwable, Flux<T>> fallback);  }### Answer:
@Test public void testCreateWithNullRule() { String id = "testCreateReactiveCbWithNullRule"; ReactiveSentinelCircuitBreaker cb = new ReactiveSentinelCircuitBreaker(id, Collections.singletonList(null)); assertThat(Mono.just("foobar").transform(it -> cb.run(it)).block()) .isEqualTo("foobar"); assertThat(DegradeRuleManager.hasConfig(id)).isFalse(); }
@Test public void runMono() { ReactiveCircuitBreaker cb = new ReactiveSentinelCircuitBreakerFactory() .create("foo"); assertThat(Mono.just("foobar").transform(it -> cb.run(it)).block()) .isEqualTo("foobar"); }
@Test public void runMonoWithFallback() { ReactiveCircuitBreaker cb = new ReactiveSentinelCircuitBreakerFactory() .create("foo"); assertThat(Mono.error(new RuntimeException("boom")) .transform(it -> cb.run(it, t -> Mono.just("fallback"))).block()) .isEqualTo("fallback"); }
@Test public void runFlux() { ReactiveCircuitBreaker cb = new ReactiveSentinelCircuitBreakerFactory() .create("foo"); assertThat(Flux.just("foobar", "hello world").transform(it -> cb.run(it)) .collectList().block()).isEqualTo(Arrays.asList("foobar", "hello world")); }
@Test public void runFluxWithFallback() { ReactiveCircuitBreaker cb = new ReactiveSentinelCircuitBreakerFactory() .create("foo"); assertThat(Flux.error(new RuntimeException("boom")) .transform(it -> cb.run(it, t -> Flux.just("fallback"))).collectList() .block()).isEqualTo(Arrays.asList("fallback")); }