use of diboot.core.test.binder.vo.UserVO in project diboot by dibo-software.
the class TestDictBinder method testBinder.
@Test
public void testBinder() {
// 加载测试数据
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(User::getId, 1001L, 1002L);
List<User> userList = userService.getEntityList(queryWrapper);
// 自动绑定
List<UserVO> voList = Binder.convertAndBindRelations(userList, UserVO.class);
// 验证绑定结果
Assert.assertTrue(V.notEmpty(voList));
for (UserVO vo : voList) {
// 验证直接关联和通过中间表间接关联的绑定
Assert.assertNotNull(vo.getGenderLabel());
System.out.println(JSON.stringify(vo));
}
// 单个entity接口测试
UserVO singleVO = BeanUtils.convert(userList.get(1), UserVO.class);
Binder.bindRelations(singleVO);
// 验证直接关联和通过中间表间接关联的绑定
Assert.assertNotNull(singleVO.getGenderLabel());
System.out.println(JSON.stringify(singleVO));
}
Aggregations