Commit e0e8eef8443f3c068e9f23d979dd162b9804d48c
Merge branch 'master' of archives.plil.fr:GIS2A4-Java/spring-persistence
Conflicts: src/test/resources/application.properties
Showing
6 changed files
with
32 additions
and
10 deletions
Show diff stats
... | ... | @@ -0,0 +1,23 @@ |
1 | +Description | |
2 | +=========== | |
3 | + | |
4 | + | |
5 | + | |
6 | + | |
7 | +TODO | |
8 | +==== | |
9 | + | |
10 | +Documentation | |
11 | +------------- | |
12 | + | |
13 | +* add usage scenario | |
14 | +* complete documentation to precise one level dependencies for create and find methods | |
15 | +* clarify tree of rights | |
16 | +* clarify why the dependencies need to be managed in the service (to avoid to break the | |
17 | +CRUD model, *i.e.* repository methods are specialised to load the one-level | |
18 | +dependencies, thus cannot be used to load object as dependencies | |
19 | + | |
20 | +Tests | |
21 | +----- | |
22 | + | |
23 | +* tests for one-level dependencies | |
0 | 24 | \ No newline at end of file | ... | ... |
src/main/java/fr/plil/sio/persistence/api/RightService.java
... | ... | @@ -15,8 +15,7 @@ public interface RightService { |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Create a sibling right attached to a parent right with a specific name in the database. |
18 | - * It is possible that two rights has the same name. | |
19 | - * Return only the right with the parent in the field parent. | |
18 | + * It is possible that two rights has the same name. Return only the right with the parent in the field parent. | |
20 | 19 | * |
21 | 20 | * |
22 | 21 | * @param name the name of the right | ... | ... |
src/main/java/fr/plil/sio/persistence/api/UserService.java
... | ... | @@ -5,6 +5,7 @@ public interface UserService { |
5 | 5 | /** |
6 | 6 | * Create an user with a specific name in the database and affected to an existing group. |
7 | 7 | * There is no two users with the same name in the database. |
8 | + * Only references at one level are loaded (i.e. the group where the user belong). | |
8 | 9 | * |
9 | 10 | * @param name the name of the user |
10 | 11 | * @param groupName the name of the group | ... | ... |
src/test/java/fr/plil/sio/persistence/jdbc/GroupServiceTest.java
... | ... | @@ -69,7 +69,7 @@ public class GroupServiceTest extends AbstractServiceSupport { |
69 | 69 | @Test |
70 | 70 | public void deleteGroupDoesDeleteUsers() { |
71 | 71 | userService.create("user1", "group"); |
72 | - userService.create("user1", "group"); | |
72 | + userService.create("user2", "group"); | |
73 | 73 | assertNotNull(userService.findByName("user1")); |
74 | 74 | assertNotNull(userService.findByName("user2")); |
75 | 75 | groupService.delete("group"); |
... | ... | @@ -128,8 +128,8 @@ public class GroupServiceTest extends AbstractServiceSupport { |
128 | 128 | assertEquals(0, group.getRights().size()); |
129 | 129 | } |
130 | 130 | |
131 | - @Test | |
132 | - public void testRemoveRightIfNotPresent() { | |
131 | + @Test(expected = IllegalArgumentException.class) | |
132 | + public void testRemoveRightIfNotInDatabase() { | |
133 | 133 | Right right = new Right(); |
134 | 134 | right.setName("not-a-right"); |
135 | 135 | assertFalse(groupService.removeRight("group", right)); | ... | ... |
src/test/java/fr/plil/sio/persistence/jdbc/RightServiceTest.java
... | ... | @@ -86,11 +86,11 @@ public class RightServiceTest extends AbstractServiceSupport { |
86 | 86 | assertEquals(0, rightService.findByName("parent").size()); |
87 | 87 | } |
88 | 88 | |
89 | - @Test | |
90 | - public void testDeleteRightIfNotFound() { | |
89 | + @Test(expected = IllegalArgumentException.class) | |
90 | + public void testDeleteRightIfNotInDatabase() { | |
91 | 91 | Right right = new Right(); |
92 | 92 | right.setName("not-a-right"); |
93 | - assertFalse(rightService.delete(right)); | |
93 | + rightService.delete(right); | |
94 | 94 | } |
95 | 95 | |
96 | 96 | @Test(expected = IllegalArgumentException.class) | ... | ... |
src/test/resources/application.properties
... | ... | @@ -2,5 +2,4 @@ logging.level.org.springframework=INFO |
2 | 2 | logging.level.org.hibernate.SQL=DEBUG |
3 | 3 | logging.level.org.hibernate=INFO |
4 | 4 | spring.datasource.url=jdbc:h2:mem:persistence;TRACE_LEVEL_FILE=4; |
5 | -#spring.datasource.maxActive=300 | |
6 | -spring.datasource.tomcat.max-active=500 | |
7 | 5 | \ No newline at end of file |
6 | +spring.datasource.tomcat.max-active=500 | ... | ... |