Skip to content

Commit

Permalink
[apache#2883] Move assertion functions from AbstractIT to ITUtils for…
Browse files Browse the repository at this point in the history
… clarity.
  • Loading branch information
laiyousin committed Apr 11, 2024
1 parent ee76305 commit b8b5f49
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void testCreateAndLoadMysqlTable() {
Assertions.assertEquals(createdTable.columns().length, columns.length);

for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], createdTable.columns()[i]);
ITUtils.assertColumn(columns[i], createdTable.columns()[i]);
}

Table loadTable = tableCatalog.loadTable(tableIdentifier);
Expand All @@ -364,7 +364,7 @@ void testCreateAndLoadMysqlTable() {
}
Assertions.assertEquals(loadTable.columns().length, columns.length);
for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], loadTable.columns()[i]);
ITUtils.assertColumn(columns[i], loadTable.columns()[i]);
}
}

Expand Down Expand Up @@ -821,10 +821,10 @@ void testCreateTableIndex() {
Distributions.NONE,
new SortOrder[0],
indexes);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, createdTable);
Table table = tableCatalog.loadTable(tableIdentifier);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, table);

NameIdentifier id = NameIdentifier.of(metalakeName, catalogName, schemaName, "test_failed");
Expand Down Expand Up @@ -922,10 +922,10 @@ public void testAutoIncrement() {
new SortOrder[0],
indexes);
// Test create auto increment key success.
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, createdTable);
Table table = tableCatalog.loadTable(tableIdentifier);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, table);

// Test alter table. auto increment exist.
Expand All @@ -942,7 +942,7 @@ public void testAutoIncrement() {
col4,
col5
};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(alterColumns), properties, indexes, table);

// UpdateColumnComment
Expand All @@ -957,7 +957,7 @@ public void testAutoIncrement() {
col4,
col5
};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(alterColumns), properties, indexes, table);

// RenameColumn
Expand All @@ -977,7 +977,7 @@ public void testAutoIncrement() {
Indexes.createMysqlPrimaryKey(new String[][] {{"col_1_1"}, {"col_2"}}),
Indexes.unique("u1_key", new String[][] {{"col_2"}, {"col_3"}})
};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(alterColumns), properties, indexes, table);

tableCatalog.dropTable(tableIdentifier);
Expand Down Expand Up @@ -1158,22 +1158,26 @@ void testMySQLSpecialTableName() {
Table t1 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t1_name));
Arrays.stream(t1.columns()).anyMatch(c -> Objects.equals(c.name(), "t112"));
assertionsTableInfo(t1_name, table_comment, Arrays.asList(t1_col), properties, t1_indexes, t1);
ITUtils.assertionsTableInfo(
t1_name, table_comment, Arrays.asList(t1_col), properties, t1_indexes, t1);

Table t2 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t2_name));
Arrays.stream(t2.columns()).anyMatch(c -> Objects.equals(c.name(), "t212"));
assertionsTableInfo(t2_name, table_comment, Arrays.asList(t2_col), properties, t2_indexes, t2);
ITUtils.assertionsTableInfo(
t2_name, table_comment, Arrays.asList(t2_col), properties, t2_indexes, t2);

Table t3 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t3_name));
Arrays.stream(t3.columns()).anyMatch(c -> Objects.equals(c.name(), "t_12"));
assertionsTableInfo(t3_name, table_comment, Arrays.asList(t3_col), properties, t3_indexes, t3);
ITUtils.assertionsTableInfo(
t3_name, table_comment, Arrays.asList(t3_col), properties, t3_indexes, t3);

Table t4 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t4_name));
Arrays.stream(t4.columns()).anyMatch(c -> Objects.equals(c.name(), "_1__"));
assertionsTableInfo(t4_name, table_comment, Arrays.asList(t4_col), properties, t4_indexes, t4);
ITUtils.assertionsTableInfo(
t4_name, table_comment, Arrays.asList(t4_col), properties, t4_indexes, t4);
}

@Test
Expand Down Expand Up @@ -1205,10 +1209,10 @@ void testMySQLTableNameCaseSensitive() {
Distributions.NONE,
new SortOrder[0],
indexes);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
"tableName", table_comment, Arrays.asList(newColumns), properties, indexes, createdTable);
Table table = tableCatalog.loadTable(tableIdentifier);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
"tableName", table_comment, Arrays.asList(newColumns), properties, indexes, table);

