public KsqlEntityList execute(
      final KsqlSecurityContext securityContext,
      final List<ParsedStatement> statements,
      final SessionProperties sessionProperties
  ) {
    final KsqlEntityList entities = new KsqlEntityList();
    for (final ParsedStatement parsed : statements) {
      final PreparedStatement<?> prepared = ksqlEngine.prepare(
          parsed,
          (isVariableSubstitutionEnabled(sessionProperties)
              ? sessionProperties.getSessionVariables()
              : Collections.emptyMap())
      );

      executeStatement(
          securityContext,
          prepared,
          sessionProperties,
          entities
      ).ifPresent(entities::add);
    }
    return entities;
  }
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
  @Test
  public void shouldCallPrepareStatementWithSessionVariables() {
    // Given
    final StatementExecutor<CreateStream> customExecutor =
        givenReturningExecutor(CreateStream.class, mock(KsqlEntity.class));
    givenRequestHandler(ImmutableMap.of(CreateStream.class, customExecutor));
    final Map<String, String> sessionVariables = ImmutableMap.of("a", "1");
    when(sessionProperties.getSessionVariables()).thenReturn(sessionVariables);
    when(ksqlConfig.getBoolean(KsqlConfig.KSQL_VARIABLE_SUBSTITUTION_ENABLE)).thenReturn(true);

    // When
    final List<ParsedStatement> statements = KSQL_PARSER.parse(SOME_STREAM_SQL);
    handler.execute(securityContext, statements, sessionProperties);

    // Then
    verify(ksqlEngine).prepare(statements.get(0), sessionVariables);
    verify(sessionProperties).getSessionVariables();
  }