package com.ai.trackwalker.capability.workorder;

import org.junit.jupiter.api.Test;

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

class WorkOrderStateMachineTest {
    @Test
    void acceptsTheCompleteFieldWorkflow() {
        assertThat(WorkOrderStateMachine.canApply("created", "ACCEPT")).isTrue();
        assertThat(WorkOrderStateMachine.canApply("accepted", "DEPART")).isTrue();
        assertThat(WorkOrderStateMachine.canApply("en_route", "ARRIVE")).isTrue();
        assertThat(WorkOrderStateMachine.canApply("on_site", "START_PROCESSING")).isTrue();
        assertThat(WorkOrderStateMachine.canApply("processing", "SUBMIT")).isTrue();
        assertThat(WorkOrderStateMachine.canApply("submitted", "APPROVE")).isTrue();
        assertThat(WorkOrderStateMachine.target("APPROVE")).isEqualTo("closed");
    }

    @Test
    void rejectsOutOfOrderOperations() {
        assertThat(WorkOrderStateMachine.canApply("created", "APPROVE")).isFalse();
        assertThat(WorkOrderStateMachine.canApply("closed", "RETURN")).isFalse();
        assertThat(WorkOrderStateMachine.supports("UNKNOWN")).isFalse();
    }
}
