MasterSlaveJobSummaryServiceImpl extends AbstractService implements MasterSlaveJobSummaryService { @Override public MasterSlaveJobSummary getJobSummary(String id) { MasterSlaveJobSummary masterSlaveJobSummary = baseDao.get(MasterSlaveJobSummary.class, id); MasterSlaveJobData masterSlaveJobData = masterSlaveApiFactory.jobApi().getJob(masterSlaveJobSummary.getGroupName(), masterSlaveJobSummary.getJobName()); if (masterSlaveJobData != null) { ReflectHelper.copyFieldValues(masterSlaveJobData.getData(), masterSlaveJobSummary); masterSlaveJobSummary.setOriginalJarFileName(masterSlaveJobData.getData().getJarFileName()); } else { List<String> jarFileNameList = masterSlaveJobService.getJarFileNameList(masterSlaveJobSummary.getGroupName(), masterSlaveJobSummary.getJobName()); if (ListHelper.isEmpty(jarFileNameList)) { throw new ServiceException("job detail not found."); } else { masterSlaveJobSummary.setOriginalJarFileName(jarFileNameList.get(0)); } } return masterSlaveJobSummary; }  @Override List<MasterSlaveJobSummary> getAllJobSummaries(); @Override synchronized void saveJobSummary(MasterSlaveJobSummary masterSlaveJobSummary); @Override void updateJobSummary(MasterSlaveJobData.Data data); @Override void updateJobSummary(String id); @Override MasterSlaveJobSummary getJobSummary(String id);  }
@Test public void getJobSummary() { masterSlaveJobService.saveJob(getSampleJarFile(), "com.zuoxiaolong"); List<MasterSlaveJobSummary> jobSummaries = masterSlaveJobSummaryService.getAllJobSummaries(); MasterSlaveJobSummary jobSummary = jobSummaries.get(0); String id = jobSummary.getId(); jobSummary.setJobCron("0 * * * * ?"); jobSummary.setMisfirePolicy("None"); jobSummary.setJarFileName("niubi-job-sample-spring.jar"); jobSummary.setOriginalJarFileName("niubi-job-sample-spring.jar"); jobSummary.setJobOperation("Start"); jobSummary.setContainerType("Spring"); masterSlaveJobSummaryService.saveJobSummary(jobSummary); jobSummary = masterSlaveJobSummaryService.getJobSummary(id); Assert.assertNotNull(jobSummary); Assert.assertEquals(jobSummary.getJobState(), "Shutdown"); MasterSlaveApiFactory apiFactory = new MasterSlaveApiFactoryImpl(client); MasterSlaveJobData.Data data = new MasterSlaveJobData.Data(); data.setJobState("Startup"); apiFactory.jobApi().updateJob(jobSummary.getGroupName(), jobSummary.getJobName(), data); jobSummary = masterSlaveJobSummaryService.getJobSummary(id); Assert.assertNotNull(jobSummary); Assert.assertEquals(jobSummary.getJobState(), "Startup"); }