package click.kamil.springstatemachineexporter.analysis.resolver;

import org.junit.jupiter.api.Test;

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

class MachineEnumCanonicalizerCrossPackageTest {

    @Test
    void shouldNotRewriteCrossPackageEnumReferencesWhenSimpleNamesMatch() {
        String machineEventType = "com.bar.OrderEvents";
        String foreignEvent = "com.foo.OrderEvents.PAY";

        assertThat(MachineEnumCanonicalizer.enumTypesMatch(machineEventType, "com.foo.OrderEvents"))
                .isFalse();
        assertThat(MachineEnumCanonicalizer.canonicalizeLabel(foreignEvent, machineEventType))
                .isEqualTo(foreignEvent);
    }

    @Test
    void shouldCanonicalizeImportStyleReferencesForMachineEnumType() {
        assertThat(MachineEnumCanonicalizer.canonicalizeLabel(
                "OrderEvents.PAY", "com.bar.OrderEvents"))
                .isEqualTo("com.bar.OrderEvents.PAY");
    }
}
