public static String getMaskedStatement(final String query) {
    try {
      final ParseTree tree = DefaultKsqlParser.getParseTree(query);
      return new Visitor().visit(tree);
    } catch (final Exception | StackOverflowError e) {
      return fallbackMasking(query);
    }
  }
@Test
  public void shouldMaskMixedValidInvalidStatements() {
    // Given:
    // Typo in "WITH" => "WIT"
    final String query = "CREATE SOURCE CONNECTOR test_connector WITH ("
        + "    \"connector.class\" = 'PostgresSource', \n"
        + "    'connection.url' = 'jdbc:postgresql://localhost:5432/my.db',\n"
        + "    `mode`='bulk',\n"
        + "    \"topic.prefix\"='jdbc-',\n"
        + "    \"table.whitelist\"='users',\n"
        + "    \"key\"='username');\n"
        + "CREATE STREAM `stream` (id varchar) WIT ('format' = 'avro', \"kafka_topic\" = 'test_topic', partitions=3);";

    // When
    final String maskedQuery = QueryMask.getMaskedStatement(query);

    // Then
    final String expected = "CREATE SOURCE CONNECTOR test_connector WITH (    \"connector.class\" = 'PostgresSource', \n    "
        + "'connection.url'='[string]',\n    "
        + "`mode`='[string]',\n    "
        + "\"topic.prefix\"='[string]',\n    "
        + "\"table.whitelist\"='[string]',\n    "
        + "\"key\"='[string]');\n"
        + "CREATE STREAM `stream` (id varchar) WIT ('format'='[string]', \"kafka_topic\"='[string]', partitions=3);";

    assertThat(maskedQuery, is(expected));
  }