public WorkflowOverviewResponse getWorkflowOverview(@NotNull String workflowId) {
    return withMetricLogError(
        () ->
            withRetryableQuery(
                GET_WORKFLOW_OVERVIEW_QUERY,
                stmt -> {
                  stmt.setString(1, workflowId);
                  stmt.setString(2, workflowId);
                },
                result -> {
                  if (result.next()) {
                    return workflowOverviewFromResult(workflowId, result);
                  }
                  throw new MaestroNotFoundException(
                      "Cannot find workflow [%s], which is either not created or has been deleted.",
                      workflowId);
                }),
        "getWorkflowOverview",
        "Failed to get the workflow overview for [{}]",
        workflowId);
  }
@Test
  public void testGetWorkflowOverview() throws Exception {
    WorkflowDefinition wfd = loadWorkflow(TEST_WORKFLOW_ID1);
    workflowDao.addWorkflowDefinition(wfd, wfd.getPropertiesSnapshot().extractProperties());
    assertNotNull(wfd.getInternalId());
    long internalId = wfd.getInternalId();
    wfd.setIsActive(false);
    workflowDao.addWorkflowDefinition(wfd, null);
    assertEquals(internalId, (long) wfd.getInternalId());

    WorkflowOverviewResponse response = workflowDao.getWorkflowOverview(TEST_WORKFLOW_ID1);
    assertEquals(TEST_WORKFLOW_ID1, response.getWorkflowId());
    assertEquals(1L, response.getActiveVersionId().longValue());
    assertEquals(2L, response.getLatestVersionId().longValue());
    assertEquals(1L, response.getDefaultVersionId().longValue());
    assertEquals(RunStrategy.create(20), response.getPropertiesSnapshot().getRunStrategy());
    assertEquals(20L, response.getStepConcurrency().longValue());
    Map<WorkflowInstance.Status, Long> statusStats = new EnumMap<>(WorkflowInstance.Status.class);
    statusStats.put(WorkflowInstance.Status.CREATED, 0L);
    statusStats.put(WorkflowInstance.Status.IN_PROGRESS, 0L);
    statusStats.put(WorkflowInstance.Status.PAUSED, 0L);
    assertEquals(statusStats, response.getNonterminalInstances());
    assertEquals(0L, response.getFailedInstances().longValue());
    assertNull(response.getLatestInstanceId());

    workflowDao.deactivate(TEST_WORKFLOW_ID1, User.create("test"));
    WorkflowOverviewResponse response1 = workflowDao.getWorkflowOverview(TEST_WORKFLOW_ID1);
    assertNull(response1.getActiveVersionId());
    assertEquals(2L, response1.getLatestVersionId().longValue());
    assertEquals(2L, response1.getDefaultVersionId().longValue());

    AssertHelper.assertThrows(
        "Cannot get non-existing workflow overview",
        MaestroNotFoundException.class,
        "Cannot find workflow [non-existing], which is either not created or has been deleted.",
        () -> workflowDao.getWorkflowOverview("non-existing"));
  }