Fix HTML export states, endpoint linking, and dynamic trigger event validation.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -88,6 +88,31 @@ class HtmlTransitionLinkConsistencyTest {
|
||||
assertThat(html).contains("com.example.order.OrderEvent.PAY");
|
||||
}
|
||||
|
||||
@Test
|
||||
void htmlShouldNotRenderDuplicateStateNodesForPackageCanonicalStartStates(@TempDir Path tempDir) throws Exception {
|
||||
writeSampleProject(tempDir);
|
||||
|
||||
AnalysisResult finalizedShape = AnalysisResult.builder()
|
||||
.name("com.example.config.OrderStateMachineConfiguration")
|
||||
.stateTypeFqn("com.example.order.OrderState")
|
||||
.eventTypeFqn("com.example.order.OrderEvent")
|
||||
.transitions(List.of(shortTransition(
|
||||
"com.example.order.OrderEvent.PAY",
|
||||
"com.example.order.OrderState.NEW",
|
||||
"com.example.order.OrderState.PAID")))
|
||||
.startStates(Set.of("com.example.order.OrderState.NEW"))
|
||||
.endStates(Set.of("com.example.order.OrderState.PAID"))
|
||||
.build();
|
||||
|
||||
String html = new HtmlExporter().export(finalizedShape, ExportOptions.builder().build());
|
||||
String svg = extractSvg(html);
|
||||
|
||||
assertThat(svg).contains("OrderState.NEW");
|
||||
assertThat(svg).contains("OrderState.PAID");
|
||||
assertThat(svg).doesNotContain("com.example.order.OrderState.NEW");
|
||||
assertThat(svg).doesNotContain("com.example.order.OrderState.PAID");
|
||||
}
|
||||
|
||||
@Test
|
||||
void enterpriseAstExportHtmlShouldContainTransitionLinkKeys(@TempDir Path tempDir) throws Exception {
|
||||
Path enterprise = findProjectRoot().resolve("state_machines/state_machine_enterprise");
|
||||
@@ -169,6 +194,15 @@ class HtmlTransitionLinkConsistencyTest {
|
||||
""");
|
||||
}
|
||||
|
||||
private static String extractSvg(String html) {
|
||||
int start = html.indexOf("<svg");
|
||||
int end = html.indexOf("</svg>");
|
||||
if (start < 0 || end < 0) {
|
||||
return html;
|
||||
}
|
||||
return html.substring(start, end + "</svg>".length());
|
||||
}
|
||||
|
||||
private static Path findProjectRoot() {
|
||||
Path current = Path.of(".").toAbsolutePath();
|
||||
while (current != null && !Files.exists(current.resolve("settings.gradle"))) {
|
||||
|
||||
Reference in New Issue
Block a user