use of diboot.core.test.binder.vo.EntityListSimpleVO in project diboot by dibo-software.
the class TestEntityListBinder method testSimpleBinder.
/**
* 验证直接关联的绑定
*/
@Test
public void testSimpleBinder() {
// 加载测试数据
LambdaQueryWrapper<Department> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(Department::getId, 10001L, 10003L);
List<Department> entityList = departmentService.list(queryWrapper);
// 自动绑定
List<EntityListSimpleVO> voList = Binder.convertAndBindRelations(entityList, EntityListSimpleVO.class);
// 验证绑定结果
Assert.assertTrue(V.notEmpty(voList));
for (EntityListSimpleVO vo : voList) {
// 验证直接关联的绑定
Assert.assertTrue(V.notEmpty(vo.getChildren()));
System.out.println(JSON.stringify(vo));
Assert.assertTrue(V.notEmpty(vo.getChildrenNames()));
for (int i = 0; i < vo.getChildren().size(); i++) {
Department dept = vo.getChildren().get(i);
Assert.assertTrue(dept.getName().equals(vo.getChildrenNames().get(i)));
}
}
}
Aggregations