Add parity test for DTO field access

Ensures public field 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:19:21 +02:00
parent 4dd64c6cdf
commit be5386b972

View File

@@ -114,6 +114,37 @@ class JdtCentralDispatcherParityTest {
.containsExactlyInAnyOrderElementsOf(heuristicShip.getTriggerPoint().getPolymorphicEvents());
}
@Test
void jdtShouldMatchHeuristicForPublicDtoFieldAccess(@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);
}
}
class OrderRequest {
public final OrderEvent type;
OrderRequest(OrderEvent type) { this.type = 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 = """