初始化
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.device.DeviceBootApplication;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月10日 15:05
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = DeviceBootApplication.class)
|
||||
public class BaseJunitTest {
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.device.pojo.po.DeptLine;
|
||||
import com.njcn.device.service.DeptLineService;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月14日 12:55
|
||||
*/
|
||||
public class DeviceTest extends BaseJunitTest {
|
||||
|
||||
@Autowired
|
||||
private DeptLineService deptLineService;
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
DeptLineParam deptLineParam = new DeptLineParam();
|
||||
deptLineParam.setId("1");
|
||||
List<String> ids = Stream.of("999", "888", "777").collect(Collectors.toList());
|
||||
//先解绑,再进行绑定
|
||||
List<DeptLine> deptLines = new ArrayList<>();
|
||||
deptLineParam.setIds(ids);
|
||||
deptLineParam.getIds().stream().map(id -> {
|
||||
System.out.println("==================");
|
||||
DeptLine deptLine = new DeptLine();
|
||||
deptLine.setId(deptLineParam.getId());
|
||||
deptLine.setLineId(id);
|
||||
deptLines.add(deptLine);
|
||||
return deptLine;
|
||||
});
|
||||
deptLineService.saveBatch(deptLines);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user