package com.ningdatech.pmapi.statemachine;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

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

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

    @Autowired
    private IProjectService projectService;

    @Test
    public void stateMachineTest() {
        Project project = projectService.getById(485);
        stateMachineUtils.pass(project);
        System.out.println(String.format("project:%s", JSON.toJSONString(project)));
        projectService.updateById(project);
    }

    @Test
    public void yyyyyy(){
        Project project = projectService.getById(400);
        projectService.update(Wrappers.lambdaUpdate(Project.class)
                .set(Project::getNewest,Boolean.FALSE)
                .ne(Project::getId,project.getId())
                .eq(Project::getProjectCode,project.getProjectCode()));
        System.out.println(project);
    }
}
