MasterSlaveJobSummaryServiceImpl extends AbstractService implements MasterSlaveJobSummaryService { @Override public synchronized void saveJobSummary(MasterSlaveJobSummary masterSlaveJobSummary) { MasterSlaveJobData masterSlaveJobData = masterSlaveApiFactory.jobApi().getJob(masterSlaveJobSummary.getGroupName(), masterSlaveJobSummary.getJobName()); MasterSlaveJobData.Data data; if (masterSlaveJobData == null) { data = new MasterSlaveJobData.Data(); } else { data = masterSlaveJobData.getData(); } ReflectHelper.copyFieldValuesSkipNull(masterSlaveJobSummary, data); MasterSlaveJob masterSlaveJob = masterSlaveJobService.getJob(masterSlaveJobSummary.getGroupName(), masterSlaveJobSummary.getJobName(), masterSlaveJobSummary.getJarFileName()); data.setJobOperationLogId(masterSlaveJobLogService.saveJobLog(masterSlaveJobSummary)); data.setPackagesToScan(masterSlaveJob.getPackagesToScan()); data.setContainerType(masterSlaveJob.getContainerType()); MasterSlaveJobSummary param = new MasterSlaveJobSummary(); param.setGroupName(data.getGroupName()); param.setJobName(data.getJobName()); MasterSlaveJobSummary masterSlaveJobSummaryInDb = baseDao.getUnique(MasterSlaveJobSummary.class, param); masterSlaveJobSummaryInDb.setJobState("Executing"); baseDao.update(masterSlaveJobSummaryInDb); masterSlaveApiFactory.jobApi().saveJob(masterSlaveJobSummary.getGroupName(), masterSlaveJobSummary.getJobName(), data); }  @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 saveJobSummary() { masterSlaveJobService.saveJob(getSampleJarFile(), "com.zuoxiaolong"); List<MasterSlaveJobSummary> jobSummaries = masterSlaveJobSummaryService.getAllJobSummaries(); MasterSlaveJobSummary jobSummary = jobSummaries.get(0); 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 = baseDao.get(MasterSlaveJobSummary.class, jobSummary.getId()); Assert.assertNotNull(jobSummary); Assert.assertEquals("Executing", jobSummary.getJobState()); }