Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more test cases on TableMetaDataNode #32973

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,14 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class TableMetaDataNodeTest {

@Test
void assertGetTableNameByActiveVersionNode() {
Optional<String> actual = TableMetaDataNode.getTableNameByActiveVersionNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table/active_version");
assertTrue(actual.isPresent());
assertThat(actual.get(), is("foo_table"));
}

@Test
void assertIsTableActiveVersionNode() {
assertTrue(TableMetaDataNode.isTableActiveVersionNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table/active_version"));
}

@Test
void assertIsTableNode() {
assertTrue(TableMetaDataNode.isTableNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table"));
void assertGetMetaDataTablesNode() {
assertThat(TableMetaDataNode.getMetaDataTablesNode("foo_db", "foo_schema"), is("/metadata/foo_db/schemas/foo_schema/tables"));
}

@Test
Expand All @@ -63,4 +52,38 @@ void assertGetTableVersionNode() {
void assertGetTableNode() {
assertThat(TableMetaDataNode.getTableNode("foo_db", "foo_schema", "foo_table"), is("/metadata/foo_db/schemas/foo_schema/tables/foo_table"));
}

@Test
void assertGetTableNameByActiveVersionNode() {
Optional<String> actual = TableMetaDataNode.getTableNameByActiveVersionNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table/active_version");
assertTrue(actual.isPresent());
assertThat(actual.get(), is("foo_table"));
}

@Test
void assertGetTableNameByActiveVersionNodeIfNotFound() {
assertFalse(TableMetaDataNode.getTableNameByActiveVersionNode("/xxx/foo_db/schemas/foo_schema/tables/foo_table/active_version").isPresent());
}

@Test
void assertGetTableName() {
Optional<String> actual = TableMetaDataNode.getTableName("/metadata/foo_db/schemas/foo_schema/tables/foo_table");
assertTrue(actual.isPresent());
assertThat(actual.get(), is("foo_table"));
}

@Test
void assertGetTableNameIfNotFound() {
assertFalse(TableMetaDataNode.getTableName("/xxx/foo_db/schemas/foo_schema/tables/foo_table").isPresent());
}

@Test
void assertIsTableActiveVersionNode() {
assertTrue(TableMetaDataNode.isTableActiveVersionNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table/active_version"));
}

@Test
void assertIsTableNode() {
assertTrue(TableMetaDataNode.isTableNode("/metadata/foo_db/schemas/foo_schema/tables/foo_table"));
}
}