test
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package click.kamil.springstatemachineexporter.exporter;
|
||||
|
||||
import click.kamil.springstatemachineexporter.model.State;
|
||||
import click.kamil.springstatemachineexporter.model.Transition;
|
||||
import click.kamil.springstatemachineexporter.model.TransitionType;
|
||||
import click.kamil.springstatemachineexporter.model.Guard;
|
||||
import click.kamil.springstatemachineexporter.model.Action;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PlantUmlTest {
|
||||
|
||||
@Test
|
||||
void testExportSanitizesLabels() {
|
||||
PlantUml plantUml = new PlantUml();
|
||||
ExportOptions options = ExportOptions.builder()
|
||||
.embedIdentifiers(true)
|
||||
.useLambdaGuards(false)
|
||||
.build();
|
||||
|
||||
State state1 = State.of("State1");
|
||||
State state2 = State.of("State2");
|
||||
|
||||
Transition t = new Transition();
|
||||
t.setType(TransitionType.EXTERNAL);
|
||||
t.setSourceStates(List.of(state1));
|
||||
t.setTargetStates(List.of(state2));
|
||||
|
||||
// Add a guard and action containing problematic characters
|
||||
t.setGuard(Guard.of("list.size() < 5", false, null, null, null, null));
|
||||
t.setActions(List.of(Action.of("doSomething(new int[]{1, 2})", false, null, null, null, null)));
|
||||
|
||||
String result = plantUml.export(
|
||||
"TestMachine",
|
||||
List.of(t),
|
||||
Set.of("State1"),
|
||||
Set.of("State2"),
|
||||
options
|
||||
);
|
||||
|
||||
// Verify that < and > are replaced with HTML entities
|
||||
assertThat(result).doesNotContain("< 5");
|
||||
assertThat(result).contains("< 5");
|
||||
|
||||
// Verify that [ and ] are replaced with HTML entities inside the link
|
||||
assertThat(result).doesNotContain("[list.size() < 5]");
|
||||
assertThat(result).doesNotContain("new int[]{1, 2}");
|
||||
assertThat(result).contains("[list.size() < 5]");
|
||||
assertThat(result).contains("new int[]{1, 2}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user