package click.kamil.springstatemachineexporter.ast.common;

import org.junit.jupiter.api.Test;

import java.util.List;

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

class AstUtilsAnalysisTokenTest {

    @Test
    void enumSetTrailingConstIsNotEnumLike() {
        assertThat(AstUtils.isEnumLikeConstantName(
                "ENUM_SET:DomainCommand.ORDER_PAY,DomainCommand.ORDER_SHIP")).isFalse();
        assertThat(AstUtils.isAnalysisToken(
                "ENUM_SET:DomainCommand.ORDER_PAY,DomainCommand.ORDER_SHIP")).isTrue();
    }

    @Test
    void symbolicWildcardIsNotEnumLike() {
        assertThat(AstUtils.isEnumLikeConstantName("<SYMBOLIC: OrderEvents.*>")).isFalse();
        assertThat(AstUtils.isAnalysisToken("<SYMBOLIC: OrderEvents.*>")).isTrue();
        assertThat(AstUtils.isAnalysisToken("OrderEvents.*>")).isTrue();
    }

    @Test
    void concreteEnumStillEnumLike() {
        assertThat(AstUtils.isEnumLikeConstantName("DomainCommand.ORDER_PAY")).isTrue();
        assertThat(AstUtils.isConcreteConstant("DomainCommand.ORDER_PAY")).isTrue();
    }

    @Test
    void enumSetFormatParseRoundTrip() {
        String formatted = AstUtils.formatEnumSet(List.of("A.PAY", "A.SHIP"));
        assertThat(formatted).isEqualTo("ENUM_SET:A.PAY,A.SHIP");
        assertThat(AstUtils.parseEnumSet(formatted)).containsExactly("A.PAY", "A.SHIP");
        assertThat(AstUtils.parseEnumSet("not-a-set")).isEmpty();
    }
}
