package click.kamil.springstatemachineexporter.analysis.resolver;

import org.junit.jupiter.api.Test;

import java.util.Map;

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

class BooleanConstraintEvaluatorBindingsTest {

    @Test
    void shouldAcceptMatchingEnumSwitchConstraint() {
        assertThat(BooleanConstraintEvaluator.isCompatibleWithBindings(
                "command == ORDER_PAY",
                Map.of("command", "DomainCommand.ORDER_PAY"))).isTrue();
    }

    @Test
    void shouldRejectMismatchedEnumSwitchConstraint() {
        assertThat(BooleanConstraintEvaluator.isCompatibleWithBindings(
                "command == ORDER_SHIP",
                Map.of("command", "DomainCommand.ORDER_PAY"))).isFalse();
    }

    @Test
    void shouldAcceptMatchingStringSwitchConstraint() {
        assertThat(BooleanConstraintEvaluator.isCompatibleWithBindings(
                "commandKey == \"order.pay\"",
                Map.of("commandKey", "order.pay"))).isTrue();
    }

    @Test
    void shouldRejectConstraintWhenBindingIsMissing() {
        assertThat(BooleanConstraintEvaluator.isCompatibleWithBindings(
                "command == ORDER_PAY",
                Map.of("commandKey", "order.pay"))).isFalse();
    }
}
