@Test public void shouldConsumeOnCallFinishedEventOnComplete() throws Exception { // Given Bulkhead bulkhead = Bulkhead.of("test", config); // When bulkhead.getEventPublisher() .onCallFinished(event -> logger.info(event.getEventType().toString())); bulkhead.onComplete(); // Then then(logger).should(times(1)).info("CALL_FINISHED"); } }
@Test public void shouldConsumeOnCallPermittedEvent() { // Given Bulkhead bulkhead = Bulkhead.of("test", config); BDDMockito.given(helloWorldService.returnHelloWorld()).willReturn("Hello world"); // When bulkhead.getEventPublisher() .onCallPermitted(event -> logger.info(event.getEventType().toString())); String result = bulkhead.executeSupplier(helloWorldService::returnHelloWorld); // Then assertThat(result).isEqualTo("Hello world"); then(logger).should(times(1)).info("CALL_PERMITTED"); }
@Test public void shouldConsumeOnCallRejectedEvent() { // Given Bulkhead bulkhead = Bulkhead.of("test", config); // When bulkhead.getEventPublisher() .onCallRejected(event -> logger.info(event.getEventType().toString())); bulkhead.isCallPermitted(); Try.ofSupplier(Bulkhead.decorateSupplier(bulkhead,helloWorldService::returnHelloWorld)); // Then then(logger).should(times(1)).info("CALL_REJECTED"); }
bulkhead.getEventPublisher().onEvent(bConsumerRegistry.createEventConsumer(name, endpointsConfig.getBulkheads().getEventConsumerBufferSize()));
bulkhead.getEventPublisher().onEvent(bConsumerRegistry.createEventConsumer(name, endpointsConfig.getBulkheads().getEventConsumerBufferSize()));
@Test public void shouldConsumeOnCallFinishedEventWhenExecutionIsFinished() throws Exception { // Given Bulkhead bulkhead = Bulkhead.of("test", config); // When bulkhead.getEventPublisher() .onCallFinished(event -> logger.info(event.getEventType().toString())); Try.ofSupplier(Bulkhead.decorateSupplier(bulkhead,helloWorldService::returnHelloWorld)); // Then then(logger).should(times(1)).info("CALL_FINISHED"); }