コード例 #1
0
  @Test
  public void cancelJob() throws SchedulerException, InterruptedException {
    MutableInt mutableInt = new MutableInt(0);
    HashMap<String, Object> map = new HashMap<>();
    map.put(TestJob.COUNTER, mutableInt);

    schedulingService.scheduleJob(GROUP_NAME, new SourceConfig(TEST_JOB, TEST_JOB, 100, map));
    assertTrue(schedulingService.checkJobExists(TEST_JOB, GROUP_NAME));

    schedulingService.cancelJobs(GROUP_NAME);
    assertFalse(schedulingService.checkJobExists(TEST_JOB, GROUP_NAME));
  }
コード例 #2
0
  @Test
  public void sourceJobShouldBeCanceled() throws SchedulerException, InterruptedException {
    // this test should find no widget and therefore cancel the job
    when(widgetConfigRepository.exists(GROUP_NAME)).thenReturn(false);

    schedulingService.scheduleJob(
        GROUP_NAME, new SourceConfig(TEST_JOB, TEST_JOB, 100, Collections.emptyMap()));
    Thread.sleep(200); // time for scheduling service to cancel the job

    assertFalse(schedulingService.checkJobExists(TEST_JOB, GROUP_NAME));
    verify(sourceDataRepository).deleteByWidgetId(eq(GROUP_NAME));
  }