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

feat(ece): support custom ownership type urns in ECE generation #10999

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
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 @@ -27,17 +27,29 @@ public OwnerChangeEvent(
SemanticChangeType semVerChange,
String description,
Urn ownerUrn,
OwnershipType ownerType) {
OwnershipType ownerType,
Urn ownerTypeUrn) {
super(
entityUrn,
category,
operation,
modifier,
ImmutableMap.of(
"ownerUrn", ownerUrn.toString(),
"ownerType", ownerType.toString()),
buildParameters(ownerUrn, ownerType, ownerTypeUrn),
auditStamp,
semVerChange,
description);
}

private static ImmutableMap<String, Object> buildParameters(
Urn ownerUrn, OwnershipType ownerType, Urn ownerTypeUrn) {
ImmutableMap.Builder<String, Object> builder =
new ImmutableMap.Builder<String, Object>()
.put("ownerUrn", ownerUrn.toString())
.put("ownerType", ownerType.toString());
if (ownerTypeUrn != null) {
builder.put("ownerTypeUrn", ownerTypeUrn.toString());
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private static List<ChangeEvent> computeDiffs(
entityUrn))
.ownerUrn(targetOwner.getOwner())
.ownerType(targetOwner.getType())
.ownerTypeUrn(targetOwner.getTypeUrn())
.auditStamp(auditStamp)
.build());
}
Expand All @@ -84,6 +85,7 @@ private static List<ChangeEvent> computeDiffs(
entityUrn))
.ownerUrn(baseOwner.getOwner())
.ownerType(baseOwner.getType())
.ownerTypeUrn(baseOwner.getTypeUrn())
.auditStamp(auditStamp)
.build());
++baseOwnerIdx;
Expand All @@ -104,6 +106,7 @@ private static List<ChangeEvent> computeDiffs(
entityUrn))
.ownerUrn(targetOwner.getOwner())
.ownerType(targetOwner.getType())
.ownerTypeUrn(targetOwner.getTypeUrn())
.auditStamp(auditStamp)
.build());
++targetOwnerIdx;
Expand All @@ -128,6 +131,7 @@ private static List<ChangeEvent> computeDiffs(
entityUrn))
.ownerUrn(baseOwner.getOwner())
.ownerType(baseOwner.getType())
.ownerTypeUrn(baseOwner.getTypeUrn())
.auditStamp(auditStamp)
.build());
++baseOwnerIdx;
Expand All @@ -150,6 +154,7 @@ private static List<ChangeEvent> computeDiffs(
entityUrn))
.ownerUrn(targetOwner.getOwner())
.ownerType(targetOwner.getType())
.ownerTypeUrn(targetOwner.getTypeUrn())
.auditStamp(auditStamp)
.build());
++targetOwnerIdx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,16 @@ public void testInvokeEntityOwnerChange() throws Exception {
final Ownership newOwners = new Ownership();
final Urn ownerUrn1 = Urn.createFromString("urn:li:corpuser:test1");
final Urn ownerUrn2 = Urn.createFromString("urn:li:corpuser:test2");
final Urn ownerUrn3 = Urn.createFromString("urn:li:corpuser:test3");
newOwners.setOwners(
new OwnerArray(
ImmutableList.of(
new Owner().setOwner(ownerUrn1).setType(OwnershipType.TECHNICAL_OWNER),
new Owner().setOwner(ownerUrn2).setType(OwnershipType.BUSINESS_OWNER))));
new Owner().setOwner(ownerUrn2).setType(OwnershipType.BUSINESS_OWNER),
new Owner()
.setOwner(ownerUrn3)
.setType(OwnershipType.CUSTOM)
.setTypeUrn(Urn.createFromString("urn:li:ownershipType:my_custom_type")))));
final Ownership prevOwners = new Ownership();
prevOwners.setOwners(new OwnerArray());
event.setAspect(GenericRecordUtils.serializeAspect(newOwners));
Expand Down Expand Up @@ -354,7 +359,24 @@ public void testInvokeEntityOwnerChange() throws Exception {
"ownerType",
OwnershipType.BUSINESS_OWNER.toString()),
actorUrn);
verifyProducePlatformEvent(_mockClient, platformEvent2, true);
verifyProducePlatformEvent(_mockClient, platformEvent2, false);

PlatformEvent platformEvent3 =
createChangeEvent(
DATASET_ENTITY_NAME,
Urn.createFromString(TEST_DATASET_URN),
ChangeCategory.OWNER,
ChangeOperation.ADD,
ownerUrn3.toString(),
ImmutableMap.of(
"ownerUrn",
ownerUrn3.toString(),
"ownerType",
OwnershipType.CUSTOM.toString(),
"ownerTypeUrn",
"urn:li:ownershipType:my_custom_type"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - thanks for adding this!

actorUrn);
verifyProducePlatformEvent(_mockClient, platformEvent3, true);
}

@Test
Expand Down
Loading