### Question:
HubRegistry implements PartitionListener { public void offline(String hubId, String hubBridge) { HubState state = hubs.get(hubId); if(state == null) { logger.debug("Received disconnected for untracked hub [{}]", hubId); disconnected(hubId); } else if(state.offline(hubBridge, clock.millis() - offlineTimeoutMs) && hubs.remove(hubId, state)) { logger.debug("Hub disconnected [{}]", hubId); metrics.onDisconnected(); disconnected(hubId); } else { logger.debug("Hub reconnected [{}]", hubId); } } @Inject  HubRegistry(
         Clock clock,
         HubDAO hubDao,
         Partitioner partitioner,
         PlatformMessageBus platformBus,
         HubRegistryConfig config,
         PlacePopulationCacheManager populationCacheMgr
   ); @WarmUp void start(); @PreDestroy void stop(); int getOnlineHubs(); boolean isOnline(String hubId); void online(String hubId, int partitionId, String hubBridge); void offline(String hubId, String hubBridge); boolean remove(String hubId); @Override void onPartitionsChanged(PartitionChangedEvent event);  }### Answer:
@Test public void testOffline() throws Exception { EasyMock.expect(mockClock.millis()).andReturn(1000L).once(); EasyMock.expect(mockClock.millis()).andReturn(1001L).once(); expectStreamPartitionAndReturn(0, ImmutableList.of(hub1)); expectGetHubByIdAndReturn(hub1); expectDisconnected(hub1.getId()); replay(); PartitionChangedEvent event = new PartitionChangedEvent(); event.setAddedPartitions(ImmutableSet.of(0)); event.setRemovedPartitions(ImmutableSet.of()); event.setPartitions(ImmutableSet.of(new DefaultPartition(0))); registry.onPartitionsChanged(event); assertEquals(1, registry.getOnlineHubs()); assertNoMessages(); registry.offline(hub1.getId(), "hub-bridge-0"); assertEquals(0, registry.getOnlineHubs()); assertValueChangeDown(hub1); assertNoMessages(); verify(); }