AbstractHealthEventHandler implements HealthEventHandler { @SuppressWarnings("unchecked") @Override public void handle(AbstractInstanceEvent event) { if(!supports(event)) { return; } T t = (T) event; doHandle(t); }  @SuppressWarnings("unchecked") @Override void handle(AbstractInstanceEvent event); @VisibleForTesting void setChecker(SiteReliabilityChecker checker);  }
@SuppressWarnings("unchecked") @Test public void testHandle() { when(consoleConfig.getDelayedMarkDownDcClusters()).thenReturn(null); when(metaCache.inBackupDc(any())).thenReturn(true); future.setSuccess(true); when(consoleServiceManager.quorumSatisfy(anyList(), any())).thenReturn(true); when(defaultDelayPingActionCollector.getState(any())).thenReturn(HEALTH_STATE.HEALTHY); when(defaultDelayPingActionCollector.getState(instance.getRedisInstanceInfo().getHostPort())).thenReturn(HEALTH_STATE.DOWN); AbstractInstanceEvent event = new InstanceUp(instance); upHandler.handle(event); downHandler.handle(event); sickHandler.handle(event); verify(finalStateSetterManager, times(1)).set(any(ClusterShardHostPort.class), anyBoolean()); event = new InstanceSick(instance); upHandler.handle(event); downHandler.handle(event); sickHandler.handle(event); verify(finalStateSetterManager, times(2)).set(any(ClusterShardHostPort.class), anyBoolean()); event = new InstanceDown(instance); upHandler.handle(event); downHandler.handle(event); sickHandler.handle(event); verify(finalStateSetterManager, times(3)).set(any(ClusterShardHostPort.class), anyBoolean()); }