use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class DescribeFunctionExecutorTest method shouldDescribeUDAF.
@Test
public void shouldDescribeUDAF() {
// When:
final FunctionDescriptionList functionList = (FunctionDescriptionList) CUSTOM_EXECUTORS.describeFunction().execute((ConfiguredStatement<DescribeFunction>) engine.configure("DESCRIBE FUNCTION MAX;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(functionList, new TypeSafeMatcher<FunctionDescriptionList>() {
@Override
protected boolean matchesSafely(final FunctionDescriptionList item) {
return functionList.getName().equals("MAX") && functionList.getType().equals(FunctionType.AGGREGATE);
}
@Override
public void describeTo(final Description description) {
description.appendText(functionList.getName());
}
});
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class DescribeFunctionExecutorTest method shouldDescribeUDTF.
@Test
public void shouldDescribeUDTF() {
// When:
final FunctionDescriptionList functionList = (FunctionDescriptionList) CUSTOM_EXECUTORS.describeFunction().execute((ConfiguredStatement<DescribeFunction>) engine.configure("DESCRIBE FUNCTION TEST_UDTF1;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(functionList, new TypeSafeMatcher<FunctionDescriptionList>() {
@Override
protected boolean matchesSafely(final FunctionDescriptionList item) {
return item.getName().equals("TEST_UDTF1") && item.getType().equals(FunctionType.TABLE);
}
@Override
public void describeTo(final Description description) {
description.appendText(functionList.getName());
}
});
assertThat(functionList.getFunctions(), hasSize(2));
final FunctionInfo expected1 = new FunctionInfo(Arrays.asList(new ArgumentInfo("foo", "INT", "", false)), "INT", "test_udtf1 int");
assertTrue(functionList.getFunctions().contains(expected1));
final FunctionInfo expected2 = new FunctionInfo(Arrays.asList(new ArgumentInfo("foo", "DOUBLE", "", false)), "DOUBLE", "test_udtf1 double");
assertTrue(functionList.getFunctions().contains(expected2));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class KsqlResourceTest method shouldSupportTopicInferenceInVerification.
@Test
public void shouldSupportTopicInferenceInVerification() {
// Given:
givenMockEngine();
givenSource(DataSourceType.KSTREAM, "ORDERS1", "ORDERS1", SOME_SCHEMA);
final String sql = "CREATE STREAM orders2 AS SELECT * FROM orders1;";
final String sqlWithTopic = "CREATE STREAM orders2 WITH(kafka_topic='orders2') AS SELECT * FROM orders1;";
final PreparedStatement<?> statementWithTopic = ksqlEngine.prepare(ksqlEngine.parse(sqlWithTopic).get(0), Collections.emptyMap());
final ConfiguredStatement<?> configuredStatement = ConfiguredStatement.of(statementWithTopic, SessionConfig.of(ksqlConfig, ImmutableMap.of()));
when(sandboxTopicInjector.inject(argThat(is(configured(preparedStatementText(sql)))))).thenReturn((ConfiguredStatement<Statement>) configuredStatement);
// When:
makeRequest(sql);
// Then:
verify(sandbox).plan(any(SandboxedServiceContext.class), eq(configuredStatement));
verify(commandStore).enqueueCommand(any(), argThat(is(commandWithStatement(sql))), any(Producer.class));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class KsqlResourceTest method shouldSupportTopicInferenceInExecution.
@Test
public void shouldSupportTopicInferenceInExecution() {
// Given:
givenMockEngine();
givenSource(DataSourceType.KSTREAM, "ORDERS1", "ORDERS1", SOME_SCHEMA);
final String sql = "CREATE STREAM orders2 AS SELECT * FROM orders1;";
final String sqlWithTopic = "CREATE STREAM orders2 WITH(kafka_topic='orders2') AS SELECT * FROM orders1;";
final PreparedStatement<?> statementWithTopic = ksqlEngine.prepare(ksqlEngine.parse(sqlWithTopic).get(0), Collections.emptyMap());
final ConfiguredStatement<?> configured = ConfiguredStatement.of(statementWithTopic, SessionConfig.of(ksqlConfig, ImmutableMap.of()));
when(topicInjector.inject(argThat(is(configured(preparedStatementText(sql)))))).thenReturn((ConfiguredStatement<Statement>) configured);
// When:
makeRequest(sql);
// Then:
verify(commandStore).enqueueCommand(any(), argThat(is(commandWithStatement(sqlWithTopic))), any());
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListPropertiesExecutorTest method shouldNotListUnrecognizedConnectProps.
@Test
public void shouldNotListUnrecognizedConnectProps() throws Exception {
// Given:
givenConnectWorkerProperties("group.id=list_properties_unit_test\n" + "key.converter=io.confluent.connect.avro.AvroConverter\n" + "value.converter=io.confluent.connect.avro.AvroConverter\n" + "offset.storage.topic=topic1\n" + "config.storage.topic=topic2\n" + "status.storage.topic=topic3\n" + "other.config=<potentially sensitive data that should not be shown>\n" + "sasl.jaas.config=<potentially sensitive data that should not be shown even though it's a recognized config>\n");
// When:
final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;").withConfig(new KsqlConfig(ImmutableMap.of("ksql.connect.worker.config", connectPropsFile))), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(properties.getProperties(), hasItem(new Property("ksql.connect.worker.config", "KSQL", connectPropsFile)));
assertThat(properties.getProperties(), hasItem(new Property("value.converter", "EMBEDDED CONNECT WORKER", "io.confluent.connect.avro.AvroConverter")));
assertThat(toMap(properties), not(hasKey("other.config")));
assertThat(toMap(properties), not(hasKey("sasl.jaas.config")));
}
Aggregations