### Question:
KsqlEngine implements Closeable { public List<QueryMetadata> createQueries(final String queries) throws Exception { final MetaStore metaStoreCopy = metaStore.clone(); return planQueries( parseQueries( queries, Collections.emptyMap(), metaStoreCopy ), new HashMap<>(), metaStoreCopy ); } KsqlEngine(final KsqlConfig ksqlConfig, final KafkaTopicClient topicClient);  KsqlEngine(
      final KsqlConfig ksqlConfig,
      final KafkaTopicClient topicClient,
      final SchemaRegistryClient schemaRegistryClient,
      final MetaStore metaStore
  ); List<QueryMetadata> buildMultipleQueries(
      final String queriesString,
      final Map<String, Object> overriddenProperties
  ); QueryMetadata getQueryExecutionPlan(final Query query); static String getStatementString(
      final SqlBaseParser.SingleStatementContext singleStatementContext
  ); List<Statement> getStatements(final String sqlString); Query addInto(
      final Query query, final QuerySpecification querySpecification,
      final String intoName,
      final Map<String, Expression> intoProperties,
      final Optional<Expression> partitionByExpression
  ); Set<QueryMetadata> getLivePersistentQueries(); MetaStore getMetaStore(); FunctionRegistry getFunctionRegistry(); KafkaTopicClient getTopicClient(); DdlCommandExec getDdlCommandExec(); boolean terminateQuery(final QueryId queryId, final boolean closeStreams); Map<QueryId, PersistentQueryMetadata> getPersistentQueries(); static List<String> getImmutableProperties(); Map<String, Object> getKsqlConfigProperties(); KsqlConfig getKsqlConfig(); long numberOfLiveQueries(); long numberOfPersistentQueries(); @Override void close(); void removeTemporaryQuery(QueryMetadata queryMetadata); DdlCommandResult executeDdlStatement(
      String sqlExpression, final DdlStatement statement,
      final Map<String, Object> overriddenProperties
  ); SchemaRegistryClient getSchemaRegistryClient(); List<QueryMetadata> createQueries(final String queries);  }### Answer:
@Test public void shouldCreatePersistentQueries() throws Exception { final List<QueryMetadata> queries = ksqlEngine.createQueries("create table bar as select * from test2;" + "create table foo as select * from test2;"); assertThat(queries.size(), equalTo(2)); final PersistentQueryMetadata queryOne = (PersistentQueryMetadata) queries.get(0); final PersistentQueryMetadata queryTwo = (PersistentQueryMetadata) queries.get(1); assertThat(queryOne.getEntity(), equalTo("BAR")); assertThat(queryTwo.getEntity(), equalTo("FOO")); }
@Test(expected = ParseFailedException.class) public void shouldFailToCreateQueryIfSelectingFromNonExistentEntity() throws Exception { ksqlEngine.createQueries("select * from bar;"); }
@Test(expected = ParseFailedException.class) public void shouldFailWhenSyntaxIsInvalid() throws Exception { ksqlEngine.createQueries("blah;"); }
@Test public void shouldFailIfReferentialIntegrityIsViolated() { try { ksqlEngine.createQueries("create table bar as select * from test2;" + "create table foo as select * from test2;"); ksqlEngine.createQueries("drop table foo;"); Assert.fail(); } catch (Exception e) { assertThat(e.getCause(), instanceOf(KsqlReferentialIntegrityException.class)); assertThat(e.getMessage(), equalTo( "Exception while processing statements :Cannot drop the data source. " + "The following queries read from this source: [] and the following queries write into " + "this source: [CTAS_FOO]. You need to terminate them before dropping this source.")); } }