Search in sources :

Example 6 with Property

use of io.confluent.ksql.rest.entity.PropertiesList.Property in project ksql by confluentinc.

the class ListPropertiesExecutorTest method shouldListPropertiesWithOverrides.

@Test
public void shouldListPropertiesWithOverrides() {
    // When:
    final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;").withConfigOverrides(ImmutableMap.of("ksql.streams.auto.offset.reset", "latest")), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(properties.getProperties(), hasItem(new Property("ksql.streams.auto.offset.reset", "KSQL", "latest")));
    assertThat(properties.getOverwrittenProperties(), hasItem("ksql.streams.auto.offset.reset"));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 7 with Property

use of io.confluent.ksql.rest.entity.PropertiesList.Property in project ksql by confluentinc.

the class ListPropertiesExecutor method execute.

public static StatementExecutorResponse execute(final ConfiguredStatement<ListProperties> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
    final KsqlConfigResolver resolver = new KsqlConfigResolver();
    final Map<String, String> engineProperties = statement.getSessionConfig().getConfig(false).getAllConfigPropsWithSecretsObfuscated();
    final List<Property> mergedProperties = mergedProperties(statement);
    final List<String> overwritten = mergedProperties.stream().filter(property -> !Objects.equals(engineProperties.get(property.getName()), property.getValue())).map(Property::getName).collect(Collectors.toList());
    final List<String> defaultProps = mergedProperties.stream().filter(property -> resolver.resolve(property.getName(), false).map(resolved -> resolved.isDefaultValue(property.getValue())).orElse(false)).map(Property::getName).collect(Collectors.toList());
    return StatementExecutorResponse.handled(Optional.of(new PropertiesList(statement.getStatementText(), mergedProperties, overwritten, defaultProps)));
}
Also used : KsqlConfigResolver(io.confluent.ksql.config.KsqlConfigResolver) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property)

Example 8 with Property

use of io.confluent.ksql.rest.entity.PropertiesList.Property in project ksql by confluentinc.

the class PropertiesListTableBuilderTest method shouldHandleClientOverwrittenProperties.

@Test
public void shouldHandleClientOverwrittenProperties() {
    // Given:
    final PropertiesList propList = new PropertiesList("list properties;", ImmutableList.of(new Property(SOME_KEY, "KSQL", "earliest")), ImmutableList.of(SOME_KEY), Collections.emptyList());
    // When:
    final Table table = builder.buildTable(propList);
    // Then:
    assertThat(getRows(table), contains(row(SOME_KEY, "KSQL", "SESSION", "earliest")));
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 9 with Property

use of io.confluent.ksql.rest.entity.PropertiesList.Property in project ksql by confluentinc.

the class PropertiesListTableBuilderTest method shouldHandleDefaultProperties.

@Test
public void shouldHandleDefaultProperties() {
    // Given:
    final PropertiesList propList = new PropertiesList("list properties;", ImmutableList.of(new Property(SOME_KEY, "KSQL", "earliest")), Collections.emptyList(), ImmutableList.of(SOME_KEY));
    // When:
    final Table table = builder.buildTable(propList);
    // Then:
    assertThat(getRows(table), contains(row(SOME_KEY, "KSQL", "", "earliest")));
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 10 with Property

use of io.confluent.ksql.rest.entity.PropertiesList.Property in project ksql by confluentinc.

the class ConsoleTest method testPrintPropertyList.

@Test
public void testPrintPropertyList() {
    // Given:
    final List<Property> properties = new ArrayList<>();
    properties.add(new Property("k1", "KSQL", "1"));
    properties.add(new Property("k2", "KSQL", "v2"));
    properties.add(new Property("k3", "KSQL", "true"));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new PropertiesList("e", properties, Collections.emptyList(), Collections.emptyList())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ArrayList(java.util.ArrayList) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Matchers.containsString(org.hamcrest.Matchers.containsString) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Aggregations

PropertiesList (io.confluent.ksql.rest.entity.PropertiesList)11 Property (io.confluent.ksql.rest.entity.PropertiesList.Property)11 Test (org.junit.Test)10 Table (io.confluent.ksql.cli.console.table.Table)4 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)3 KsqlConfig (io.confluent.ksql.util.KsqlConfig)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 KsqlConfigResolver (io.confluent.ksql.config.KsqlConfigResolver)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 KsqlRequest (io.confluent.ksql.rest.entity.KsqlRequest)1 ArrayList (java.util.ArrayList)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1