Commit bda41d029193295a064f50bcfb814d79efafbb49

Authored by jcartign
1 parent f2ed17f6

All tests method prototypes ready

src/main/java/fr/plil/sio/persistence/api/GroupService.java
... ... @@ -32,32 +32,11 @@ public interface GroupService {
32 32 Group findByName(String name);
33 33  
34 34 /**
35   - * Add an user in the group.
36   - *
37   - * @param groupName the name of the group.
38   - * @param userName the name of the user to add in the group.
39   - * @return true if user is added in the group, false if user was already present.
40   - * @throws IllegalArgumentException if groupName or userName is null, or if group or user cannot be found.
41   - */
42   - boolean addUser(String groupName, String userName);
43   -
44   - /**
45   - * Remove an user in the group.
46   - *
47   - * @param groupName the name of the group.
48   - * @param userName the name of the user to remove from the group.
49   - * @return true if user is removed from the group, false if user was not present in the group.
50   - * @throws IllegalArgumentException if groupName or userName is null, or if group or user cannot be found.
51   - */
52   - boolean removeUser(String groupName, String userName);
53   -
54   - /**
55 35 * Add a right in the group. Right is inserted at the end of rights list of the group.
56 36 *
57 37 * @param groupName the name of the group.
58 38 * @param right the right to add
59 39 * @return true if right is added in the group, false if right was already present.
60   - * @throws IllegalStateException if a parent right is already present
61 40 * @throws IllegalArgumentException if groupName or right is null, or if group or right cannot be found.
62 41 */
63 42 boolean addRight(String groupName, Right right);
... ...
src/test/java/fr/plil/sio/persistence/jdbc/GroupServiceTest.java
1 1 package fr.plil.sio.persistence.jdbc;
2 2  
3   -import fr.plil.sio.persistence.api.Group;
4   -import fr.plil.sio.persistence.api.GroupService;
5   -import fr.plil.sio.persistence.api.User;
6   -import fr.plil.sio.persistence.api.UserService;
7 3 import org.junit.Test;
8 4 import org.junit.runner.RunWith;
9   -import org.springframework.beans.factory.annotation.Autowired;
10 5 import org.springframework.boot.test.SpringApplicationConfiguration;
11 6 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12 7  
13   -import static org.junit.Assert.assertEquals;
14   -import static org.junit.Assert.assertNotNull;
15   -
16 8 @RunWith(SpringJUnit4ClassRunner.class)
17 9 @SpringApplicationConfiguration(classes = JdbcApplication.class)
18 10 public class GroupServiceTest {
19 11  
20   - @Autowired
21   - private UserService userService;
  12 + @Test
  13 + public void testCreateGroupAndFindByName() {
  14 + }
22 15  
23   - @Autowired
24   - private GroupService groupService;
  16 + @Test(expected = IllegalArgumentException.class)
  17 + public void testCreateGroupFailsWhenNameNull() {
  18 + }
  19 +
  20 + @Test(expected = IllegalStateException.class)
  21 + public void testCreateFailsWhenSameGroupUserAlreadyPresent() {
  22 + }
  23 +
  24 + public void testDeleteGroup() {
  25 + }
  26 +
  27 + public void testDeleteGroupIfNotFound() {
  28 + }
  29 +
  30 + @Test(expected = IllegalArgumentException.class)
  31 + public void testDeleteGroupFailsIfNameNull() {
  32 + }
25 33  
26 34 @Test
27   - public void testCreateAndFindByName() {
28   - groupService.create("group1");
29   - Group group2 = groupService.findByName("group1");
30   - assertNotNull(group2);
31   - assertNotNull(group2.getName());
32   - assertEquals("group1", group2.getName());
  35 + public void deleteGroupDoesDeleteUsers() {
  36 + }
  37 +
  38 + public void testFindByNameIfUserNotFound() {
  39 + }
  40 +
  41 + @Test(expected = IllegalArgumentException.class)
  42 + public void testFindByNameFailsIfNameNull() {
33 43 }
34 44  
35 45 @Test
36   - public void addUsersAndCheckIfPresent() {
37   - Group group1 = groupService.create("group1");
38   - User user1 = userService.create("user1");
39   - User user2 = userService.create("user2");
40   - groupService.addUser(group1, user1);
41   - groupService.addUser(group1, user2);
42   - Group group2 = groupService.findByName("group1");
43   - assertNotNull(group2);
44   - assertNotNull(group2.getName());
45   - assertEquals("group1", group2.getName());
46   - assertEquals(2, group2.getUsers().size());
  46 + public void testAddRight() {
  47 +
47 48 }
48 49  
49 50 @Test
50   - public void deleteGroupDoesNotDeleteUsers() {
51   - Group group1 = groupService.create("group1");
52   - User user1 = userService.create("user1");
53   - User user2 = userService.create("user2");
54   - groupService.addUser(group1, user1);
55   - groupService.addUser(group1, user2);
56   - groupService.delete(group1);
57   - assertNotNull(userService.findByName("user1"));
58   - assertNotNull(userService.findByName("user2"));
  51 + public void testAddRightIfAlreadyPresent() {
  52 +
59 53 }
60 54  
  55 + @Test(expected = IllegalArgumentException.class)
  56 + public void testAddRightFailsIfGroupNameNull() {
  57 +
  58 + }
  59 +
  60 + @Test(expected = IllegalArgumentException.class)
  61 + public void testAddRightFailsIfRightNull() {
  62 +
  63 + }
  64 +
  65 + @Test(expected = IllegalArgumentException.class)
  66 + public void testAddRightFailsIfGroupNotInDatabase() {
  67 +
  68 + }
  69 +
  70 + @Test(expected = IllegalArgumentException.class)
  71 + public void testAddUserFailsIfRightNotInDatabase() {
  72 +
  73 + }
  74 +
  75 +
  76 + /**
  77 + * Remove a right associated with a group.
  78 + *
  79 + * @param groupName the name of the group.
  80 + * @param right the right to remove
  81 + * @return true if right is removed from the group, false if teh right was not present in the group.
  82 + * @throws IllegalArgumentException if groupName or right is null, or if group or right cannot be found.
  83 + */
  84 +
  85 + @Test
  86 + public void testRemoveRight() {
  87 +
  88 + }
  89 +
  90 + @Test
  91 + public void testRemoveRightIfNotPresent() {
  92 +
  93 + }
  94 +
  95 + @Test(expected = IllegalArgumentException.class)
  96 + public void testRemoveRightFailsIfGroupNameNull() {
  97 +
  98 + }
  99 +
  100 + @Test(expected = IllegalArgumentException.class)
  101 + public void testRemoveRightFailsIfRightNull() {
  102 +
  103 + }
  104 +
  105 + @Test(expected = IllegalArgumentException.class)
  106 + public void testRemoveRightFailsIfGroupNotInDatabase() {
  107 +
  108 + }
  109 +
  110 + @Test(expected = IllegalArgumentException.class)
  111 + public void testRemoveRightFailsIfRightNotInDatabase() {
  112 +
  113 + }
61 114 }
... ...
src/test/java/fr/plil/sio/persistence/jdbc/RightServiceTest.java
1 1 package fr.plil.sio.persistence.jdbc;
2 2  
  3 +import org.junit.Test;
3 4 import org.junit.runner.RunWith;
4 5 import org.springframework.boot.test.SpringApplicationConfiguration;
5 6 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
... ... @@ -7,4 +8,88 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 8 @RunWith(SpringJUnit4ClassRunner.class)
8 9 @SpringApplicationConfiguration(classes = JdbcApplication.class)
9 10 public class RightServiceTest {
  11 +
  12 + @Test
  13 + public void testCreateParentRightAndFindOne() {
  14 +
  15 + }
  16 +
  17 + @Test
  18 + public void testCreateTwoParentRightsWithSameNameAndFindByName() {
  19 +
  20 + }
  21 +
  22 + @Test(expected = IllegalArgumentException.class)
  23 + public void testCreateFailsIfNameNull() {
  24 +
  25 + }
  26 +
  27 + @Test
  28 + public void testCreateSiblingRightAndFindOne() {
  29 +
  30 + }
  31 +
  32 + @Test(expected = IllegalArgumentException.class)
  33 + public void testCreateSiblingFailsIfNameNull() {
  34 +
  35 + }
  36 +
  37 + @Test(expected = IllegalArgumentException.class)
  38 + public void testCreateSiblingFailsIfParentNull() {
  39 +
  40 + }
  41 +
  42 + @Test(expected = IllegalArgumentException.class)
  43 + public void testCreateSiblingFailsIfParentNotInDatabase() {
  44 +
  45 + }
  46 +
  47 + @Test
  48 + public void testDeleteParentRight() {
  49 + }
  50 +
  51 + @Test
  52 + public void testDeleteSiblingRight() {
  53 + }
  54 +
  55 +
  56 + @Test
  57 + public void testDeleteParentAndSiblingRights() {
  58 + }
  59 +
  60 + @Test
  61 + public void testDeleteRightIfNotFound() {
  62 + }
  63 +
  64 + @Test(expected = IllegalArgumentException.class)
  65 + public void testDeleteRightFailsIfRightNull() {
  66 + }
  67 +
  68 + @Test
  69 + public void testFindByName() {
  70 + }
  71 +
  72 + @Test
  73 + public void testFindSeveralByName() {
  74 + }
  75 +
  76 + @Test
  77 + public void testFindByNameIfNameNotFound() {
  78 + }
  79 +
  80 + @Test(expected = IllegalArgumentException.class)
  81 + public void testFindByNameFailsIfNameNull() {
  82 + }
  83 +
  84 + @Test
  85 + public void testFindOne() {
  86 + }
  87 +
  88 + @Test
  89 + public void testFindOneIfIdNotFound() {
  90 + }
  91 +
  92 + @Test(expected = IllegalArgumentException.class)
  93 + public void testFindOneFailsIfIdNull() {
  94 + }
10 95 }
... ...
src/test/java/fr/plil/sio/persistence/jdbc/UserServiceTest.java
1 1 package fr.plil.sio.persistence.jdbc;
2 2  
3   -import fr.plil.sio.persistence.api.User;
4   -import fr.plil.sio.persistence.api.UserService;
5 3 import org.junit.Test;
6 4 import org.junit.runner.RunWith;
7   -import org.springframework.beans.factory.annotation.Autowired;
8 5 import org.springframework.boot.test.SpringApplicationConfiguration;
9 6 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 7  
11   -import static org.junit.Assert.assertEquals;
12   -import static org.junit.Assert.assertNotNull;
13   -
14 8 @RunWith(SpringJUnit4ClassRunner.class)
15 9 @SpringApplicationConfiguration(classes = JdbcApplication.class)
16 10 public class UserServiceTest {
17 11  
18   - @Autowired
19   - private UserService userService;
20   -
21 12 @Test
22 13 public void testCreateAndFindByName() {
23   - final String name = "blabla";
24   - User user1 = userService.create(name);
25   - User user2 = userService.findByName(name);
26   - assertNotNull(user1);
27   - assertNotNull(user2);
28   - assertNotNull(user1.getName());
29   - assertNotNull(user2.getName());
30   - assertNotNull(user1.getGroup());
31   - assertNotNull(user2.getGroup());
32   - assertEquals(user1.getName(), user2.getName());
33   - assertEquals(user1.getGroup(), user2.getGroup());
  14 + }
  15 +
  16 + @Test(expected = IllegalArgumentException.class)
  17 + public void testCreateFailsWhenNameNull() {
  18 + }
  19 +
  20 + @Test(expected = IllegalArgumentException.class)
  21 + public void testCreateFailsWhenGroupNameNull() {
  22 + }
  23 +
  24 + @Test(expected = IllegalArgumentException.class)
  25 + public void testCreateFailsWhenGroupDoesNotExist() {
  26 + }
  27 +
  28 + @Test(expected = IllegalStateException.class)
  29 + public void testCreateFailsWhenSameNameUserAlreadyPresent() {
  30 + }
  31 +
  32 + public void testDeleteUser() {
  33 + }
  34 +
  35 + public void testDeleteUserIfNotFound() {
  36 + }
  37 +
  38 + @Test(expected = IllegalArgumentException.class)
  39 + public void testDeleteUserFailsIfNameNull() {
  40 + }
  41 +
  42 + public void testFindUserByNameIfUserNotFound() {
  43 + }
  44 +
  45 + @Test(expected = IllegalArgumentException.class)
  46 + public void testFindUserByNameFailsIfNameNull() {
  47 + }
  48 +
  49 + public void testIsUserHasExactRight() {
  50 + }
  51 +
  52 + public void testIsUserHasRightByParents() {
  53 + }
  54 +
  55 + public void testIsUserHasNotTheExactRight() {
  56 + }
  57 +
  58 + @Test(expected = IllegalArgumentException.class)
  59 + public void testIsUserHasRightFailsWhenUsernameNull() {
  60 + }
  61 +
  62 + @Test(expected = IllegalArgumentException.class)
  63 + public void testIsUserHasRightFailsWhenRightNull() {
  64 + }
  65 +
  66 + @Test(expected = IllegalArgumentException.class)
  67 + public void testIsUserHasRightFailsWhenRightNotInDatabase() {
34 68 }
35 69 }
... ...