GroupService { @CacheEvict(value = "group-user-cache", allEntries = true) public void createGroup(String name, String description, boolean publicGroup) { log.debug("Creating group : {}", name); User currentUser = authenticationService.getCurrentUser(); String domain = DomainUtil.getDomainFromLogin(currentUser.getLogin()); String groupId = groupRepository.createGroup(domain); groupDetailsRepository.createGroupDetails(groupId, name, description, publicGroup); groupMembersRepository.addAdmin(groupId, currentUser.getLogin()); groupCounterRepository.incrementGroupCounter(domain, groupId); userGroupRepository.addGroupAsAdmin(currentUser.getLogin(), groupId); Group group = getGroupById(domain, groupId); searchService.addGroup(group); }  @CacheEvict(value = "group-user-cache", allEntries = true) void createGroup(String name, String description, boolean publicGroup); @CacheEvict(value = {"group-user-cache", "group-cache"}, allEntries = true) void editGroup(Group group); Collection<UserGroupDTO> getMembersForGroup(String groupId, String login); UserGroupDTO getMembersForGroup(String groupId, User userWanted); @Cacheable(value = "group-user-cache", key = "#user.login") Collection<Group> getGroupsForUser(User user); @Cacheable(value = "group-user-cache", key = "#user.login") Collection<Group> getGroupsOfUser(User user); @Cacheable(value = "group-cache") Group getGroupById(String domain, String groupId); Collection<Group> getGroupsWhereUserIsAdmin(User user); Collection<Group> getGroupsWhereCurrentUserIsAdmin(); @CacheEvict(value = {"group-user-cache", "group-cache"}, allEntries = true) void addMemberToGroup(User user, Group group); @CacheEvict(value = {"group-user-cache", "group-cache"}, allEntries = true) void removeMemberFromGroup(User user, Group group); Collection<Group> buildGroupList(Collection<Group> groups); Collection<Group> buildGroupList(User user, Collection<Group> groups); Group buildGroup(Group group); Group buildGroup(User user, Group group); Collection<Group> buildGroupIdsList(Collection<String> groupIds); Group buildGroupIds(String groupId); Group buildGroupIds(User user, String groupId);  }
@Test public void createGroup() { mockAuthentication("jdubois@ippon.fr"); User user = userService.getUserByLogin("jdubois@ippon.fr"); assertEquals(0, groupService.getGroupsForUser(user).size()); String groupName = "Group name"; String groupDescription = "Group description"; boolean publicGroup = true; groupService.createGroup(groupName, groupDescription, publicGroup); Collection<Group> groups = groupService.getGroupsForUser(user); assertEquals(1, groups.size()); Group group = groups.iterator().next(); assertEquals(groupName, group.getName()); assertEquals(groupDescription, group.getDescription()); assertTrue(group.isPublicGroup()); assertFalse(group.isArchivedGroup()); }