Skip to content
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
1 change: 1 addition & 0 deletions sfge/src/main/java/com/salesforce/graph/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Schema {
public static final String IMPLEMENTED_BY = "ImplementedBy";
public static final String INTERFACE_DEFINING_TYPES = "InterfaceDefiningTypes";
public static final String INTERFACE_NAMES = "InterfaceNames";
public static final String INVOCABLE_METHOD = "InvocableMethod";
/** True if this vertex is part of the Apex Standard Library */
public static final String IS_STANDARD = "IsStandard";
/**
Expand Down
11 changes: 9 additions & 2 deletions sfge/src/main/java/com/salesforce/graph/ops/MethodUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ public static List<MethodVertex> getRemoteActionMethods(
return getMethodsWithAnnotation(g, targetFiles, Schema.REMOTE_ACTION);
}

/**
* Returns non-test methods in the target files with an @InvocableMethod annotation. An empty
* list implicitly includes all files.
*/
public static List<MethodVertex> getInvocableMethodMethods(
GraphTraversalSource g, List<String> targetFiles) {
return getMethodsWithAnnotation(g, targetFiles, Schema.INVOCABLE_METHOD);
}

static List<MethodVertex> getMethodsWithAnnotation(
GraphTraversalSource g, List<String> targetFiles, String annotation) {
// Only look at UserClass vertices. Uninterested in Enums, Interfaces, or Triggers.
final String[] labels = new String[] {NodeType.USER_CLASS};
return SFVertexFactory.loadVertices(
g,
rootMethodTraversal(g, targetFiles)
Expand Down
2 changes: 2 additions & 0 deletions sfge/src/main/java/com/salesforce/rules/RuleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public static List<MethodVertex> getPathEntryPoints(
methods.addAll(MethodUtil.getNamespaceAccessibleMethods(g, fileLevelTargets));
// ...and RemoteAction methods...
methods.addAll(MethodUtil.getRemoteActionMethods(g, fileLevelTargets));
// ...and InvocableMethod methods...
methods.addAll(MethodUtil.getInvocableMethodMethods(g, fileLevelTargets));
// ...and PageReference methods...
methods.addAll(MethodUtil.getPageReferenceMethods(g, fileLevelTargets));
// ...and global-exposed methods...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.salesforce.graph.ops.MethodUtil;
import com.salesforce.graph.vertex.MethodVertex;
import com.salesforce.graph.vertex.SFVertexFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -120,7 +119,8 @@ public void testCaseSafeProperties() {
((Object[])
userClassVertex.get(
Schema.INTERFACE_NAMES
+ CaseSafePropertyUtil.CASE_SAFE_SUFFIX))[0]);
+ CaseSafePropertyUtil.CASE_SAFE_SUFFIX))
[0]);

Map<Object, Object> userInterfaceVertex =
g.V().hasLabel(NodeType.USER_INTERFACE).elementMap().next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ private void verifyInterfaceDefiningTypeProperty(
.values(Schema.INTERFACE_DEFINING_TYPES)
.toList();
for (Object propValue : propValues) {
MatcherAssert.assertThat(
(Object[])propValue,
arrayContaining(parentDefiningType));
MatcherAssert.assertThat((Object[]) propValue, arrayContaining(parentDefiningType));
}
}
}
10 changes: 8 additions & 2 deletions sfge/src/test/java/com/salesforce/graph/ops/MethodUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,13 @@ public void getTargetMethods_targetMethodInInnerAndOuterClass() {
containsString(EventKey.WARNING_MULTIPLE_METHOD_TARGET_MATCHES.getMessageKey()));
}

@ValueSource(strings = {Schema.AURA_ENABLED, Schema.REMOTE_ACTION, Schema.NAMESPACE_ACCESSIBLE})
@ValueSource(
strings = {
Schema.AURA_ENABLED,
Schema.INVOCABLE_METHOD,
Schema.REMOTE_ACTION,
Schema.NAMESPACE_ACCESSIBLE
})
@ParameterizedTest(name = "{displayName}: {0}")
public void testGetMethodsWithAnnotation(String annotation) {
String[] sourceCode = {
Expand Down Expand Up @@ -369,7 +375,7 @@ public void testGetMethodsWithAnnotation(String annotation) {
+ "}\n",
};

TestUtil.buildGraph(g, sourceCode);
TestUtil.buildGraph(g, sourceCode, true);

List<MethodVertex> methods =
MethodUtil.getMethodsWithAnnotation(g, new ArrayList<>(), annotation);
Expand Down
8 changes: 7 additions & 1 deletion sfge/src/test/java/com/salesforce/rules/RuleUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ public void setup() {
this.g = TestUtil.getGraph();
}

@ValueSource(strings = {Schema.AURA_ENABLED, Schema.REMOTE_ACTION, Schema.NAMESPACE_ACCESSIBLE})
@ValueSource(
strings = {
Schema.AURA_ENABLED,
Schema.INVOCABLE_METHOD,
Schema.REMOTE_ACTION,
Schema.NAMESPACE_ACCESSIBLE
})
@ParameterizedTest(name = "{displayName}: {0}")
public void getPathEntryPoints_includesAnnotatedMethods(String annotation) {
String sourceCode =
Expand Down