@Test public void assertExecuteWhenFetchDataIsNotEmptyAndDataIsOne() throws JobExecutionException { when(jobCaller.fetchData()).thenReturn(Collections.<Object>singletonList(1)); when(jobCaller.processData(1)).thenReturn(true); when(configService.getConcurrentDataProcessThreadCount()).thenReturn(2); unstreamingIndividualThroughputDataFlowElasticJob.execute(null); verify(jobCaller).processData(1); verify(configService).getConcurrentDataProcessThreadCount(); ElasticJobAssert.verifyForIsNotMisfireAndIsNotFailover( configService, shardingService, executionContextService, executionService, failoverService, shardingContext); ElasticJobAssert.assertProcessCountStatistics(1, 0); }
@Test public void assertExecuteWhenFetchDataIsNull() throws JobExecutionException { when(jobCaller.fetchData()).thenReturn(null); unstreamingIndividualThroughputDataFlowElasticJob.execute(null); verify(jobCaller, times(0)).processData(any()); ElasticJobAssert.verifyForIsNotMisfireAndIsNotFailover( configService, shardingService, executionContextService, executionService, failoverService, shardingContext); ElasticJobAssert.assertProcessCountStatistics(0, 0); }
@Test public void assertExecuteWhenFetchDataIsNotEmptyAndConcurrentDataProcessThreadCountIsOneAndProcessFailureWithException() throws JobExecutionException { when(jobCaller.fetchData()).thenReturn(Arrays.<Object>asList(1, 2)); doThrow(RuntimeException.class).when(jobCaller).processData(any()); when(configService.getConcurrentDataProcessThreadCount()).thenReturn(1); unstreamingIndividualThroughputDataFlowElasticJob.execute(null); verify(jobCaller).processData(1); verify(jobCaller).processData(2); verify(configService).getConcurrentDataProcessThreadCount(); ElasticJobAssert.verifyForIsNotMisfireAndIsNotFailover( configService, shardingService, executionContextService, executionService, failoverService, shardingContext); ElasticJobAssert.assertProcessCountStatistics(0, 2); }