package click.kamil.springstatemachineexporter.exporter;

import click.kamil.springstatemachineexporter.analysis.model.AnalysisResult;
import click.kamil.springstatemachineexporter.model.State;
import click.kamil.springstatemachineexporter.model.Transition;
import click.kamil.springstatemachineexporter.model.TransitionType;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;

class JsonExporterTest {

    @Test
    void shouldExportToJson() {
        JsonExporter exporter = new JsonExporter();
        Transition transition = new Transition();
        transition.setType(TransitionType.EXTERNAL);
        transition.setSourceStates(List.of(State.of("S1")));
        transition.setTargetStates(List.of(State.of("S2")));
        transition.setEvent(click.kamil.springstatemachineexporter.model.Event.of("E1"));

        AnalysisResult result = AnalysisResult.builder()
                .name("TestSM")
                .transitions(List.of(transition))
                .startStates(Set.of("S1"))
                .endStates(Set.of("S2"))
                .build();

        String json = exporter.export(result, ExportOptions.builder().build());

        assertThat(json)
                .contains("\"name\" : \"TestSM\"")
                .contains("\"rawName\" : \"E1\"")
                .contains("\"rawName\" : \"S1\"")
                .contains("\"rawName\" : \"S2\"");
    }
}
