JobLauncherFeService extends CommonFeService { public JobLauncherModel getJobLauncherModel(final String jobName, final String applicationInstanceId) { final LightminClientApplication lightminClientApplication = this.findLightminClientApplicatonById(applicationInstanceId); final JobParameters oldParameters = this.jobServerService.getLastJobParameters(jobName, lightminClientApplication); final String oldParametersString = ApiParameterParser.parseParametersToString(oldParameters); final JobLauncherModel model = new JobLauncherModel(); model.setJobParameters(oldParametersString); model.setJobName(jobName); model.setApplicationInstanceId(applicationInstanceId); return model; } JobLauncherFeService(final RegistrationBean registrationBean, final JobServerService jobServerService); JobLauncherModel getJobLauncherModel(final String jobName,
                                                final String applicationInstanceId); void launchJob(final JobLauncherModel jobLauncherModel);  }
@Test public void testGetJobLauncherModel() { final String jobName = "testJob"; final String applicationInstanceId = "testApp"; final String name1 = "longValue"; final String name2 = "stringValue"; final JobParameter jobParameter1 = ApiTestHelper.createJobParameter(1L, ParameterType.LONG); final JobParameter jobParameter2 = ApiTestHelper.createJobParameter("test", ParameterType.STRING); final Map<String, JobParameter> jobParameterMap = new HashMap<>(); ApiTestHelper.addJobParameter(jobParameterMap, name1, jobParameter1); ApiTestHelper.addJobParameter(jobParameterMap, name2, jobParameter2); final JobParameters jobParameters = ApiTestHelper.createJobParameters(jobParameterMap); final LightminClientApplication applicationInstance = new LightminClientApplication(); when(this.registrationBean.findById(applicationInstanceId)).thenReturn(applicationInstance); when(this.jobServerService.getLastJobParameters(jobName, applicationInstance)).thenReturn(jobParameters); final JobLauncherModel result = this.jobLauncherFeService.getJobLauncherModel(jobName, applicationInstanceId); BDDAssertions.then(result).isNotNull(); BDDAssertions.then(result.getJobParameters()).isEqualTo(ApiParameterParser.parseParametersToString(jobParameters)); BDDAssertions.then(result.getApplicationInstanceId()).isEqualTo(applicationInstanceId); BDDAssertions.then(result.getJobName()).isEqualTo(jobName); }