// Test create table with same name but different case
Expand All @@ -1230,7 +1234,7 @@ void testMySQLTableNameCaseSensitive() {
Assertions.assertEquals("TABLENAME", tableAgain.name());

table = tableCatalog.loadTable(tableIdentifier2);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
"TABLENAME", table_comment, Arrays.asList(newColumns), properties, indexes, table);
}

Expand Down Expand Up @@ -1345,7 +1349,7 @@ void testOperationTableIndex() {
Indexes.unique("u1_key", new String[][] {{"col_2"}, {"col_3"}}),
Indexes.createMysqlPrimaryKey(new String[][] {{"col_1"}})
};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);

// delete index and add new column and index.
Expand All @@ -1367,7 +1371,7 @@ void testOperationTableIndex() {
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));
Column col4 = Column.of("col_4", Types.VarCharType.of(255), null, true, false, null);
newColumns = new Column[] {col1, col2, col3, col4};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);

// Add a previously existing index
Expand All @@ -1387,7 +1391,7 @@ void testOperationTableIndex() {
};
table =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);
}

Expand Down Expand Up @@ -1454,7 +1458,7 @@ void testAddColumnAutoIncrement() {
Column col6 = Column.of("col_6", Types.LongType.get(), "id", false, true, null);
Index[] indices = new Index[] {Indexes.createMysqlPrimaryKey(new String[][] {{"col_6"}})};
newColumns = new Column[] {col1, col2, col3, col4, col5, col6};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indices, table);

// Test the auto-increment property of modified fields
Expand All @@ -1464,7 +1468,7 @@ void testAddColumnAutoIncrement() {
col6 = Column.of("col_6", Types.LongType.get(), "id", false, false, null);
indices = new Index[] {Indexes.createMysqlPrimaryKey(new String[][] {{"col_6"}})};
newColumns = new Column[] {col1, col2, col3, col4, col5, col6};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indices, table);

// Add the auto-increment attribute to the field
Expand All @@ -1474,7 +1478,7 @@ void testAddColumnAutoIncrement() {
col6 = Column.of("col_6", Types.LongType.get(), "id", false, true, null);
indices = new Index[] {Indexes.createMysqlPrimaryKey(new String[][] {{"col_6"}})};
newColumns = new Column[] {col1, col2, col3, col4, col5, col6};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indices, table);
}

Expand Down Expand Up @@ -1516,7 +1520,7 @@ void testAddColumnDefaultValue() {
Table table = tableCatalog.loadTable(tableIdentifier);
newColumns = new Column[] {col1, col2, col3, col4};

assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName,
table_comment,
Arrays.asList(newColumns),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ void testCreateTableWithArrayType() {
Assertions.assertEquals(tableName, createdTable.name());
Assertions.assertEquals(columns.length, createdTable.columns().length);
for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], createdTable.columns()[i]);
ITUtils.assertColumn(columns[i], createdTable.columns()[i]);
}

Table loadTable = tableCatalog.loadTable(tableIdentifier);
Assertions.assertEquals(tableName, loadTable.name());
Assertions.assertEquals(columns.length, loadTable.columns().length);
for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], loadTable.columns()[i]);
ITUtils.assertColumn(columns[i], loadTable.columns()[i]);
}
}

Expand Down Expand Up @@ -406,7 +406,7 @@ void testCreateAndLoadPostgreSqlTable() {
Assertions.assertEquals(createdTable.columns().length, columns.length);

for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], createdTable.columns()[i]);
ITUtils.assertColumn(columns[i], createdTable.columns()[i]);
}

Table loadTable = tableCatalog.loadTable(tableIdentifier);
Expand All @@ -419,7 +419,7 @@ void testCreateAndLoadPostgreSqlTable() {
}
Assertions.assertEquals(loadTable.columns().length, columns.length);
for (int i = 0; i < columns.length; i++) {
assertColumn(columns[i], loadTable.columns()[i]);
ITUtils.assertColumn(columns[i], loadTable.columns()[i]);
}
}

Expand Down Expand Up @@ -647,10 +647,10 @@ void testCreateIndexTable() {
Distributions.NONE,
new SortOrder[0],
indexes);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, createdTable);
Table table = tableCatalog.loadTable(tableIdentifier);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), properties, indexes, table);

