### Question:
HeartbeatInfoCache implements HeartbeatContributor, Serializable { public void update(HeartbeatInfo info) { HeartbeatInfo oldInfo = (HeartbeatInfo)infoCache.get(info); info = oldInfo == null ? info : oldInfo; info.incrementCount(); infoCache.put(info, info); }  void update(HeartbeatInfo info); void contributeToHttpCall(HeartbeatCall call); int size();  }### Answer:
@Test void update_heartbeatInfoIsNotCached_heartbeatInfoIsCachedAndCountIsIncremented() { infoCache.clear(); heartbeatInfoCache.update(heartbeatInfo); verify(heartbeatInfo).incrementCount(); verify(infoCache).put(heartbeatInfo, heartbeatInfo); }
@Test void update_heartbeatInfoIsCached_heartbeatInfoCacheIsUpdatedAndCountIsIncremented() { HeartbeatInfo cachedHeartbeatInfo = mock(HeartbeatInfo.class); infoCache.put(heartbeatInfo, cachedHeartbeatInfo); heartbeatInfoCache.update(heartbeatInfo); verify(cachedHeartbeatInfo).incrementCount(); verify(infoCache).put(cachedHeartbeatInfo, cachedHeartbeatInfo); }