SmallRyeReactiveMessagingLivenessCheck implements HealthCheck { @Override public HealthCheckResponse call() { HealthReport report = health.getLiveness(); return HealthChecks.getHealthCheck(report, "liveness check"); }  @Override HealthCheckResponse call();  }
@Test public void testWithTwoConnectors() { SeContainerInitializer initializer = SeContainerInitializer.newInstance().disableDiscovery(); initializer.addBeanClasses(HealthCenter.class, MyReporterA.class, MyReporterB.class, SmallRyeReactiveMessagingLivenessCheck.class); SeContainer container = initializer.initialize(); SmallRyeReactiveMessagingLivenessCheck check = container.getBeanManager().createInstance() .select(SmallRyeReactiveMessagingLivenessCheck.class, Liveness.Literal.INSTANCE).get(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); assertThat(check.call().getData().orElse(null)).containsExactly(entry("my-channel", "[OK]")); MyReporterA a = container.getBeanManager().createInstance() .select(MyReporterA.class, ConnectorLiteral.of("connector-a")).get(); MyReporterB b = container.getBeanManager().createInstance() .select(MyReporterB.class, ConnectorLiteral.of("connector-b")).get(); a.toggle(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); b.toggle(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.DOWN); assertThat(check.call().getData().orElse(null)).containsExactly(entry("my-channel", "[KO]")); }
@Test public void testWithNoConnector() { SeContainerInitializer initializer = SeContainerInitializer.newInstance().disableDiscovery(); initializer.addBeanClasses(HealthCenter.class, SmallRyeReactiveMessagingLivenessCheck.class); SeContainer container = initializer.initialize(); SmallRyeReactiveMessagingLivenessCheck check = container.getBeanManager().createInstance() .select(SmallRyeReactiveMessagingLivenessCheck.class, Liveness.Literal.INSTANCE).get(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); assertThat(check.call().getData()).isEmpty(); }