public WorkflowInstanceActionResponse kill(
      String workflowId, long workflowInstanceId, long workflowRunId, User caller) {
    return terminate(
        workflowId, workflowInstanceId, workflowRunId, Actions.WorkflowInstanceAction.KILL, caller);
  }
@Test
  public void testKill() {
    when(instanceDao.tryTerminateQueuedInstance(any(), any(), any())).thenReturn(true);
    when(instance.getStatus()).thenReturn(WorkflowInstance.Status.CREATED);
    boolean res = actionHandler.kill("test-workflow", 1, 1, user).isCompleted();
    assertTrue(res);
    verify(instanceDao, times(1)).getLatestWorkflowInstanceRun("test-workflow", 1);
    verify(instanceDao, times(1))
        .tryTerminateQueuedInstance(any(), eq(WorkflowInstance.Status.FAILED), anyString());

    when(instance.getStatus()).thenReturn(WorkflowInstance.Status.IN_PROGRESS);
    when(instance.getExecutionId()).thenReturn("foo");
    res = actionHandler.kill("test-workflow", 1, 1, user).isCompleted();
    assertFalse(res);
    verify(instanceDao, times(2)).getLatestWorkflowInstanceRun("test-workflow", 1);
    verify(instanceDao, times(1))
        .tryTerminateQueuedInstance(any(), eq(WorkflowInstance.Status.FAILED), anyString());
    verify(actionDao, times(1)).terminate(any(), any(), any(), anyString());

    when(instance.getStatus()).thenReturn(WorkflowInstance.Status.PAUSED);
    when(instance.getExecutionId()).thenReturn(null);
    res = actionHandler.kill("test-workflow", 1, 1, user).isCompleted();
    assertTrue(res);
    verify(instanceDao, times(3)).getLatestWorkflowInstanceRun("test-workflow", 1);
    verify(instanceDao, times(2))
        .tryTerminateQueuedInstance(any(), eq(WorkflowInstance.Status.FAILED), anyString());
    verify(actionDao, times(1)).terminate(any(), any(), any(), anyString());
  }