package com.ningdatech.pmapi.statemachine;

import com.alibaba.fastjson.JSON;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;

/**
 * 状态机测试
 *
 * @author CMM
 * @since 2023/02/08 11:46
 */

public class StateMachineTest extends AppTests {
    @Autowired
    private StateMachineUtils stateMachineUtils;

    @Test
    public void stateMachineTest() throws Exception {
        Project project = new Project();
        project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
        project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
        project.setDeclareAmount(BigDecimal.valueOf(2000));
        stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus()));
        System.out.println(String.format("project:%s", JSON.toJSONString(project)));
    }
}
