Repository navigation
Expand file tree
/
Copy pathAreaDaoTest.java
More file actions
58 lines (49 loc) · 1.43 KB
/
Copy pathAreaDaoTest.java
File metadata and controls
58 lines (49 loc) · 1.43 KB
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
package com.fei.demo.dao;
import com.fei.demo.entity.Area;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
import java.util.List;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AreaDaoTest {
@Autowired
private AreaDao areaDao;
@Test
public void queryArea() {
List<Area> areaList = areaDao.queryArea();
assertEquals(2, areaList.size());
}
@Test
public void queryAreaById() {
Area area = areaDao.queryAreaById(1);
assertEquals("东苑", area.getAreaName());
}
@Test
public void insertArea() {
Area area = new Area();
area.setAreaName("南苑");
area.setPriority(1);
int effectedNum = areaDao.insertArea(area);
assertEquals(1, effectedNum);
}
@Test
public void updateArea() {
Area area = new Area();
area.setAreaId(2);
area.setAreaName("西苑");
area.setPriority(3);
area.setLastEditTime(new Date());
int effectedNum = areaDao.updateArea(area);
assertEquals(1, effectedNum);
}
@Test
public void deleteArea() {
int effectedNum = areaDao.deleteArea(1);
assertEquals(1, effectedNum);
}
}