public final void addJob(
        String jobName, String groupName, StorageType storageType, org.quartz.Trigger trigger) {

      JobKey jobKey = new JobKey(jobName, groupName);

      JobBuilder jobBuilder = JobBuilder.newJob(MessageSenderJob.class);

      jobBuilder = jobBuilder.withIdentity(jobKey);

      JobDetail jobDetail = jobBuilder.build();

      JobDataMap jobDataMap = jobDetail.getJobDataMap();

      jobDataMap.put(SchedulerEngine.MESSAGE, _jsonFactory.serialize(new Message()));
      jobDataMap.put(SchedulerEngine.DESTINATION_NAME, _TEST_DESTINATION_NAME);
      jobDataMap.put(SchedulerEngine.STORAGE_TYPE, storageType.toString());

      JobState jobState = new JobState(TriggerState.NORMAL);

      jobState.addException(new Exception(), new Date());

      jobDataMap.put(SchedulerEngine.JOB_STATE, JobStateSerializeUtil.serialize(jobState));

      _jobs.put(jobKey, new Tuple(jobDetail, trigger, TriggerState.NORMAL));
    }
  @Test
  public void testSuppressError() throws Exception {
    SchedulerResponse schedulerResponse =
        _quartzSchedulerEngine.getScheduledJob(
            _TEST_JOB_NAME_0, _MEMORY_TEST_GROUP_NAME, StorageType.MEMORY);

    Message message = schedulerResponse.getMessage();

    JobState jobState = (JobState) message.get(SchedulerEngine.JOB_STATE);

    Assert.assertNotNull(jobState.getExceptions());

    _quartzSchedulerEngine.suppressError(
        _TEST_JOB_NAME_0, _MEMORY_TEST_GROUP_NAME, StorageType.MEMORY);

    schedulerResponse =
        _quartzSchedulerEngine.getScheduledJob(
            _TEST_JOB_NAME_0, _MEMORY_TEST_GROUP_NAME, StorageType.MEMORY);

    message = schedulerResponse.getMessage();

    jobState = (JobState) message.get(SchedulerEngine.JOB_STATE);

    Assert.assertNull(jobState.getExceptions());
  }
  protected void handleException(Message message, Exception exception) {
    JobState jobState = (JobState) message.get(SchedulerEngine.JOB_STATE);

    if (jobState != null) {
      jobState.addException(exception, new Date());
    }
  }
  protected void updateJobState(
      Scheduler scheduler, JobKey jobKey, TriggerState triggerState, boolean suppressError)
      throws Exception {

    JobDetail jobDetail = scheduler.getJobDetail(jobKey);

    if (jobDetail == null) {
      return;
    }

    JobDataMap jobDataMap = jobDetail.getJobDataMap();

    JobState jobState = getJobState(jobDataMap);

    if (triggerState != null) {
      jobState.setTriggerState(triggerState);
    }

    if (suppressError) {
      jobState.clearExceptions();
    }

    jobDataMap.put(SchedulerEngine.JOB_STATE, JobStateSerializeUtil.serialize(jobState));

    scheduler.addJob(jobDetail, true);
  }
  protected void assertTriggerState(
      SchedulerResponse schedulerResponse, TriggerState expectedTriggerState) {

    Message message = schedulerResponse.getMessage();

    JobState jobState = (JobState) message.get(SchedulerEngine.JOB_STATE);

    TriggerState triggerState = jobState.getTriggerState();

    Assert.assertEquals(expectedTriggerState, triggerState);
  }
  protected void unschedule(Scheduler scheduler, JobKey jobKey) throws Exception {

    JobDetail jobDetail = scheduler.getJobDetail(jobKey);

    TriggerKey triggerKey = new TriggerKey(jobKey.getName(), jobKey.getGroup());

    if (jobDetail == null) {
      return;
    }

    unregisterMessageListener(scheduler, jobKey);

    JobDataMap jobDataMap = jobDetail.getJobDataMap();

    JobState jobState = getJobState(jobDataMap);

    Trigger trigger = scheduler.getTrigger(triggerKey);

    if (trigger == null) {
      return;
    }

    jobState.setTriggerDate(SchedulerEngine.END_TIME, new Date());
    jobState.setTriggerDate(SchedulerEngine.FINAL_FIRE_TIME, trigger.getPreviousFireTime());
    jobState.setTriggerDate(SchedulerEngine.NEXT_FIRE_TIME, null);
    jobState.setTriggerDate(SchedulerEngine.PREVIOUS_FIRE_TIME, trigger.getPreviousFireTime());
    jobState.setTriggerDate(SchedulerEngine.START_TIME, trigger.getStartTime());

    jobState.setTriggerState(TriggerState.UNSCHEDULED);

    jobState.clearExceptions();

    jobDataMap.put(SchedulerEngine.JOB_STATE, JobStateSerializeUtil.serialize(jobState));

    scheduler.unscheduleJob(triggerKey);

    scheduler.addJob(jobDetail, true);
  }