Search in sources :

Example 1 with MulColJoinVO

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("成都帝博"));
}
Also used : Dictionary(com.diboot.core.entity.Dictionary) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ArrayList(java.util.ArrayList) MulColJoinVO(diboot.core.test.binder.vo.MulColJoinVO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 Dictionary (com.diboot.core.entity.Dictionary)1 MulColJoinVO (diboot.core.test.binder.vo.MulColJoinVO)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1