JobExecutionFeService extends CommonFeService { public ContentPageModel<List<JobExecutionModel>> getJobExecutionModelPage(final String applicationInstanceId, final String jobName, final Integer startIndex, final Integer pageSize) { final LightminClientApplication lightminClientApplication = this.findLightminClientApplicatonById(applicationInstanceId); final JobInstancePage jobInstancesPage = this.jobServerService.getJobInstances(jobName, startIndex, pageSize, lightminClientApplication); final ContentPageModel<List<JobExecutionModel>> page = new ContentPageModel<>(startIndex, pageSize, jobInstancesPage.getTotalJobInstanceCount()); final List<JobExecutionModel> jobExecutionModels = new ArrayList<>(); for (final JobInstance jobInstance : jobInstancesPage.getJobInstances()) { final JobExecutionPage jobExecutionsForInstance = this.jobServerService.getJobExecutionPage(jobInstance.getId(), lightminClientApplication); final List<JobExecution> jobExecutions = jobExecutionsForInstance.getJobExecutions(); for (final JobExecution jobExecution : jobExecutions) { final JobExecutionModel jobExecutionModel = new JobExecutionModel(); this.mapJobExecution(jobExecution, jobExecutionModel); jobExecutionModels.add(jobExecutionModel); } } page.setValue(jobExecutionModels); return page; } JobExecutionFeService(final RegistrationBean registrationBean, final JobServerService jobServerService); ContentPageModel<List<JobExecutionModel>> getJobExecutionModelPage(final String applicationInstanceId,
                                                                              final String jobName,
                                                                              final Integer startIndex,
                                                                              final Integer pageSize); JobExecutionDetailsModel getJobExecutionDetailsModel(final Long jobExecutionId,
                                                                final String applicationInstanceId); void restartJobExecution(final Long jobExecutionId, final String applicationInstanceId); void stopJobExecution(final Long jobExecutionId, final String applicationInstanceId);  }
@Test public void testGetJobExecutionModelPage() { final int pageSize = 5; final int startIndex = 0; final Long jobInstanceId = 1L; final LightminClientApplication applicationInstance = new LightminClientApplication(); when(this.registrationBean.findById(APPLICATION_INSTANCE_ID)).thenReturn(applicationInstance); final JobExecutionPage jobExecutionPage = ApiTestHelper.createJobExecutionPage(pageSize); when(this.jobServerService. getJobExecutionPage(jobInstanceId, applicationInstance)).thenReturn(jobExecutionPage); final JobInstancePage jobInstancePage = ApiTestHelper.createJobInstancePage(1); when(this.jobServerService.getJobInstances("test_job", 0, pageSize, applicationInstance)).thenReturn(jobInstancePage); final ContentPageModel<List<JobExecutionModel>> result = this.jobExecutionFeService.getJobExecutionModelPage(APPLICATION_INSTANCE_ID, "test_job", startIndex, pageSize); BDDAssertions.then(result).isNotNull(); BDDAssertions.then(result.getValue()).isNotNull(); BDDAssertions.then(result.getValue().size()).isEqualTo(pageSize); }