package click.kamil.springstatemachineexporter.analysis.resolver;

import org.junit.jupiter.api.Test;

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

class DynamicTriggerExpressionsTest {

    @Test
    void bareCarrierTokensAreDynamic() {
        assertThat(DynamicTriggerExpressions.isDynamic("event")).isTrue();
        assertThat(DynamicTriggerExpressions.isDynamic("message")).isTrue();
        assertThat(DynamicTriggerExpressions.isDynamic("payload")).isTrue();
    }

    @Test
    void concreteEnumConstantsAreNotDynamic() {
        assertThat(DynamicTriggerExpressions.isDynamic("OrderEvent.PAY")).isFalse();
        assertThat(DynamicTriggerExpressions.isDynamic("com.example.OrderEvent.SHIP")).isFalse();
    }

    @Test
    void valueOfAndTernaryAreDynamic() {
        assertThat(DynamicTriggerExpressions.isDynamic("OrderEvent.valueOf(x)")).isTrue();
        assertThat(DynamicTriggerExpressions.isDynamic("cond ? OrderEvent.PAY : OrderEvent.SHIP")).isTrue();
    }

    @Test
    void symbolicMarkerIsNotDynamicForCanonicalRewrite() {
        assertThat(DynamicTriggerExpressions.isDynamic("<SYMBOLIC: com.example.OrderEvent.*>")).isFalse();
    }

    @Test
    void placeholderAndBareLowercaseAreDynamic() {
        assertThat(DynamicTriggerExpressions.isDynamic("${event}")).isTrue();
        assertThat(DynamicTriggerExpressions.isDynamic("cmd")).isTrue();
    }
}
