-
Notifications
You must be signed in to change notification settings - Fork 54
@W-10459675@: Part 4 of several. Added Messaging.InboundEmailHandler implementations as sources. #742
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
Conversation
| public static final String IDENTIFIER = "Identifier"; | ||
| public static final String IMPLEMENTATION_OF = "ImplementationOf"; | ||
| public static final String IMPLEMENTED_BY = "ImplementedBy"; | ||
| public static final String INTERFACE_DEFINING_TYPES = "InterfaceDefiningTypes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New property added because the existing INTERFACE_NAMES property isn't guaranteed to contain the full defining types of interfaces, which was making queries very complicated.
| Schema.NAME, | ||
| Schema.DEFINING_TYPE, | ||
| Schema.FULL_METHOD_NAME, | ||
| Schema.INTERFACE_DEFINING_TYPES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case-safe equivalent for new property.
| Schema.INTERFACE_NAMES, | ||
| Schema.METHOD_NAME, | ||
| Schema.NAME, | ||
| Schema.RETURN_TYPE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lack of a case-safe return type was a problem.
| } | ||
| } | ||
|
|
||
| public static GraphTraversal<Object, Object> hasArrayContaining( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the opposite of H.hasWithin(). Instead of checking whether a property's value is contained by the provided array, it checks whether a property represents an array containing the provided value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be helpful to have this information as javadoc.
| // It's possible for the implementedVertex to be null if the interface being | ||
| // implemented is declared in a file | ||
| // that wasn't scanned. | ||
| if (!implementedVerticesByName.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to isEmpty check, since the map is always non-null.
| @@ -1,7 +1,19 @@ | |||
| package com.salesforce.graph.build; | |||
|
|
|||
| import static org.hamcrest.Matchers.hasSize; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added aggressive test coverage for every scenario I could think of, since there was previously none.
| __.where( | ||
| H.hasArrayContaining( | ||
| NodeType.USER_CLASS, | ||
| Schema.INTERFACE_DEFINING_TYPES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new property makes this query significantly less complicated.
| // subtypes. Do that with a union of these two subtraversals. | ||
| // Also, start with the hasLabel() call, because doing an initial filter along an indexed | ||
| // field saves us a ton of time. | ||
| GraphTraversal<Vertex, Vertex> traversal = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query is complicated, but I tried to document it as best I could. Please let me know if anything is unclear.
| // Also, start with the hasLabel() call, because doing an initial filter along an indexed | ||
| // field saves us a ton of time. | ||
| GraphTraversal<Vertex, Vertex> traversal = | ||
| g.V().hasLabel(NodeType.USER_CLASS, NodeType.USER_INTERFACE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hasLabel call isn't technically necessary, but adding it improved the performance of the query substantially.
| + " }\n" | ||
| + "}\n"; | ||
|
|
||
| private String[] interfaceTestSourceCodes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added aggressive test coverage for the new traversal, with every test case I could think of.
| // Filter the results by return type and arity to limit the possibility of | ||
| // getting unnecessary results. | ||
| .where(H.has(NodeType.METHOD, Schema.RETURN_TYPE, INBOUND_EMAIL_RESULT)) | ||
| .has(Schema.ARITY, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this time, we're only checking the arity, instead of checking the types of arguments. We could add that in the future, but that feels like an excessive level of complication unless we know we'll need it. (He said, having already overcomplicated the PR...)
219d8f8 to
212c25b
Compare
rmohan20
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
212c25b to
92e2a45
Compare
a58bb49 to
462eca9
Compare
This PR does the following:
InterfaceDefiningTypes, which captures the full defining type of each interface implemented by a class, and a case-safe equivalent for this property.These properties are populated during the execution of
InheritanceEdgeBuilder.InheritanceEdgeBuilder.ReturnType.hasArrayContaining(), which returns vertices whose value of a specified property is an array containing a specified value.traverseImplementationsOf(), which traverses every class that implements a given interface both directly and indirectly (i.e., extends a class that implements it, or implements an interface that extends it), along with robust test coverage for this new method.Messaging.InboundEmailResult handleInboundEmail()method onMessaging.InboundEmailHandlerimplementations (both direct and indirect) as entrypoints forApexFlsViolationRule.Change to be added in supplemental PR:
InheritanceEdgeBuilderto something likeInheritanceInformationCreator, since it now does more than just building edges.