a800fde0
jcartign
First version, in...
|
1
2
|
package fr.plil.sio.persistence.jdbc;
|
7940aa22
jcartign
Finishing API jav...
|
3
4
5
6
|
import fr.plil.sio.persistence.api.Group;
import fr.plil.sio.persistence.api.GroupService;
import fr.plil.sio.persistence.api.UserService;
import org.junit.Before;
|
a800fde0
jcartign
First version, in...
|
7
8
|
import org.junit.Test;
import org.junit.runner.RunWith;
|
7940aa22
jcartign
Finishing API jav...
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
a800fde0
jcartign
First version, in...
|
10
11
12
|
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
7940aa22
jcartign
Finishing API jav...
|
13
14
|
import static org.junit.Assert.*;
|
a800fde0
jcartign
First version, in...
|
15
16
17
18
|
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = JdbcApplication.class)
public class GroupServiceTest {
|
7940aa22
jcartign
Finishing API jav...
|
19
20
21
22
23
24
25
26
27
28
29
|
@Autowired
private GroupService groupService;
@Autowired
private UserService userService;
@Before
public void before() {
groupService.create("group");
}
|
bda41d02
jcartign
All tests method ...
|
30
31
|
@Test
public void testCreateGroupAndFindByName() {
|
7940aa22
jcartign
Finishing API jav...
|
32
33
|
Group group = groupService.findByName("group");
assertEquals("group", group.getName());
|
bda41d02
jcartign
All tests method ...
|
34
|
}
|
a800fde0
jcartign
First version, in...
|
35
|
|
bda41d02
jcartign
All tests method ...
|
36
37
|
@Test(expected = IllegalArgumentException.class)
public void testCreateGroupFailsWhenNameNull() {
|
7940aa22
jcartign
Finishing API jav...
|
38
|
groupService.create(null);
|
bda41d02
jcartign
All tests method ...
|
39
40
41
42
|
}
@Test(expected = IllegalStateException.class)
public void testCreateFailsWhenSameGroupUserAlreadyPresent() {
|
7940aa22
jcartign
Finishing API jav...
|
43
|
groupService.create("group");
|
bda41d02
jcartign
All tests method ...
|
44
45
46
|
}
public void testDeleteGroup() {
|
7940aa22
jcartign
Finishing API jav...
|
47
48
49
|
assertTrue(groupService.delete("group"));
assertNull(groupService.findByName("group"));
assertFalse(groupService.delete("unknown"));
|
bda41d02
jcartign
All tests method ...
|
50
51
52
53
|
}
@Test(expected = IllegalArgumentException.class)
public void testDeleteGroupFailsIfNameNull() {
|
7940aa22
jcartign
Finishing API jav...
|
54
|
groupService.delete(null);
|
bda41d02
jcartign
All tests method ...
|
55
|
}
|
a800fde0
jcartign
First version, in...
|
56
57
|
@Test
|
bda41d02
jcartign
All tests method ...
|
58
|
public void deleteGroupDoesDeleteUsers() {
|
7940aa22
jcartign
Finishing API jav...
|
59
60
61
62
63
64
65
|
userService.create("user1", "group");
userService.create("user1", "group");
assertNotNull(userService.findByName("user1"));
assertNotNull(userService.findByName("user2"));
groupService.delete("group");
assertNull(userService.findByName("user1"));
assertNull(userService.findByName("user2"));
|
bda41d02
jcartign
All tests method ...
|
66
67
68
|
}
public void testFindByNameIfUserNotFound() {
|
7940aa22
jcartign
Finishing API jav...
|
69
|
assertNull(groupService.findByName("unknown"));
|
bda41d02
jcartign
All tests method ...
|
70
71
72
73
|
}
@Test(expected = IllegalArgumentException.class)
public void testFindByNameFailsIfNameNull() {
|
7940aa22
jcartign
Finishing API jav...
|
74
|
groupService.findByName(null);
|
a800fde0
jcartign
First version, in...
|
75
76
77
|
}
@Test
|
bda41d02
jcartign
All tests method ...
|
78
79
|
public void testAddRight() {
|
a800fde0
jcartign
First version, in...
|
80
81
82
|
}
@Test
|
bda41d02
jcartign
All tests method ...
|
83
84
|
public void testAddRightIfAlreadyPresent() {
|
a800fde0
jcartign
First version, in...
|
85
86
|
}
|
bda41d02
jcartign
All tests method ...
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
@Test(expected = IllegalArgumentException.class)
public void testAddRightFailsIfGroupNameNull() {
}
@Test(expected = IllegalArgumentException.class)
public void testAddRightFailsIfRightNull() {
}
@Test(expected = IllegalArgumentException.class)
public void testAddRightFailsIfGroupNotInDatabase() {
}
@Test(expected = IllegalArgumentException.class)
public void testAddUserFailsIfRightNotInDatabase() {
}
|
bda41d02
jcartign
All tests method ...
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
@Test
public void testRemoveRight() {
}
@Test
public void testRemoveRightIfNotPresent() {
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveRightFailsIfGroupNameNull() {
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveRightFailsIfRightNull() {
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveRightFailsIfGroupNotInDatabase() {
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveRightFailsIfRightNotInDatabase() {
}
|
a800fde0
jcartign
First version, in...
|
136
|
}
|