Search in sources :

Example 1 with DataStorageConfiguration

use of org.apache.ignite.configuration.schemas.store.DataStorageConfiguration 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\"")));
}
Also used : HashIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema) PageMemoryDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.PageMemoryDataRegionConfigurationSchema) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) CompletableFuture(java.util.concurrent.CompletableFuture) PartialIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema) SortedIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema) InjectConfiguration(org.apache.ignite.internal.configuration.testframework.InjectConfiguration) ArgumentCaptor(org.mockito.ArgumentCaptor) UnsafeMemoryAllocatorConfigurationSchema(org.apache.ignite.configuration.schemas.store.UnsafeMemoryAllocatorConfigurationSchema) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ConfigurationExtension(org.apache.ignite.internal.configuration.testframework.ConfigurationExtension) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Matchers.hasSize(org.hamcrest.Matchers.hasSize) RocksDbDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataStorageView(org.apache.ignite.configuration.schemas.store.DataStorageView) Matchers.empty(org.hamcrest.Matchers.empty) ValidationContext(org.apache.ignite.configuration.validation.ValidationContext) NamedListView(org.apache.ignite.configuration.NamedListView) DataStorageConfiguration(org.apache.ignite.configuration.schemas.store.DataStorageConfiguration) TablesConfiguration(org.apache.ignite.configuration.schemas.table.TablesConfiguration) CompletableFutureMatcher.willBe(org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) TableView(org.apache.ignite.configuration.schemas.table.TableView) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Nullable(org.jetbrains.annotations.Nullable) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue) Matchers.equalTo(org.hamcrest.Matchers.equalTo) HashIndexChange(org.apache.ignite.configuration.schemas.table.HashIndexChange) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) NamedListView(org.apache.ignite.configuration.NamedListView) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) TableView(org.apache.ignite.configuration.schemas.table.TableView) Test(org.junit.jupiter.api.Test)

Example 2 with DataStorageConfiguration

use of org.apache.ignite.configuration.schemas.store.DataStorageConfiguration 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\"")));
}
Also used : HashIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema) PageMemoryDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.PageMemoryDataRegionConfigurationSchema) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) CompletableFuture(java.util.concurrent.CompletableFuture) PartialIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema) SortedIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema) InjectConfiguration(org.apache.ignite.internal.configuration.testframework.InjectConfiguration) ArgumentCaptor(org.mockito.ArgumentCaptor) UnsafeMemoryAllocatorConfigurationSchema(org.apache.ignite.configuration.schemas.store.UnsafeMemoryAllocatorConfigurationSchema) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ConfigurationExtension(org.apache.ignite.internal.configuration.testframework.ConfigurationExtension) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Matchers.hasSize(org.hamcrest.Matchers.hasSize) RocksDbDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DataStorageView(org.apache.ignite.configuration.schemas.store.DataStorageView) Matchers.empty(org.hamcrest.Matchers.empty) ValidationContext(org.apache.ignite.configuration.validation.ValidationContext) NamedListView(org.apache.ignite.configuration.NamedListView) DataStorageConfiguration(org.apache.ignite.configuration.schemas.store.DataStorageConfiguration) TablesConfiguration(org.apache.ignite.configuration.schemas.table.TablesConfiguration) CompletableFutureMatcher.willBe(org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) TableView(org.apache.ignite.configuration.schemas.table.TableView) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Nullable(org.jetbrains.annotations.Nullable) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue) Matchers.equalTo(org.hamcrest.Matchers.equalTo) HashIndexChange(org.apache.ignite.configuration.schemas.table.HashIndexChange) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) HashIndexChange(org.apache.ignite.configuration.schemas.table.HashIndexChange) NamedListView(org.apache.ignite.configuration.NamedListView) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) TableView(org.apache.ignite.configuration.schemas.table.TableView) Test(org.junit.jupiter.api.Test)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)2 TimeUnit (java.util.concurrent.TimeUnit)2 NamedListView (org.apache.ignite.configuration.NamedListView)2 DataStorageConfiguration (org.apache.ignite.configuration.schemas.store.DataStorageConfiguration)2 DataStorageView (org.apache.ignite.configuration.schemas.store.DataStorageView)2 PageMemoryDataRegionConfigurationSchema (org.apache.ignite.configuration.schemas.store.PageMemoryDataRegionConfigurationSchema)2 RocksDbDataRegionConfigurationSchema (org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema)2 UnsafeMemoryAllocatorConfigurationSchema (org.apache.ignite.configuration.schemas.store.UnsafeMemoryAllocatorConfigurationSchema)2 HashIndexChange (org.apache.ignite.configuration.schemas.table.HashIndexChange)2 HashIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema)2 PartialIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema)2 SortedIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema)2 TableConfiguration (org.apache.ignite.configuration.schemas.table.TableConfiguration)2 TableView (org.apache.ignite.configuration.schemas.table.TableView)2 TablesConfiguration (org.apache.ignite.configuration.schemas.table.TablesConfiguration)2 ValidationContext (org.apache.ignite.configuration.validation.ValidationContext)2 ValidationIssue (org.apache.ignite.configuration.validation.ValidationIssue)2 ConfigurationExtension (org.apache.ignite.internal.configuration.testframework.ConfigurationExtension)2 InjectConfiguration (org.apache.ignite.internal.configuration.testframework.InjectConfiguration)2 CompletableFutureMatcher.willBe (org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe)2