tkalkirill commented on code in PR #2448: URL: https://github.com/apache/ignite-3/pull/2448#discussion_r1294545267
########## modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TableTestUtils.java: ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.table; + +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; +import org.apache.ignite.internal.catalog.CatalogManager; +import org.apache.ignite.internal.catalog.CatalogService; +import org.apache.ignite.internal.catalog.commands.ColumnParams; +import org.apache.ignite.internal.catalog.commands.CreateTableParams; +import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; +import org.jetbrains.annotations.Nullable; + +/** + * Utils to manage tables inside tests. + */ +public class TableTestUtils { + /** + * Creates table in the catalog. + * + * @param catalogManager Catalog manager. + * @param schemaName Schema name. + * @param zoneName Zone name. + * @param tableName Table name. + * @param columns Table columns. + * @param pkColumns Primary key columns. + */ + public static void createTable( + CatalogManager catalogManager, + String schemaName, + String zoneName, + String tableName, + List<ColumnParams> columns, + List<String> pkColumns + ) { + CreateTableParams.Builder builder = CreateTableParams.builder() + .schemaName(schemaName) + .zone(zoneName) + .tableName(tableName) + .columns(columns) + .primaryKeyColumns(pkColumns); + + assertThat(catalogManager.createTable(builder.build()), willCompleteSuccessfully()); + } + + /** + * Returns table ID form catalog, {@code null} if table is absent. + * + * @param catalogService Catalog service. + * @param tableName Table name. + * @param timestamp Timestamp. + */ + public static @Nullable Integer getTableId(CatalogService catalogService, String tableName, long timestamp) { + CatalogTableDescriptor table = catalogService.table(tableName, timestamp); + + return table == null ? null : table.id(); + } + + /** + * Returns table ID form catalog. Review Comment: fix it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
