@Test public void is_up_when_api_ok_and_trusted_not_ok() throws Exception { when(untrustedApi.isOk()).thenReturn(true); when(trustedApi.isOk()).thenReturn(false); boolean isDown = apiDownChecker.isApiDown(); assertFalse(isDown); }
public synchronized boolean isApiDown() { long currentTime = dateProvider.now(); if (lastCheckTimestamp + KEEP_ALIVE_MILLIS >= currentTime) { return lastResult; } else { lastCheckTimestamp = currentTime; lastResult = requestIsApiDown(); return lastResult; } }
ApiDownChecker { public synchronized boolean isApiDown() { long currentTime = dateProvider.now(); if (lastCheckTimestamp + KEEP_ALIVE_MILLIS >= currentTime) { return lastResult; } else { lastCheckTimestamp = currentTime; lastResult = requestIsApiDown(); return lastResult; } } }
ApiDownChecker { public synchronized boolean isApiDown() { long currentTime = dateProvider.now(); if (lastCheckTimestamp + KEEP_ALIVE_MILLIS >= currentTime) { return lastResult; } else { lastCheckTimestamp = currentTime; lastResult = requestIsApiDown(); return lastResult; } } ApiDownChecker(ApiValidator untrustedApiValidator, ApiValidator trustedValidator, Logger logger, DateProvider dateProvider); }
ApiDownChecker { public synchronized boolean isApiDown() { long currentTime = dateProvider.now(); if (lastCheckTimestamp + KEEP_ALIVE_MILLIS >= currentTime) { return lastResult; } else { lastCheckTimestamp = currentTime; lastResult = requestIsApiDown(); return lastResult; } } ApiDownChecker(ApiValidator untrustedApiValidator, ApiValidator trustedValidator, Logger logger, DateProvider dateProvider); static ApiDownChecker.Builder create(); synchronized boolean isApiDown(); ApiValidator getTrustedValidator(); ApiValidator getUntrustedValidator(); Logger getLogger(); }
ApiDownChecker { public synchronized boolean isApiDown() { long currentTime = dateProvider.now(); if (lastCheckTimestamp + KEEP_ALIVE_MILLIS >= currentTime) { return lastResult; } else { lastCheckTimestamp = currentTime; lastResult = requestIsApiDown(); return lastResult; } } ApiDownChecker(ApiValidator untrustedApiValidator, ApiValidator trustedValidator, Logger logger, DateProvider dateProvider); static ApiDownChecker.Builder create(); synchronized boolean isApiDown(); ApiValidator getTrustedValidator(); ApiValidator getUntrustedValidator(); Logger getLogger();  }