Skip to content

Commit

Permalink
feat: add new findRelationships interface and unit test placeholder (#…
Browse files Browse the repository at this point in the history
…389)

* feat: add new findRelationships interface and unit test placeholder

* fix & nullable
  • Loading branch information
ybz1013 authored Jul 15, 2024
1 parent da61213 commit d1584da
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,29 @@ public <SRC_SNAPSHOT extends RecordTemplate, DEST_SNAPSHOT extends RecordTemplat
.collect(Collectors.toList());
}

/**
* Finds a list of relationships of a specific type based on the given filters if applicable.
*
* @param sourceEntityUrn urn of the source entity to query
* @param sourceEntityFilter the filter to apply to the source entity when querying (not applicable to non-MG entities)
* @param destinationEntityUrn urn of the destination entity to query. If relationship is OwnedBy, this is crew/ldap.
* @param destinationEntityFilter the filter to apply to the destination entity when querying (not applicable to non-MG entities)
* @param relationshipType the type of relationship to query
* @param relationshipFilter the filter to apply to relationship when querying
* @param offset the offset query should start at. Ignored if set to a negative value.
* @param count the maximum number of entities to return. Ignored if set to a non-positive value. * @return A list of relationship records.
*/
@Nonnull
public <RELATIONSHIP extends RecordTemplate> List<RELATIONSHIP> findRelationships(
@Nullable String sourceEntityUrn, @Nullable LocalRelationshipFilter sourceEntityFilter,
@Nullable String destinationEntityUrn, @Nullable LocalRelationshipFilter destinationEntityFilter,
@Nonnull Class<RELATIONSHIP> relationshipType, @Nonnull LocalRelationshipFilter relationshipFilter,
int offset, int count) {
// NOTE: additional validation for sourceEntityUrn and sourceEntityUrn first.
// for non-MG entities, filters need to be null or ignored.
throw new RuntimeException("findRelationships is not implemented.");
}

/**
* Validate:
* 1. The entity filter only contains supported condition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ public void testFindOneRelationshipWithFilter() throws Exception {
assertEquals(consumeFromSamzaInNearline.size(), 1); // Because Samza only consumes kafka in NEARLINE.
}

@Test
public void testFindOneRelationshipWithEntityUrn() {
// TODO: implement
}

@Test
public void testFindOneRelationshipWithFilterWithEntityUrn() {
// TODO: implement
}

@Test
public void testFindOneRelationshipWithNonMgEntityUrn() {
// TODO: implement
}

@Test
public void testFindOneRelationshipWithFilterWithNonMgEntityUrn() {
// TODO: implement
// non-MG entities should not support filter
}

@Test
public void testFindEntitiesOneHopAwayIncomingDirection() throws Exception {
FooUrn alice = new FooUrn(1);
Expand Down

0 comments on commit d1584da

Please sign in to comment.