@Deployment(
      resources = {
        "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml"
      })
  public void testSetJobDuedateDateNull() {
    ProcessInstance processInstance =
        runtimeService.startProcessInstanceByKey("exceptionInJobExecution");

    // The execution is waiting in the first usertask. This contains a boundary
    // timer event.
    Job timerJob =
        managementService
            .createJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();

    assertNotNull("No job found for process instance", timerJob);
    assertNotNull(timerJob.getDuedate());

    managementService.setJobDuedate(timerJob.getId(), null);

    timerJob =
        managementService
            .createJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();

    assertNull(timerJob.getDuedate());
  }
  @Deployment(
      resources = {
        "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml"
      })
  public void testSetJobDuedate() {
    ProcessInstance processInstance =
        runtimeService.startProcessInstanceByKey("exceptionInJobExecution");

    // The execution is waiting in the first usertask. This contains a boundary
    // timer event.
    Job timerJob =
        managementService
            .createJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();

    assertNotNull("No job found for process instance", timerJob);
    assertNotNull(timerJob.getDuedate());

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DATE, 3); // add 3 days on the actual date
    managementService.setJobDuedate(timerJob.getId(), cal.getTime());

    Job newTimerJob =
        managementService
            .createJobQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();

    // normalize date for mysql dropping fractional seconds in time values
    int SECOND = 1000;
    assertEquals(
        (cal.getTime().getTime() / SECOND) * SECOND,
        (newTimerJob.getDuedate().getTime() / SECOND) * SECOND);
  }