Add parity test for record component access

Ensures record component access (req.type()) flows into sendEvent() consistently between heuristic and JDT call-graph engines.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 21:21:59 +02:00
parent be5386b972
commit 308dac557e

View File

@@ -145,6 +145,34 @@ class JdtCentralDispatcherParityTest {
.containsExactlyInAnyOrderElementsOf(heuristic.getTriggerPoint().getPolymorphicEvents());
}
@Test
void jdtShouldMatchHeuristicForRecordComponentAccess(@TempDir Path tempDir) throws Exception {
String source = """
package com.example;
public class ApiController {
CommandGateway gateway;
public void submit() { gateway.submit(new OrderRequest(OrderEvent.SUBMIT)); }
}
class CommandGateway {
void submit(OrderRequest req) {
StateMachine sm = new StateMachine();
sm.sendEvent(req.type());
}
}
record OrderRequest(OrderEvent type) {}
enum OrderEvent { SUBMIT, PAY }
class StateMachine { public void sendEvent(OrderEvent e) {} }
class OrderStateMachineConfig {}
""";
CodebaseContext context = scanSource(source, tempDir);
CallChain heuristic = resolveChain(context, CONTROLLER, "submit", STATE_MACHINE, EngineKind.HEURISTIC);
CallChain jdt = resolveChain(context, CONTROLLER, "submit", STATE_MACHINE, EngineKind.JDT);
assertThat(jdt.getTriggerPoint().getPolymorphicEvents())
.containsExactlyInAnyOrderElementsOf(heuristic.getTriggerPoint().getPolymorphicEvents());
}
@Test
void jdtShouldMatchHeuristicForDtoCrossHop(@TempDir Path tempDir) throws Exception {
String source = """