// Test create index complex fields fail.
Expand Down Expand Up @@ -1019,22 +1019,26 @@ void testPGSpecialTableName() {
Table t1 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t1_name));
Arrays.stream(t1.columns()).anyMatch(c -> Objects.equals(c.name(), "t112"));
assertionsTableInfo(t1_name, table_comment, Arrays.asList(t1_col), properties, t1_indexes, t1);
ITUtils.assertionsTableInfo(
t1_name, table_comment, Arrays.asList(t1_col), properties, t1_indexes, t1);

Table t2 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t2_name));
Arrays.stream(t2.columns()).anyMatch(c -> Objects.equals(c.name(), "t212"));
assertionsTableInfo(t2_name, table_comment, Arrays.asList(t2_col), properties, t2_indexes, t2);
ITUtils.assertionsTableInfo(
t2_name, table_comment, Arrays.asList(t2_col), properties, t2_indexes, t2);

Table t3 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t3_name));
Arrays.stream(t3.columns()).anyMatch(c -> Objects.equals(c.name(), "t_12"));
assertionsTableInfo(t3_name, table_comment, Arrays.asList(t3_col), properties, t3_indexes, t3);
ITUtils.assertionsTableInfo(
t3_name, table_comment, Arrays.asList(t3_col), properties, t3_indexes, t3);

Table t4 =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, t4_name));
Arrays.stream(t4.columns()).anyMatch(c -> Objects.equals(c.name(), "_1__"));
assertionsTableInfo(t4_name, table_comment, Arrays.asList(t4_col), properties, t4_indexes, t4);
ITUtils.assertionsTableInfo(
t4_name, table_comment, Arrays.asList(t4_col), properties, t4_indexes, t4);
}

@Test
Expand All @@ -1061,15 +1065,15 @@ void testPGTableNameCaseSensitive() {
Distributions.NONE,
new SortOrder[0],
indexes);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
"tablename",
"low case table name",
Arrays.asList(newColumns),
properties,
indexes,
createdTable);
Table table = tableCatalog.loadTable(tableIdentifier);
assertionsTableInfo(
ITUtils.assertionsTableInfo(
"tablename", "low case table name", Arrays.asList(newColumns), properties, indexes, table);

// Test create table with same name but different case
Expand Down Expand Up @@ -1260,7 +1264,7 @@ void testOperationTableIndex() {
Indexes.unique("u1_key", new String[][] {{"col_2"}, {"col_3"}}),
Indexes.primary("pk1_key", new String[][] {{"col_1"}})
};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);

// delete index and add new column and index.
Expand All @@ -1282,7 +1286,7 @@ void testOperationTableIndex() {
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));
Column col4 = Column.of("col_4", Types.VarCharType.of(255), null, true, false, null);
newColumns = new Column[] {col1, col2, col3, col4};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);

// Add a previously existing index
Expand All @@ -1302,7 +1306,7 @@ void testOperationTableIndex() {
};
table =
tableCatalog.loadTable(NameIdentifier.of(metalakeName, catalogName, schemaName, tableName));
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName, table_comment, Arrays.asList(newColumns), createProperties(), indexes, table);
}

Expand Down Expand Up @@ -1342,7 +1346,7 @@ void testAddColumnAutoIncrement() {

Column col5 = Column.of("col_5", Types.LongType.get(), "id", false, true, null);
newColumns = new Column[] {col1, col2, col3, col4, col5};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName,
table_comment,
Arrays.asList(newColumns),
Expand All @@ -1356,7 +1360,7 @@ void testAddColumnAutoIncrement() {
table = tableCatalog.loadTable(tableIdentifier);
col5 = Column.of("col_5", Types.LongType.get(), "id", false, false, null);
newColumns = new Column[] {col1, col2, col3, col4, col5};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName,
table_comment,
Arrays.asList(newColumns),
Expand All @@ -1370,7 +1374,7 @@ void testAddColumnAutoIncrement() {
table = tableCatalog.loadTable(tableIdentifier);
col5 = Column.of("col_5", Types.LongType.get(), "id", false, true, null);
newColumns = new Column[] {col1, col2, col3, col4, col5};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName,
table_comment,
Arrays.asList(newColumns),
Expand Down Expand Up @@ -1418,7 +1422,7 @@ void testAddColumnDefaultValue() {
Table table = tableCatalog.loadTable(tableIdentifier);

newColumns = new Column[] {col1, col2, col3};
assertionsTableInfo(
ITUtils.assertionsTableInfo(
tableName,
table_comment,
Arrays.asList(newColumns),
Expand Down
Loading

0 comments on commit b8b5f49

Please sign in to comment.