ResponsiveHealthIndicator implements HealthIndicator { static ZeebeClient createZeebeClient(final GatewayCfg gatewayCfg, final Duration defaultTimeout) { final String gatewayAddress = getContactPoint(gatewayCfg); ZeebeClientBuilder clientBuilder = ZeebeClient.newClientBuilder() .gatewayAddress(gatewayAddress) .defaultRequestTimeout(defaultTimeout); if (gatewayCfg.getSecurity().isEnabled()) { clientBuilder = clientBuilder.caCertificatePath(gatewayCfg.getSecurity().getCertificateChainPath()); } else { clientBuilder = clientBuilder.usePlaintext(); } return clientBuilder.build(); } ResponsiveHealthIndicator(final GatewayCfg gatewayCfg, final Duration defaultTimeout); @Override Health health();  }
@Test public void testCreateZeebeClientShouldConfigureContactPoint() { final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION); assertThat(actual.getConfiguration().getGatewayAddress()).isEqualTo("testhost:1234"); }
@Test public void testCreateZeebeClientShouldConfigureRequestTimeout() { final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION); assertThat(actual.getConfiguration().getDefaultRequestTimeout()).isEqualTo(TEST_DURATION); }
@Test public void testCreateZeebeClientShouldEnablePlainTextCommunicationIfSecurityIsDisabled() { final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION); assertThat(actual.getConfiguration().isPlaintextConnectionEnabled()).isTrue(); }
@Test public void testCreateZeebeClientShouldPassCertificateChainPathIfSecurityIsEnabled() { final var securityEnabledGatewayCfg = new GatewayCfg(); securityEnabledGatewayCfg.getNetwork().setHost("testhost"); securityEnabledGatewayCfg.getNetwork().setPort(1234); securityEnabledGatewayCfg.getSecurity().setEnabled(true); securityEnabledGatewayCfg.getSecurity().setCertificateChainPath(CERTIFICATE_CHAIN_PATH); securityEnabledGatewayCfg.init(); final ZeebeClient actualZeebeClient = ResponsiveHealthIndicator.createZeebeClient(securityEnabledGatewayCfg, TEST_DURATION); assertThat(actualZeebeClient.getConfiguration().isPlaintextConnectionEnabled()).isFalse(); assertThat(actualZeebeClient.getConfiguration().getCaCertificatePath()) .isEqualTo(CERTIFICATE_CHAIN_PATH); }