@Test public void testHealth_up() { final int limit = 5000; final int remaining = 1001; final long reset = 1372700873; final ZonedDateTime verwachteReset = ZonedDateTime.ofInstant(Instant.ofEpochSecond(reset), ZoneId.systemDefault()); when(githubGateway.getRateLimit()).thenReturn(GithubRateLimits.with() .core(GithubRateLimit.with() .limit(limit) .remaining(remaining) .reset(reset) .build()) .build()); final Health result = githubRateHealthCheck.health(); assertThat(result.getStatus()).isEqualTo(Status.UP); assertThat(result.getDetails().get("limit")).isEqualTo(limit); assertThat(result.getDetails().get("remaining")).isEqualTo(remaining); assertThat(result.getDetails().get("reset")).isEqualTo(verwachteReset); }
@Override public Health health() { final GithubRateLimit rateLimit = githubGateway.getRateLimit().getCore(); if (rateLimit.getRemaining() == 0) { return addDetails(Health.down(), rateLimit).build(); } if (rateLimit.getRemaining() > calculateThreshold(rateLimit.getLimit())) { return addDetails(Health.up(), rateLimit).build(); } return addDetails(Health.status(new Status("THRESHOLD REACHED")), rateLimit).build(); }
GithubRateHealthCheck implements HealthIndicator { @Override public Health health() { final GithubRateLimit rateLimit = githubGateway.getRateLimit().getCore(); if (rateLimit.getRemaining() == 0) { return addDetails(Health.down(), rateLimit).build(); } if (rateLimit.getRemaining() > calculateThreshold(rateLimit.getLimit())) { return addDetails(Health.up(), rateLimit).build(); } return addDetails(Health.status(new Status("THRESHOLD REACHED")), rateLimit).build(); } }
GithubRateHealthCheck implements HealthIndicator { @Override public Health health() { final GithubRateLimit rateLimit = githubGateway.getRateLimit().getCore(); if (rateLimit.getRemaining() == 0) { return addDetails(Health.down(), rateLimit).build(); } if (rateLimit.getRemaining() > calculateThreshold(rateLimit.getLimit())) { return addDetails(Health.up(), rateLimit).build(); } return addDetails(Health.status(new Status("THRESHOLD REACHED")), rateLimit).build(); } GithubRateHealthCheck(final GithubGateway githubGateway,
                                 @Value("${io.fundrequest.health.github.api-rate-limit.threshold-percentage:20}") final int thresholdPercentage); }
GithubRateHealthCheck implements HealthIndicator { @Override public Health health() { final GithubRateLimit rateLimit = githubGateway.getRateLimit().getCore(); if (rateLimit.getRemaining() == 0) { return addDetails(Health.down(), rateLimit).build(); } if (rateLimit.getRemaining() > calculateThreshold(rateLimit.getLimit())) { return addDetails(Health.up(), rateLimit).build(); } return addDetails(Health.status(new Status("THRESHOLD REACHED")), rateLimit).build(); } GithubRateHealthCheck(final GithubGateway githubGateway,
                                 @Value("${io.fundrequest.health.github.api-rate-limit.threshold-percentage:20}") final int thresholdPercentage); @Override Health health(); }
GithubRateHealthCheck implements HealthIndicator { @Override public Health health() { final GithubRateLimit rateLimit = githubGateway.getRateLimit().getCore(); if (rateLimit.getRemaining() == 0) { return addDetails(Health.down(), rateLimit).build(); } if (rateLimit.getRemaining() > calculateThreshold(rateLimit.getLimit())) { return addDetails(Health.up(), rateLimit).build(); } return addDetails(Health.status(new Status("THRESHOLD REACHED")), rateLimit).build(); } GithubRateHealthCheck(final GithubGateway githubGateway,
                                 @Value("${io.fundrequest.health.github.api-rate-limit.threshold-percentage:20}") final int thresholdPercentage); @Override Health health();  }