package click.kamil.springstatemachineexporter.analysis.resolver;

import click.kamil.springstatemachineexporter.ast.common.CodebaseContext;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.util.List;

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

class EnterpriseStringMachineTypeTest {

    @Test
    void shouldResolveStringTypesForEnterpriseConfig() throws Exception {
        Path projectRoot = Path.of("../state_machines/enterprise_order_system").toAbsolutePath().normalize();
        Path javaRoot = projectRoot.resolve("src/main/java");

        CodebaseContext context = new CodebaseContext();
        context.setSourcepath(List.of(javaRoot.toString()));
        context.scan(javaRoot);

        StateMachineTypeResolver.MachineTypes types = StateMachineTypeResolver.resolveTypes(
                "click.kamil.examples.enterprise.config.EnterpriseStateMachineConfig", context);

        assertThat(types.stateTypeFqn()).isEqualTo("String");
        assertThat(types.eventTypeFqn()).isEqualTo("String");
        assertThat(MachineEnumCanonicalizer.canonicalizeLabel("NEW", types.stateTypeFqn()))
                .isEqualTo("String.NEW");
    }
}
