JobFeService extends CommonFeService { public List<BatchJobInfoModel> findById(final String applicationId) { final LightminClientApplication lightminClientApplication = this.registrationBean.findById(applicationId); final List<String> registeredJobs = lightminClientApplication.getLightminClientInformation().getRegisteredJobs(); final List<BatchJobInfoModel> batchJobInfoModels = new ArrayList<>(); registeredJobs .forEach( jobName -> { final JobInfo jobInfo = this.jobServerService.getJobInfo(jobName, lightminClientApplication); final BatchJobInfoModel batchJobInfoModel = new BatchJobInfoModel(); batchJobInfoModel.setInstanceCount(jobInfo.getJobInstanceCount()); batchJobInfoModel.setJobName(jobInfo.getJobName()); batchJobInfoModels.add(batchJobInfoModel); } ); return batchJobInfoModels; } JobFeService(final JobServerService jobServerService, final RegistrationBean registrationBean); List<BatchJobInfoModel> findById(final String applicationId);  }
@Test public void testFindById() { final LightminClientApplication lightminClientApplication = ServiceTestHelper.createLightminClientApplication(); when(this.registrationBean.findById(APPLICATION_ID)).thenReturn(lightminClientApplication); when(this.jobServerService.getJobInfo(anyString(), any())).thenReturn(ApiTestHelper.createJobInfo("test_job", 2)); final List<BatchJobInfoModel> result = this.jobFeService.findById(APPLICATION_ID); BDDAssertions.then(result).isNotNull(); BDDAssertions.then(result.size()).isEqualTo(2); }