SmallRyeReactiveMessagingReadinessCheck implements HealthCheck { @Override public HealthCheckResponse call() { HealthReport report = health.getReadiness(); return HealthChecks.getHealthCheck(report, "readiness check"); }  @Override HealthCheckResponse call();  }
@Test public void testWithTwoConnectors() { SeContainerInitializer initializer = SeContainerInitializer.newInstance().disableDiscovery(); initializer.addBeanClasses(HealthCenter.class, MyReporterA.class, MyReporterB.class, SmallRyeReactiveMessagingReadinessCheck.class); SeContainer container = initializer.initialize(); SmallRyeReactiveMessagingReadinessCheck check = container.getBeanManager().createInstance() .select(SmallRyeReactiveMessagingReadinessCheck.class, Readiness.Literal.INSTANCE).get(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); assertThat(check.call().getData().orElse(null)).containsExactly(entry("my-channel", "[OK] - test")); 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.DOWN); b.toggle(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.DOWN); assertThat(check.call().getData().orElse(null)).containsExactly(entry("my-channel", "[KO] - test")); a.toggle(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); assertThat(check.call().getData().orElse(null)).containsExactly(entry("my-channel", "[OK] - test")); }
@Test public void testWithNoConnector() { SeContainerInitializer initializer = SeContainerInitializer.newInstance().disableDiscovery(); initializer.addBeanClasses(HealthCenter.class, SmallRyeReactiveMessagingReadinessCheck.class); SeContainer container = initializer.initialize(); SmallRyeReactiveMessagingReadinessCheck check = container.getBeanManager().createInstance() .select(SmallRyeReactiveMessagingReadinessCheck.class, Readiness.Literal.INSTANCE).get(); assertThat(check.call().getState()).isEqualTo(HealthCheckResponse.State.UP); assertThat(check.call().getData()).isEmpty(); }