@SuppressWarnings("unchecked") @Test public void testExecuteWithPredicate() throws Exception { JobExecutionContext context = mock(JobExecutionContext.class); Scheduler scheduler = mock(Scheduler.class); GriffinMeasure measure = createGriffinMeasure("measureName", createFileExistPredicate(), createFileExistPredicate()); JobDetail jd = createJobDetail(JsonUtil.toJson(measure), ""); BatchJob job = new BatchJob(1L, "jobName", "qName", "qGroup", false); List<Trigger> triggers = Arrays.asList(createSimpleTrigger(2, 0)); given(context.getJobDetail()).willReturn(jd); given(measureRepo.findOne(Matchers.anyLong())).willReturn(measure); given(jobRepo.findOne(Matchers.anyLong())).willReturn(job); given(factory.getScheduler()).willReturn(scheduler); given((List<Trigger>) scheduler.getTriggersOfJob(Matchers.any( JobKey.class))).willReturn(triggers); given(scheduler.checkExists(Matchers.any(TriggerKey.class))) .willReturn(false); given(jobRepo.save(Matchers.any(BatchJob.class))).willReturn(job); given(scheduler.checkExists(Matchers.any(JobKey.class))) .willReturn(false); jobInstance.execute(context); verify(context, times(1)).getJobDetail(); }
@Override @Transactional public void execute(JobExecutionContext context) { try { initParam(context); setSourcesPartitionsAndPredicates(measure.getDataSources()); createJobInstance(job.getConfigMap()); } catch (Exception e) { LOGGER.error("Create predicate job failure.", e); } }
JobInstance implements Job { @Override @Transactional public void execute(JobExecutionContext context) { try { initParam(context); setSourcesPartitionsAndPredicates(measure.getDataSources()); createJobInstance(job.getConfigMap()); } catch (Exception e) { LOGGER.error("Create predicate job failure.", e); } } }
JobInstance implements Job { @Override @Transactional public void execute(JobExecutionContext context) { try { initParam(context); setSourcesPartitionsAndPredicates(measure.getDataSources()); createJobInstance(job.getConfigMap()); } catch (Exception e) { LOGGER.error("Create predicate job failure.", e); } }  }
JobInstance implements Job { @Override @Transactional public void execute(JobExecutionContext context) { try { initParam(context); setSourcesPartitionsAndPredicates(measure.getDataSources()); createJobInstance(job.getConfigMap()); } catch (Exception e) { LOGGER.error("Create predicate job failure.", e); } }  @Override @Transactional void execute(JobExecutionContext context); }
JobInstance implements Job { @Override @Transactional public void execute(JobExecutionContext context) { try { initParam(context); setSourcesPartitionsAndPredicates(measure.getDataSources()); createJobInstance(job.getConfigMap()); } catch (Exception e) { LOGGER.error("Create predicate job failure.", e); } }  @Override @Transactional void execute(JobExecutionContext context); static final String MEASURE_KEY; static final String PREDICATES_KEY; static final String PREDICATE_JOB_NAME; static final String INTERVAL; static final String REPEAT; static final String CHECK_DONEFILE_SCHEDULE; }