ResponsiveHealthIndicator implements HealthIndicator { ZeebeClient supplyZeebeClient() { if (zeebeClient == null && gatewayCfg.isInitialized()) { zeebeClient = createZeebeClient(gatewayCfg, defaultTimeout); } return zeebeClient; } ResponsiveHealthIndicator(final GatewayCfg gatewayCfg, final Duration defaultTimeout); @Override Health health();  }
@Test public void shouldNotSupplyZeebeClientIfGatewayConfigIsNotInitialized() { final var gatewayCfg = new GatewayCfg(); gatewayCfg.getNetwork().setHost("testhost"); gatewayCfg.getNetwork().setPort(1234); gatewayCfg.getSecurity().setEnabled(false); final var healthIndicator = new ResponsiveHealthIndicator(gatewayCfg, TEST_DURATION); final var actualZeebeClient = healthIndicator.supplyZeebeClient(); assertThat(actualZeebeClient).isNull(); }
@Test public void shouldSupplyConfiguredZeebeClientIfGatewayConfigIsInitialized() { final var gatewayCfg = new GatewayCfg(); gatewayCfg.getNetwork().setHost("testhost"); gatewayCfg.getNetwork().setPort(1234); gatewayCfg.getSecurity().setEnabled(false); gatewayCfg.init(); final var healthIndicator = new ResponsiveHealthIndicator(gatewayCfg, TEST_DURATION); final var actualZeebeClient = healthIndicator.supplyZeebeClient(); assertThat(actualZeebeClient).isNotNull(); assertThat(actualZeebeClient.getConfiguration().getGatewayAddress()).isEqualTo("testhost:1234"); assertThat(actualZeebeClient.getConfiguration().isPlaintextConnectionEnabled()).isTrue(); }