diff --git a/ktg-admin/src/test/BomRouteUnitTest.java b/ktg-admin/src/test/BomRouteUnitTest.java new file mode 100644 index 0000000..7ee3483 --- /dev/null +++ b/ktg-admin/src/test/BomRouteUnitTest.java @@ -0,0 +1,66 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.BomRoute; +import com.ktg.mes.md.service.IBomRouteService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.List; + +/** + * BOM管理单元测试 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class BomRouteUnitTest { + @Autowired + private IBomRouteService bomRouteService; + + @Test + public void add() { + BomRoute bomRoute = new BomRoute(); + bomRoute.setBomCode("UNIT_TEST_002"); + bomRoute.setBomName("单元测试002"); + bomRoute.setBomVersion("V1.0"); + bomRoute.setMdItemId(75L); + bomRoute.setIsDefault("true"); + bomRoute.setMbbProduBomList(new ArrayList<>()); + bomRouteService.insertBomRoute(bomRoute); + System.out.println("add:" + bomRoute.getBomRouteId()); // 10 + } + + @Test + public void list() { + List list = bomRouteService.selectBomRouteList(new BomRoute()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(bomRouteService.selectBomRouteByBomRouteId(10L))); + } + + @Test + public void edit() { + BomRoute bomRoute = new BomRoute(); + bomRoute.setBomRouteId(10L); + bomRoute.setBomName("单元测试001"); + bomRoute.setBomVersion("V1.0"); + bomRoute.setMdItemId(75L); + bomRoute.setIsDefault("true"); + bomRoute.setMbbProduBomList(new ArrayList<>()); + int count = bomRouteService.updateBomRoute(bomRoute); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {10L}; + int count = bomRouteService.deleteBomRouteByBomRouteIds(ids); + System.out.println("remove:" + count); + } +}