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:
@@ -114,6 +114,37 @@ class JdtCentralDispatcherParityTest {
|
|||||||
.containsExactlyInAnyOrderElementsOf(heuristicShip.getTriggerPoint().getPolymorphicEvents());
|
.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
|
@Test
|
||||||
void jdtShouldMatchHeuristicForDtoCrossHop(@TempDir Path tempDir) throws Exception {
|
void jdtShouldMatchHeuristicForDtoCrossHop(@TempDir Path tempDir) throws Exception {
|
||||||
String source = """
|
String source = """
|
||||||
|
|||||||
Reference in New Issue
Block a user