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 7ba6050 commit 726e73d
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ class ParentChildRelMetadataServiceSpec extends Specification{
def child1 = QualifiedName.ofTable(catalog, database, "c1")
def child2 = QualifiedName.ofTable(catalog, database, "c2")
def type = "clone";

when:
service.createParentChildRelation(parent, child1, type)
service.createParentChildRelation(parent, child2, type)

then:
// Test Parent
assert service.getParent(parent) == null

Expand All @@ -98,7 +101,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{

// Test Child 1
assert child_parent_expected == service.getParent(child1)
assert service.getChildren(child1) == 0
assert service.getChildren(child1).size() == 0

assert child_parent_expected == service.getParent(child2)
assert service.getChildren(child2).size() == 0
Expand All @@ -111,7 +114,13 @@ class ParentChildRelMetadataServiceSpec extends Specification{
def child = QualifiedName.ofTable(catalog, database, "c")
def type = "clone"
service.createParentChildRelation(parent1, child, type)
assertThrows(RuntimeException.class, service.createParentChildRelation(parent2, child, type))

when:
service.createParentChildRelation(parent2, child, type)

then:
def e = thrown(RuntimeException)
e.message == "Cannot have a child table having more than one parent - Child Table: ${catalog}/${database}/c already have a parent Table=${catalog}/${database}/p1"

// Test Child
def child_parent_expected = new ParentInfo(parent1.toString(), type)
Expand All @@ -127,8 +136,12 @@ class ParentChildRelMetadataServiceSpec extends Specification{
def grandChild = QualifiedName.ofTable(catalog, database, "gc")
def type = "clone"
service.createParentChildRelation(parent, child, type)
assertThrows(RuntimeException.class, service.createParentChildRelation(child, grandChild, type))

when:
service.createParentChildRelation(child, grandChild, type)

then:
def e = thrown(RuntimeException)
// Test Child
def child_parent_expected = new ParentInfo(parent.toString(), type)
def child_parent_actual = service.getParent(child)
Expand Down

0 comments on commit 726e73d

Please sign in to comment.