JobFacade { public void failoverIfNecessary() { if (configService.isFailover() && !serverService.isJobPausedManually()) { failoverService.failoverIfNecessary(); } } JobFacade(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration, final List<ElasticJobListener> elasticJobListeners); String getJobName(); int getConcurrentDataProcessThreadCount(); void checkMaxTimeDiffSecondsTolerable(); void failoverIfNecessary(); void registerJobBegin(final JobExecutionMultipleShardingContext shardingContext); void registerJobCompleted(final JobExecutionMultipleShardingContext shardingContext, boolean completeFlag); JobExecutionMultipleShardingContext getShardingContext(); boolean misfireIfNecessary(final List<Integer> shardingItems); void clearMisfire(final List<Integer> shardingItems); boolean isExecuteMisfired(final List<Integer> shardingItems); boolean isEligibleForJobRunning(); boolean isNeedSharding(); void updateOffset(final int item, final String offset); void cleanPreviousExecutionInfo(); void beforeJobExecuted(final JobExecutionMultipleShardingContext shardingContext); void afterJobExecuted(final JobExecutionMultipleShardingContext shardingContext); boolean inSkipTime(); boolean isLocalServerDisabled();  }
@Test public void testFailoverIfUnnecessary() { when(configService.isFailover()).thenReturn(false); jobFacade.failoverIfNecessary(); verify(failoverService, times(0)).failoverIfNecessary(); }
@Test public void testFailoverIfNecessaryButIsPaused() { when(configService.isFailover()).thenReturn(true); when(serverService.isJobPausedManually()).thenReturn(true); jobFacade.failoverIfNecessary(); verify(failoverService, times(0)).failoverIfNecessary(); }
@Test public void testFailoverIfNecessary() { when(configService.isFailover()).thenReturn(true); when(serverService.isJobPausedManually()).thenReturn(false); jobFacade.failoverIfNecessary(); verify(failoverService).failoverIfNecessary(); }