MCPcopy Create free account
hub / github.com/castello/spring_basic / CommentDaoImplTest

Class CommentDaoImplTest

ch4/CommentDaoImplTest.java:14–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12import static org.junit.Assert.*;
13
14@RunWith(SpringJUnit4ClassRunner.class)
15@ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/spring/root-context.xml"})
16public class CommentDaoImplTest {
17 @Autowired
18 CommentDao commentDao;
19
20 @Test
21 public void count() throws Exception {
22 commentDao.deleteAll(1);
23 assertTrue(commentDao.count(1)==0);
24 }
25
26 @Test
27 public void delete() throws Exception {
28 commentDao.deleteAll(1);
29 CommentDto commentDto = new CommentDto(1, 0, "comment", "asdf");
30 assertTrue(commentDao.insert(commentDto)==1);
31 assertTrue(commentDao.count(1)==1);
32 }
33
34 @Test
35 public void insert() throws Exception {
36 commentDao.deleteAll(1);
37 CommentDto commentDto = new CommentDto(1, 0, "comment", "asdf");
38 assertTrue(commentDao.insert(commentDto)==1);
39 assertTrue(commentDao.count(1)==1);
40
41 commentDto = new CommentDto(1, 0, "comment", "asdf");
42 assertTrue(commentDao.insert(commentDto)==1);
43 assertTrue(commentDao.count(1)==2);
44 }
45
46 @Test
47 public void selectAll() throws Exception {
48 commentDao.deleteAll(1);
49 CommentDto commentDto = new CommentDto(1, 0, "comment", "asdf");
50 assertTrue(commentDao.insert(commentDto)==1);
51 assertTrue(commentDao.count(1)==1);
52
53 List<CommentDto> list = commentDao.selectAll(1);
54 assertTrue(list.size()==1);
55
56 commentDto = new CommentDto(1, 0, "comment", "asdf");
57 assertTrue(commentDao.insert(commentDto)==1);
58 assertTrue(commentDao.count(1)==2);
59
60 list = commentDao.selectAll(1);
61 assertTrue(list.size()==2);
62 }
63
64 @Test
65 public void select() throws Exception {
66 commentDao.deleteAll(1);
67 CommentDto commentDto = new CommentDto(1, 0, "comment", "asdf");
68 assertTrue(commentDao.insert(commentDto)==1);
69 assertTrue(commentDao.count(1)==1);
70
71 List<CommentDto> list = commentDao.selectAll(1);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected