public boolean shouldLog(final Logger logger, final String path, final int responseCode) {
    if (rateLimitersByPath.containsKey(path)) {
      final RateLimiter rateLimiter = rateLimitersByPath.get(path);
      if (!rateLimiter.tryAcquire()) {
        if (pathLimitHit.tryAcquire()) {
          logger.info("Hit rate limit for path " + path + " with limit " + rateLimiter.getRate());
        }
        return false;
      }
    }
    if (rateLimitersByResponseCode.containsKey(responseCode)) {
      final RateLimiter rateLimiter = rateLimitersByResponseCode.get(responseCode);
      if (!rateLimiter.tryAcquire()) {
        if (responseCodeLimitHit.tryAcquire()) {
          logger.info("Hit rate limit for response code " + responseCode + " with limit "
              + rateLimiter.getRate());
        }
        return false;
      }
    }
    return true;
  }
@Test
  public void shouldLog() {
    // When:
    assertThat(loggingRateLimiter.shouldLog(logger, PATH, 200), is(true));

    // Then:
    verify(rateLimiter).tryAcquire();
    verify(logger, never()).info(any());
  }