Skip to content

Commit

Permalink
fixTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Jun 2, 2024
1 parent 55fe85b commit ab3057f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
assert service.getChildren(newParent) == newParent_children_expected

// Test Child
def child_parent_expected = new ParentInfo(parent.toString(), type)
def child_parent_expected = new ParentInfo(newParent.toString(), type)
assert child_parent_expected == service.getParent(child)
assert service.getChildren(child).size() == 0
}
Expand Down Expand Up @@ -206,7 +206,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{

// Test Parent
assert service.getParent(parent) == null
def parent_children_expected = [new ChildInfo(child.toString(), type)] as Set
def parent_children_expected = [new ChildInfo(newChild.toString(), type)] as Set
assert parent_children_expected == service.getChildren(parent)

// Test Child
Expand All @@ -226,6 +226,8 @@ class ParentChildRelMetadataServiceSpec extends Specification{
def child = QualifiedName.ofTable(catalog, database, "c")
def type = "clone";
service.createParentChildRelation(parent, child, type)
when:
service.drop(child)

// Test Parent
def parent_parent_actual = service.getParent(parent)
Expand All @@ -248,8 +250,11 @@ class ParentChildRelMetadataServiceSpec extends Specification{
def child = QualifiedName.ofTable(catalog, database, "c")
def type = "clone";
service.createParentChildRelation(parent, child, type)
assertThrows(RuntimeException.class, service.drop(parent))

when:
service.drop(parent)
then:
def e = thrown(RuntimeException)
// Test Parent
def parent_parent_actual = service.getParent(parent)
assert parent_parent_actual == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ public void rename(final QualifiedName oldName, final QualifiedName newName) {
retryTemplate.execute((RetryCallback<Void, RuntimeException>) context -> {
jdbcTemplate.update(connection -> {
// Rename Parent Entity
try (final PreparedStatement renameParentPS = connection.prepareStatement(SQL_RENAME_PARENT_ENTITY)) {
try (final PreparedStatement renameParentPS =
connection.prepareStatement(SQL_RENAME_PARENT_ENTITY)) {
renameParentPS.setString(1, newName.toString());
renameParentPS.setString(2, oldName.toString());
renameParentPS.executeUpdate();
}

// Rename Child Entity
try (final PreparedStatement renameChildPS = connection.prepareStatement(SQL_RENAME_CHILD_ENTITY)) {
try (final PreparedStatement renameChildPS =
connection.prepareStatement(SQL_RENAME_CHILD_ENTITY)) {
renameChildPS.setString(1, newName.toString());
renameChildPS.setString(2, oldName.toString());
renameChildPS.executeUpdate();
Expand Down

0 comments on commit ab3057f

Please sign in to comment.