Extract call-site and link policy helpers to clarify analysis pipeline rules.
Move functional-interface checks, cross-frame Supplier resolution, and transition link resolution into dedicated types so call graph and linker share one DRY implementation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package click.kamil.springstatemachineexporter.analysis.enricher;
|
||||
|
||||
import click.kamil.springstatemachineexporter.analysis.model.LinkResolution;
|
||||
import click.kamil.springstatemachineexporter.analysis.model.TriggerPoint;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CallChainLinkPolicyTest {
|
||||
|
||||
@Test
|
||||
void shouldFailClosedOnEnumSetAmbiguousWiden() {
|
||||
TriggerPoint trigger = TriggerPoint.builder()
|
||||
.ambiguous(true)
|
||||
.event("ENUM_SET:com.example.OrderEvent.PAY,com.example.OrderEvent.SHIP")
|
||||
.polymorphicEvents(List.of("com.example.OrderEvent.PAY", "com.example.OrderEvent.SHIP"))
|
||||
.build();
|
||||
|
||||
assertThat(CallChainLinkPolicy.shouldFailClosedOnAmbiguousCallGraphWiden(trigger)).isTrue();
|
||||
assertThat(CallChainLinkPolicy.resolveLinkResolution(trigger, List.of(), false))
|
||||
.isEqualTo(LinkResolution.AMBIGUOUS_WIDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldMarkExternalTriggersUnresolved() {
|
||||
TriggerPoint trigger = TriggerPoint.builder()
|
||||
.external(true)
|
||||
.event("eventString")
|
||||
.build();
|
||||
|
||||
assertThat(CallChainLinkPolicy.resolveLinkResolution(trigger, List.of(), false))
|
||||
.isEqualTo(LinkResolution.UNRESOLVED_EXTERNAL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package click.kamil.springstatemachineexporter.analysis.service;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class FunctionalInterfaceTypesTest {
|
||||
|
||||
@Test
|
||||
void shouldRecognizeSupplierParameter() {
|
||||
assertThat(FunctionalInterfaceTypes.isFunctionalInterface("java.util.function.Supplier"))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAcceptLambdaIntoSupplierParameter() {
|
||||
assertThat(FunctionalInterfaceTypes.isProvablyResolvedCallSiteArgument(
|
||||
"() -> OrderEvent.CANCEL", "java.util.function.Supplier"))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRejectNonFunctionalParameter() {
|
||||
assertThat(FunctionalInterfaceTypes.isProvablyResolvedCallSiteArgument(
|
||||
"OrderEvent.CANCEL", "com.example.OrderEvent"))
|
||||
.isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user