better finding state machines
This commit is contained in:
@@ -61,6 +61,30 @@ public class RegressionTest {
|
||||
Path.of("../state_machines/inheritance_extra_functions2_state_machine"),
|
||||
Path.of("src/test/resources/golden/ThreeStateMachineConfiguration"),
|
||||
"ThreeStateMachineConfiguration"
|
||||
),
|
||||
new TestScenario(
|
||||
"F1 State Machine (Example 4)",
|
||||
Path.of("../state_machines/inheritance_extra_functions3_state_machine"),
|
||||
Path.of("src/test/resources/golden/F1StateMachineConfiguration"),
|
||||
"F1StateMachineConfiguration"
|
||||
),
|
||||
new TestScenario(
|
||||
"F2 State Machine (Example 4)",
|
||||
Path.of("../state_machines/inheritance_extra_functions3_state_machine"),
|
||||
Path.of("src/test/resources/golden/F2StateMachineConfiguration"),
|
||||
"F2StateMachineConfiguration"
|
||||
),
|
||||
new TestScenario(
|
||||
"G1 State Machine (Example 4)",
|
||||
Path.of("../state_machines/inheritance_extra_functions3_state_machine"),
|
||||
Path.of("src/test/resources/golden/G1StateMachineConfiguration"),
|
||||
"G1StateMachineConfiguration"
|
||||
),
|
||||
new TestScenario(
|
||||
"G2 State Machine (Example 4)",
|
||||
Path.of("../state_machines/inheritance_extra_functions3_state_machine"),
|
||||
Path.of("src/test/resources/golden/G2StateMachineConfiguration"),
|
||||
"G2StateMachineConfiguration"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
|
||||
@@ -273,21 +274,38 @@ class AstFileFinderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnTrue_whenClassHasAnnotationWithParameters() {
|
||||
String classWithAnnotatedParams = """
|
||||
@Service("testService")
|
||||
public class TestService {
|
||||
public void doSomething() {
|
||||
// implementation
|
||||
}
|
||||
void shouldReturnTrue_whenFunctionReturnsTargetType() {
|
||||
String source = """
|
||||
public class Test {
|
||||
public StateMachine<S, E> build() { return null; }
|
||||
}
|
||||
""";
|
||||
AstFileFinder finder = new AstFileFinder();
|
||||
List<String> annotationNames = List.of("Service");
|
||||
|
||||
boolean result = finder.hasClassWithAnnotation(classWithAnnotatedParams, annotationNames);
|
||||
|
||||
boolean result = finder.hasFunctionReturningType(source, Set.of("StateMachine"));
|
||||
assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnFalse_whenNoFunctionReturnsTargetType() {
|
||||
String source = """
|
||||
public class Test {
|
||||
public void build() {}
|
||||
}
|
||||
""";
|
||||
AstFileFinder finder = new AstFileFinder();
|
||||
boolean result = finder.hasFunctionReturningType(source, Set.of("StateMachine"));
|
||||
assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnTrue_whenFunctionReturnsQualifiedTargetType() {
|
||||
String source = """
|
||||
public class Test {
|
||||
public org.springframework.statemachine.StateMachine build() { return null; }
|
||||
}
|
||||
""";
|
||||
AstFileFinder finder = new AstFileFinder();
|
||||
boolean result = finder.hasFunctionReturningType(source, Set.of("StateMachine"));
|
||||
assertThat(result).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user