### Question:
ConfigurationUpdaterImpl implements ConfigurationUpdater { @Override public long getLatestConfigurationTimestamp() { getLatestConfiguration(); return latest == null ? 0 : latest.getTimestamp(); } ConfigurationUpdaterImpl(QuerySyncConfiguration syncConfiguration, ErrorLog errorLog);   ConfigurationUpdaterImpl(Clock clock, WebClientFactory factory); @Override long getLatestConfigurationTimestamp(); @Override void shareConfiguration(String configuration); @Override ConfigurationUpdate getUpdate();  }### Answer:
@Test public void whenUnableToReachServer_returnedTimestampIsZero() { factory.throwWebClientException(new WebClientException()); assertThat(impl.getLatestConfigurationTimestamp(), equalTo(0L)); }
@Test public void extractTimestampFromReply() { factory.addJsonResponse(RESPONSE_1); assertThat(impl.getLatestConfigurationTimestamp(), equalTo(TIMESTAMP_1)); }
@Test public void whenAskedForConfigurationWithinUpdateInterval_returnCachedValue() { clock.setCurrentMsec(0); factory.addJsonResponse(RESPONSE_1); impl.getLatestConfigurationTimestamp(); clock.incrementSeconds(REFRESH_INTERVAL / 2); factory.addJsonResponse(RESPONSE_2); assertThat(impl.getLatestConfigurationTimestamp(), equalTo(TIMESTAMP_1)); }
@Test public void whenAskedForConfigurationAfterUpdateInterval_returnNewValue() { clock.setCurrentMsec(0); factory.addJsonResponse(RESPONSE_1); impl.getLatestConfigurationTimestamp(); clock.incrementSeconds(REFRESH_INTERVAL); factory.addJsonResponse(RESPONSE_2); assertThat(impl.getLatestConfigurationTimestamp(), equalTo(TIMESTAMP_2)); }