package com.cf.imes.module.system.service.machine;

import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.controller.admin.machine.vo.CuttingSaveReqVO;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import jakarta.annotation.Resource;

import static com.cf.imes.framework.test.core.util.RandomUtils.randomPojo;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
class MachineServiceImplTest {

    @Resource
    private MachineService machineService;
    @Test
    void create() {
        OrganContextHolder.setOrganId(1L);
        for (int i = 0; i < 20; i++) {
            CuttingSaveReqVO saveReqVO = randomPojo(CuttingSaveReqVO.class);
            saveReqVO.setId(null);
            // 调用，并断言
            assertThrows(JsonProcessingException.class, () -> machineService.createCutting(saveReqVO));
        }

    }
}