@VisibleForTesting
  MaestroWorkflow getMaestroWorkflow(String workflowId) {
    return withRetryableQuery(
        GET_MAESTRO_WORKFLOW,
        stmt -> stmt.setString(1, workflowId),
        result -> {
          if (result.next()) {
            return maestroWorkflowFromResult(result);
          }
          return null;
        });
  }
@Test
  public void testGetMaestroWorkflow() throws Exception {
    WorkflowDefinition wfd = loadWorkflow(TEST_WORKFLOW_ID1);
    assertEquals(TEST_WORKFLOW_ID1, wfd.getWorkflow().getId());
    WorkflowDefinition definition =
        workflowDao.addWorkflowDefinition(wfd, wfd.getPropertiesSnapshot().extractProperties());
    assertNotNull(wfd.getInternalId());
    assertEquals(wfd, definition);

    MaestroWorkflow maestroWorkflow = workflowDao.getMaestroWorkflow(wfd.getWorkflow().getId());
    assertEquals(1L, maestroWorkflow.getActiveVersionId().longValue());
    assertNotNull(maestroWorkflow.getActivateTime());
    assertNotNull(maestroWorkflow.getActivatedBy());
    assertNotNull(maestroWorkflow.getModifyTime());
    assertNull("metadata should be unset", maestroWorkflow.getMetadata());
    assertNull("definition should be unset", maestroWorkflow.getDefinition());
    assertEquals(
        wfd.getPropertiesSnapshot().getOwner(), maestroWorkflow.getPropertiesSnapshot().getOwner());
    assertEquals(
        wfd.getPropertiesSnapshot().getAccessControl(),
        maestroWorkflow.getPropertiesSnapshot().getAccessControl());
    assertEquals(
        wfd.getPropertiesSnapshot().getRunStrategy(),
        maestroWorkflow.getPropertiesSnapshot().getRunStrategy());
    assertEquals(
        wfd.getPropertiesSnapshot().getStepConcurrency(),
        maestroWorkflow.getPropertiesSnapshot().getStepConcurrency());
    assertEquals(
        wfd.getPropertiesSnapshot().getAlerting(),
        maestroWorkflow.getPropertiesSnapshot().getAlerting());
    assertEquals(1L, maestroWorkflow.getLatestVersionId().longValue());
  }