### Question:
XSiteResource implements ResourceHandler { private CompletionStage<RestResponse> pushStateStatus(RestRequest request) { return statusOperation(request, PUSH_STATE_STATUS); } XSiteResource(InvocationHelper invocationHelper); @Override Invocations getInvocations(); static final String AFTER_FAILURES_FIELD; static final String MIN_WAIT_FIELD; }### Answer:
@Test public void testPushState() { RestCacheClient cache = getCacheClient(LON); RestCacheClient backupCache = getCacheClient(NYC); String key = "key"; String value = "value"; Function<String, Integer> keyOnBackup = k -> responseStatus(backupCache.get(key)); takeBackupOffline(LON, NYC); assertEquals(OFFLINE, getBackupStatus(LON, NYC)); assertEquals(ONLINE, getBackupStatus(LON, SFO)); assertNoContent(cache.put(key, value)); assertEquals(404, (int) keyOnBackup.apply(key)); assertSuccessful(cache.pushSiteState(NYC)); assertEquals(ONLINE, getBackupStatus(LON, NYC)); eventuallyEquals("OK", () -> pushStateStatus(cache, NYC)); assertEquals(200, responseStatus(backupCache.get(key))); }
@Test public void testPushAllCaches() { RestClient restClientLon = clientPerSite.get(LON); RestClient restClientSfo = clientPerSite.get(SFO); RestCacheClient cache1Lon = restClientLon.cache(CACHE_1); RestCacheClient cache2Lon = restClientLon.cache(CACHE_2); RestCacheClient cache1Sfo = restClientSfo.cache(CACHE_1); RestCacheClient cache2Sfo = restClientSfo.cache(CACHE_2); assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).takeOffline(SFO)); Json backupStatuses = jsonResponseBody(restClientLon.cacheManager(CACHE_MANAGER).backupStatuses()); assertEquals("offline", backupStatuses.at(SFO).at("status").asString()); int entries = 10; IntStream.range(0, entries).forEach(i -> { String key = String.valueOf(i); String value = "value"; assertNoContent(cache1Lon.put(key, value)); assertNoContent(cache2Lon.put(key, value)); }); assertEquals(0, getCacheSize(cache1Sfo)); assertEquals(0, getCacheSize(cache2Sfo)); assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).pushSiteState(SFO)); assertEquals(ONLINE, getBackupStatus(LON, SFO)); eventuallyEquals("OK", () -> pushStateStatus(cache1Lon, SFO)); eventuallyEquals("OK", () -> pushStateStatus(cache2Lon, SFO)); assertEquals(entries, getCacheSize(cache1Sfo)); assertEquals(entries, getCacheSize(cache2Sfo)); }