public boolean resetTaskOffset(String previousFailedTaskId) {
    final Task task = executionDAOFacade.getTaskById(previousFailedTaskId);
    final Workflow workflow =
        executionDAOFacade.getWorkflowById(task.getWorkflowInstanceId(), true);
    Optional<Task> currentTask =
        workflow.getTasks().stream()
            .filter(t -> task.getTaskId().equals(t.getRetriedTaskId()))
            .findFirst();
    if (currentTask.isPresent()) {
      final Task enqueuedTask = currentTask.get();
      return queueDAO.resetOffsetTime(
          QueueUtils.getQueueName(enqueuedTask), enqueuedTask.getTaskId());
    }
    return false;
  }
@Test
  public void testResetOffset() {
    String workflowId = "workflow-id";
    String taskId = "task-id-1";
    String taskId1 = "task-id-2";

    Task maestroTask = new Task();
    maestroTask.setTaskType(Constants.MAESTRO_TASK_NAME);
    maestroTask.setReferenceTaskName("maestroTask");
    maestroTask.setWorkflowInstanceId(workflowId);
    maestroTask.setScheduledTime(System.currentTimeMillis());
    maestroTask.setTaskId(taskId);
    maestroTask.setStatus(Task.Status.FAILED);
    maestroTask.setStartTime(123);
    maestroTask.setCallbackAfterSeconds(0);

    Task maestroTask1 = new Task();
    maestroTask1.setTaskType(Constants.MAESTRO_TASK_NAME);
    maestroTask1.setReferenceTaskName("maestroTask");
    maestroTask1.setWorkflowInstanceId(workflowId);
    maestroTask1.setScheduledTime(System.currentTimeMillis());
    maestroTask1.setTaskId(taskId1);
    maestroTask1.setStatus(Task.Status.SCHEDULED);
    maestroTask1.setStartTime(123);
    maestroTask1.setCallbackAfterSeconds(0);
    maestroTask1.setRetryCount(1);
    maestroTask1.setRetriedTaskId(taskId);

    List<Task> tasks = new ArrayList<>();
    tasks.add(maestroTask);
    tasks.add(maestroTask1);

    Workflow workflow = new Workflow();
    workflow.setWorkflowId(workflowId);
    workflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    workflow.setTasks(tasks);

    when(executionDAOFacade.getTaskById(taskId)).thenReturn(maestroTask);
    when(executionDAOFacade.getWorkflowById(workflowId, true)).thenReturn(workflow);
    when(queueDAO.resetOffsetTime(Constants.MAESTRO_TASK_NAME, taskId1)).thenReturn(true);

    assertTrue(maestroWorkflowExecutor.resetTaskOffset(taskId));
  }