package click.kamil.springstatemachineexporter.exporter;

import org.junit.jupiter.api.Test;

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

class TransitionLinkKeyTest {

    @Test
    void shouldBuildFnFormLinkKeyFromPackageCanonicalIdentifiers() {
        assertThat(TransitionLinkKey.build(
                "com.example.order.OrderState.NEW",
                "com.example.order.OrderEvent.PAY"))
                .isEqualTo("OrderState_NEW__OrderEvent_PAY");
    }

    @Test
    void shouldBuildFqnFormLinkKeyWhenRequested() {
        assertThat(TransitionLinkKey.build(
                "com.example.order.OrderState.NEW",
                "com.example.order.OrderEvent.PAY",
                EnumFormat.fqn,
                EnumFormat.fqn))
                .isEqualTo("com_example_order_OrderState_NEW__com_example_order_OrderEvent_PAY");
    }

    @Test
    void shouldBuildEventOnlyLinkKeyWhenSourceMissing() {
        assertThat(TransitionLinkKey.build(null, "com.example.order.OrderEvent.PAY"))
                .isEqualTo("__OrderEvent_PAY");
    }
}
