Search in sources :

Example 1 with QueryLogger

use of io.confluent.ksql.logging.query.QueryLogger in project ksql by confluentinc.

the class KsqlResourceTest method queryLoggerShouldReceiveTerminateStatementsWhenHandleKsqlStatementWithTerminate.

@Test
public void queryLoggerShouldReceiveTerminateStatementsWhenHandleKsqlStatementWithTerminate() {
    // Given:
    final PersistentQueryMetadata queryMetadata = createQuery("CREATE STREAM test_explain AS SELECT * FROM test_stream;", emptyMap());
    final String terminateSql = "TERMINATE " + queryMetadata.getQueryId() + ";";
    // When:
    try (MockedStatic<QueryLogger> logger = Mockito.mockStatic(QueryLogger.class)) {
        ksqlResource.handleKsqlStatements(securityContext, new KsqlRequest(terminateSql, ImmutableMap.of(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"), emptyMap(), 0L));
        // Then:
        logger.verify(() -> QueryLogger.info("Query terminated", terminateSql), times(1));
    }
}
Also used : KsqlRequest(io.confluent.ksql.rest.entity.KsqlRequest) QueryLogger(io.confluent.ksql.logging.query.QueryLogger) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) Test(org.junit.Test)

Aggregations

QueryLogger (io.confluent.ksql.logging.query.QueryLogger)1 KsqlRequest (io.confluent.ksql.rest.entity.KsqlRequest)1 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1