### Question:
ReactorSphU { public static <R> Mono<R> entryWith(String resourceName, Mono<R> actual) { return entryWith(resourceName, EntryType.OUT, actual); } private  ReactorSphU(); static Mono<R> entryWith(String resourceName, Mono<R> actual); static Mono<R> entryWith(String resourceName, EntryType entryType, Mono<R> actual);  }### Answer:
@Test public void testReactorEntryNormalWhenFlowControlTriggered() { String resourceName = createResourceName("testReactorEntryNormalWhenFlowControlTriggered"); FlowRuleManager.loadRules(Collections.singletonList( new FlowRule(resourceName).setCount(0) )); StepVerifier.create(ReactorSphU.entryWith(resourceName, Mono.just(60)) .subscribeOn(Schedulers.elastic()) .map(e -> e * 3)) .expectError(BlockException.class) .verify(); ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName); assertNotNull(cn); assertEquals(0, cn.passQps(), 0.01); assertEquals(1, cn.blockRequest()); FlowRuleManager.loadRules(new ArrayList<>()); }
@Test public void testReactorEntryWithCommon() { String resourceName = createResourceName("testReactorEntryWithCommon"); StepVerifier.create(ReactorSphU.entryWith(resourceName, Mono.just(60)) .subscribeOn(Schedulers.elastic()) .map(e -> e * 3)) .expectNext(180) .verifyComplete(); ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName); assertNotNull(cn); assertEquals(1, cn.passQps(), 0.01); }
@Test public void testReactorEntryWithBizException() { String resourceName = createResourceName("testReactorEntryWithBizException"); StepVerifier.create(ReactorSphU.entryWith(resourceName, Mono.error(new IllegalStateException()))) .expectError(IllegalStateException.class) .verify(); ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName); assertNotNull(cn); assertEquals(1, cn.passQps(), 0.01); assertEquals(1, cn.totalException()); }