Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Jun 5, 2024
1 parent 08abbe4 commit 882220c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
assert e.message.contains("Cannot create a child table as parent")

// Test Child
def child_parent_expected = new ParentInfo(parent.toString(), type, parentUUID)
def child_parent_expected = [new ParentInfo(parent.toString(), type, parentUUID)] as Set
assert service.getParents(child, Optional.of(parentUUID)) == child_parent_expected
assert service.getParents(child, Optional.empty()) == child_parent_expected

Expand Down Expand Up @@ -221,7 +221,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
assert service.getChildren(newParent, Optional.empty()) == newParent_children_expected

// Test Child
def child_parent_expected = new ParentInfo(newParent.toString(), type, parentUUID)
def child_parent_expected = [new ParentInfo(newParent.toString(), type, parentUUID)] as Set
assert child_parent_expected == service.getParents(child, Optional.of(childUUID))
assert child_parent_expected == service.getParents(child, Optional.empty())
assert service.getChildren(child, Optional.of(childUUID)).isEmpty()
Expand All @@ -230,7 +230,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
// rename back
when:
service.rename(newParent, parent, Optional.of(parentUUID))
child_parent_expected = new ParentInfo(parent.toString(), type, parentUUID)
child_parent_expected = [new ParentInfo(parent.toString(), type, parentUUID)] as Set

then:
// Test new Parent Name
Expand Down Expand Up @@ -264,7 +264,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
service.createParentChildRelation(parent, parentUUID, child1, child1UUID, type)
service.createParentChildRelation(parent, parentUUID, child2, child1UUID, type)
def newParent = QualifiedName.ofTable(catalog, database, "np")
def child_parent_expected = new ParentInfo(newParent.toString(), type, parentUUID)
def child_parent_expected = [new ParentInfo(newParent.toString(), type, parentUUID)] as Set

when:
service.rename(parent, newParent, Optional.of(parentUUID))
Expand Down Expand Up @@ -304,7 +304,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
assert service.getChildren(child, Optional.empty()).isEmpty()

// Test New Child
def child_parent_expected = new ParentInfo(parent.toString(), type, parentUUID)
def child_parent_expected = [new ParentInfo(parent.toString(), type, parentUUID)] as Set
assert child_parent_expected == service.getParents(newChild, Optional.of(childUUID))
assert child_parent_expected == service.getParents(newChild, Optional.empty())
assert service.getChildren(child, Optional.of(childUUID)).isEmpty()
Expand Down Expand Up @@ -382,7 +382,7 @@ class ParentChildRelMetadataServiceSpec extends Specification{
assert parent_children_expected == service.getChildren(parent, Optional.empty())

// Test Child
def child_parent_expected = new ParentInfo(parent.toString(), type, parentUUID)
def child_parent_expected = [new ParentInfo(parent.toString(), type, parentUUID)] as Set
assert child_parent_expected == service.getParents(child, Optional.of(childUUID))
assert child_parent_expected == service.getParents(child, Optional.empty())
assert service.getChildren(child, Optional.of(childUUID)).isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public TableDto create(final QualifiedName name, final TableDto tableDto) {
log.info("Creating table {}", name);
eventBus.post(new MetacatCreateTablePreEvent(name, metacatRequestContext, this, tableDto));

final Optional<Runnable> unSaveOpOpt = saveParentChildRelationship(name, tableDto);
final Optional<Runnable> unSaveOpOpt = saveParentChildRelationship(name, tableDto); //suceed
try {
connectorTableServiceProxy.create(name, converterUtil.fromTableDto(tableDto));
connectorTableServiceProxy.create(name, converterUtil.fromTableDto(tableDto)); //failed
} catch (Exception e) {
unSaveOpOpt.ifPresent(Runnable::run);
throw e;
Expand Down Expand Up @@ -484,6 +484,27 @@ public Optional<TableDto> get(final QualifiedName name, final GetTableServicePar
table.setName(name);
}

//CREATE:
// ROOT_NAME
// ROOT_UUID
// CHILD_UUID
// RELATIONTYPE
// -> STRIPE IT OUT

/*Read
// "PARENT_CHILD_RELATION" {
"parentInfos": [{}]
"childInfos": [{}]
}
*/

/* update
// "PARENT_CHILD_RELATION" {
"parentInfos": [{}]
"childInfos": [{}]
}
*/

if (getTableServiceParameters.isIncludeDefinitionMetadata()) {
Optional<ObjectNode> definitionMetadata =
(getTableServiceParameters.isDisableOnReadMetadataIntercetor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public void createParentChildRelation(final QualifiedName parentName,
+ " already have a parent Table=" + childParents.stream().findFirst().get());
}

// parent child
// clone parent_parent parent

// Validation to prevent creating a child table as a parent of another child table
final Set<ParentInfo> parentParents = getParents(parentName, Optional.of(parentUUID));
if (!parentParents.isEmpty()) {
Expand Down

0 comments on commit 882220c

Please sign in to comment.