use of org.apache.ignite.configuration.validation.ValidationContext in project ignite-3 by apache.
the class TableValidatorImplTest method testMisalignedColumnNamedListKeys.
/**
* Tests that column names and column keys inside a Named List must be equal.
*/
@Test
void testMisalignedColumnNamedListKeys(@InjectConfiguration(polymorphicExtensions = RocksDbDataRegionConfigurationSchema.class) DataStorageConfiguration dbCfg) {
NamedListView<TableView> oldValue = tablesCfg.tables().value();
TableConfiguration tableCfg = tablesCfg.tables().get("table");
CompletableFuture<Void> tableChangeFuture = tableCfg.columns().change(columnsChange -> columnsChange.create("ololo", columnChange -> columnChange.changeName("not ololo").changeType(columnTypeChange -> columnTypeChange.changeType("STRING")).changeNullable(true)));
assertThat(tableChangeFuture, willBe(nullValue(Void.class)));
ValidationContext<NamedListView<TableView>> ctx = mockContext(oldValue, dbCfg.value());
ArgumentCaptor<ValidationIssue> issuesCaptor = validate(ctx);
assertThat(issuesCaptor.getAllValues(), hasSize(1));
assertThat(issuesCaptor.getValue().message(), is(equalTo("Column name \"not ololo\" does not match its Named List key: \"ololo\"")));
}
use of org.apache.ignite.configuration.validation.ValidationContext in project ignite-3 by apache.
the class TableValidatorImplTest method testMisalignedIndexNamedListKeys.
/**
* Tests that index names and index keys inside a Named List must be equal.
*/
@Test
void testMisalignedIndexNamedListKeys(@InjectConfiguration(polymorphicExtensions = RocksDbDataRegionConfigurationSchema.class) DataStorageConfiguration dbCfg) {
NamedListView<TableView> oldValue = tablesCfg.tables().value();
TableConfiguration tableCfg = tablesCfg.tables().get("table");
CompletableFuture<Void> tableChangeFuture = tableCfg.indices().change(indicesChange -> indicesChange.create("ololo", indexChange -> indexChange.changeName("not ololo").convert(HashIndexChange.class).changeColNames("id")));
assertThat(tableChangeFuture, willBe(nullValue(Void.class)));
ValidationContext<NamedListView<TableView>> ctx = mockContext(oldValue, dbCfg.value());
ArgumentCaptor<ValidationIssue> issuesCaptor = validate(ctx);
assertThat(issuesCaptor.getAllValues(), hasSize(1));
assertThat(issuesCaptor.getValue().message(), is(equalTo("Index name \"not ololo\" does not match its Named List key: \"ololo\"")));
}
Aggregations