HealthCheck implements HealthStatusChecker { @Subscribe public void onEvent(final ErrorEvent event) { event.visit(e -> handle(e, fatalErrors), e -> handle(e, errors)); } @Autowired  HealthCheck(HealthChecker healthChecker, @Value("${health.check.error.list.size:25}") int maxSize,
            @Value("${health.check.max.error.list.size:2500}") int hardMax, EventBus errorBus); @PostConstruct void register(); void setMaxSize(int maxSize); @Subscribe void onEvent(final ErrorEvent event); HealthStatus checkHealthStatus(); @Override boolean isOk();  }
@Test public void testOnEvent() { check.onEvent(new ErrorEvent()); assertThat(check.errors.size(), is(1)); }
@Test public void testOnEventMaxNotExceeded() { for (int i = 0; i < check.getMaxSize() * 2; i++) { check.onEvent(new ErrorEvent()); assertThat(check.errors.size(), is(Math.min(i + 1, check.getMaxSize()))); } }