This commit is contained in:
2026-07-07 21:11:32 +02:00
parent 9a5f122bd2
commit 1be8d5e950
3 changed files with 102 additions and 13 deletions

View File

@@ -143,7 +143,38 @@ class TransitionLinkerEnricherTest {
assertThat(updatedChain.getMatchedTransitions()).hasSize(1);
}
@Test
void shouldNotLinkAllEnumTransitionsWhenConstantNamesCollide() {
Transition orderPay = new Transition();
orderPay.setSourceStates(List.of(State.of("NEW", "NEW")));
orderPay.setTargetStates(List.of(State.of("PAID", "PAID")));
orderPay.setEvent(Event.of("PAY", "com.example.OrderEvents.PAY"));
Transition invoicePay = new Transition();
invoicePay.setSourceStates(List.of(State.of("DRAFT", "DRAFT")));
invoicePay.setTargetStates(List.of(State.of("SENT", "SENT")));
invoicePay.setEvent(Event.of("PAY", "com.example.InvoiceEvents.PAY"));
CallChain chain = CallChain.builder()
.triggerPoint(TriggerPoint.builder()
.event("OrderEvents.PAY")
.eventTypeFqn("com.example.OrderEvents")
.build())
.contextMachineId("testMachine")
.build();
AnalysisResult result = AnalysisResult.builder()
.name("testMachine")
.transitions(List.of(orderPay, invoicePay))
.metadata(CodebaseMetadata.builder().callChains(List.of(chain)).build())
.build();
enricher.enrich(result, null, null);
CallChain updatedChain = result.getMetadata().getCallChains().get(0);
assertThat(updatedChain.getMatchedTransitions()).hasSize(1);
assertThat(updatedChain.getMatchedTransitions().get(0).getEvent()).isEqualTo("com.example.OrderEvents.PAY");
}
@Test
void shouldMatchBaseEventDespiteScrapedPolyEvents() {

View File

@@ -196,6 +196,38 @@ class StrictFqnMatchingEngineTest {
assertThat(engine.matches(smEvent, triggerPoint)).isTrue();
}
@Test
void shouldNotMatchBareStrippedConstantToAnyEnumWithoutTypeContext() {
Event smEvent = Event.of("PAY", "com.example.OrderEvents.PAY");
TriggerPoint triggerPoint = TriggerPoint.builder()
.event("PAY")
.build();
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
}
@Test
void shouldNotMatchSameEnumSimpleNameFromDifferentPackages() {
Event smEvent = Event.of("PAY", "com.example.other.OrderEvents.PAY");
TriggerPoint triggerPoint = TriggerPoint.builder()
.event("OrderEvents.PAY")
.eventTypeFqn("com.example.OrderEvents")
.build();
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
}
@Test
void shouldNotMatchPolymorphicStrippedConstantWithoutTypeContext() {
Event smEvent = Event.of("PAY", "com.example.InvoiceEvents.PAY");
TriggerPoint triggerPoint = TriggerPoint.builder()
.event("getType()")
.polymorphicEvents(List.of("PAY"))
.build();
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
}
@Test
void shouldMatchDynamicMethodCallAsVariable() {
Event smEvent = Event.of("PAY", "com.example.OrderEvents.PAY");