1
1
package com .springboot .aop .aop ;
2
2
3
+ import com .springboot .aop .domain .History ;
4
+ import com .springboot .aop .domain .User ;
5
+ import com .springboot .aop .repository .HistoryRepository ;
3
6
import com .springboot .aop .service .BoardService ;
4
7
import com .springboot .aop .service .UserService ;
5
8
import org .junit .Assert ;
9
12
import org .springframework .boot .test .context .SpringBootTest ;
10
13
import org .springframework .test .context .junit4 .SpringRunner ;
11
14
15
+ import java .util .List ;
16
+
12
17
@ RunWith (SpringRunner .class )
13
18
@ SpringBootTest
14
- public class BoardServiceTest {
19
+ public class ServiceTest {
15
20
16
21
@ Autowired
17
22
private BoardService boardService ;
18
23
@ Autowired
19
24
private UserService userService ;
25
+ @ Autowired
26
+ private HistoryRepository historyRepository ;
20
27
21
28
@ Test
22
29
public void findBoards () throws Exception {
@@ -28,4 +35,17 @@ public void findUsers() throws Exception {
28
35
Assert .assertEquals (userService .getUsers ().size (), 100 );
29
36
}
30
37
38
+ @ Test
39
+ public void updateUsers () throws Exception {
40
+ List <User > users = userService .getUsers ();
41
+ for (int i = 0 ; i < 5 ; ++i ) {
42
+ User user = users .get (i );
43
+ user .
setEmail (
"[email protected] " );
44
+ userService .update (user );
45
+ }
46
+
47
+ List <History > histories = historyRepository .findAll ();
48
+ Assert .assertEquals (histories .size (), 5 );
49
+ }
50
+
31
51
}
0 commit comments