use of diboot.core.test.binder.vo.MulColJoinVO in project diboot by dibo-software.
the class TestMultipleColumnsJoinBinder method testBinder.
@Test
public void testBinder() {
QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "GENDER");
queryWrapper.gt("parent_id", 0);
List<Long> ids = dictionaryService.getValuesOfField(queryWrapper, Dictionary::getId);
// 加载测试数据
List<MulColJoinVO> voList = new ArrayList<>();
MulColJoinVO vo1 = new MulColJoinVO();
vo1.setDictType("GENDER");
vo1.setDictId(ids.get(0));
vo1.setOrgPid(0L);
vo1.setTelphone("0512-62988949");
voList.add(vo1);
MulColJoinVO vo2 = new MulColJoinVO();
vo2.setDictType("GENDER");
vo2.setDictId(ids.get(1));
vo2.setOrgPid(0L);
vo2.setTelphone("028-62988949");
voList.add(vo2);
// 自动绑定
Binder.bindRelations(voList);
// 验证绑定结果
Assert.assertTrue(V.notEmpty(voList));
// 验证直接关联和通过中间表间接关联的绑定
Assert.assertNotNull(voList.get(0).getParentDict().getType().equals(vo1.getDictType()));
Assert.assertNotNull(voList.get(0).getParentDictName().equals("性别"));
Assert.assertNotNull(voList.get(0).getOrgList().size() == 1);
// 验证枚举值已绑定
Assert.assertNotNull(voList.get(0).getOrgNames().contains("苏州帝博"));
Assert.assertNotNull(voList.get(1).getParentDict().getType().equals(vo1.getDictType()));
Assert.assertNotNull(voList.get(1).getParentDictName().equals("男"));
Assert.assertNotNull(voList.get(1).getOrgList().size() == 1);
// 验证枚举值已绑定
Assert.assertNotNull(voList.get(1).getOrgNames().contains("成都帝博"));
}
Aggregations