public static void throwTooManyActivePushQueriesException(
          final KsqlExecutionContext executionContext,
          final KsqlRestConfig ksqlRestConfig,
          final String statementStr
  ) {
    final String sanitizedMessage = String.format(
        "Not executing statement(s) as it would cause the number "
            + "of active, push queries to exceed the configured limit. "
            + "Terminate existing PUSH queries, "
            + "or increase the '%s' setting via the 'ksql-server.properties' file. "
            + "Current push query count: %d. Configured limit: %d.",
        KsqlRestConfig.MAX_PUSH_QUERIES,
        getNumLivePushQueries(executionContext),
        getPushQueryLimit(ksqlRestConfig)
    );
    final String unloggedMessage = String.format(
        "Not executing statement(s) '%s' as it would cause the number "
            + "of active, push queries to exceed the configured limit. "
            + "Terminate existing PUSH queries, "
            + "or increase the '%s' setting via the 'ksql-server.properties' file. "
            + "Current push query count: %d. Configured limit: %d.",
        statementStr,
        KsqlRestConfig.MAX_PUSH_QUERIES,
        getNumLivePushQueries(executionContext),
        getPushQueryLimit(ksqlRestConfig)
    );
    throw new KsqlStatementException(
        sanitizedMessage,
        unloggedMessage,
        statementStr
    );
  }
@Test
  public void shouldThrowWhenPushQueryLimitExceeded() {
    // Given:
    final String statementStr = "my statement";
    givenAllLiveQueries(10);
    givenActivePersistentQueries(4);
    givenPushQueryLimit(3);

    // When:
    final KsqlStatementException e = assertThrows(
            KsqlStatementException.class,
            () -> QueryCapacityUtil.throwTooManyActivePushQueriesException(ksqlEngine, ksqlRestConfig, statementStr)
    );

    // Then:
    assertThat(e.getUnloggedMessage(), containsString(
            "Not executing statement(s) 'my statement' as it would cause the number "
                    + "of active, push queries to exceed the configured limit. "
                    + "Terminate existing PUSH queries, "
                    + "or increase the 'ksql.max.push.queries' setting "
                    + "via the 'ksql-server.properties' file. "
                    + "Current push query count: 6. Configured limit: 3."));
    assertThat(e.getMessage(), containsString(
            "Not executing statement(s) as it would cause the number "
                    + "of active, push queries to exceed the configured limit. "
                    + "Terminate existing PUSH queries, "
                    + "or increase the 'ksql.max.push.queries' setting "
                    + "via the 'ksql-server.properties' file. "
                    + "Current push query count: 6. Configured limit: 3."));
    assertThat(e.getSqlStatement(), containsString("my statement"));
  }