luodangjia
2024-07-17 69f4408cd37ac8dd18e9f0cdc572401a3b057ea1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.stylefeng.guns.system;
 
import com.stylefeng.guns.base.BaseJunit;
import com.stylefeng.guns.modular.system.dao.DeptMapper;
import com.stylefeng.guns.modular.system.model.Dept;
import org.junit.Test;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
 
/**
 * 字典服务测试
 *
 * @author fengshuonan
 * @date 2017-04-27 17:05
 */
public class DeptTest extends BaseJunit {
 
    @Resource
    DeptMapper deptMapper;
 
    @Test
    public void addDeptTest() {
        Dept dept = new Dept();
        dept.setFullname("测试fullname");
        dept.setNum(5);
        dept.setPid(1);
        dept.setSimplename("测试");
        dept.setTips("测试tips");
        dept.setVersion(1);
        Integer insert = deptMapper.insert(dept);
        assertEquals(insert, new Integer(1));
    }
 
    @Test
    public void updateTest() {
        Dept dept = this.deptMapper.selectById(24);
        dept.setTips("哈哈");
        boolean flag = dept.updateById();
        assertTrue(flag);
    }
 
    @Test
    public void deleteTest() {
        Dept dept = this.deptMapper.selectById(24);
        Integer integer = deptMapper.deleteById(dept);
        assertTrue(integer > 0);
    }
 
    @Test
    public void listTest() {
        List<Map<String, Object>> list = this.deptMapper.list("总公司");
        assertTrue(list.size() > 0);
    }
}