### Question:
UserService implements IUserService { @Override public List<UserGroupPermissions> getMyGroupPermissions(UserDetails user) { return Optional.ofNullable(user) .map(UserDetails::getAuthorizations) .orElse(new ArrayList<>()) .stream() .map(authorization -> new UserGroupPermissions(authorization.getGroup().getName(), authorization.getRole().getPermissions())) .collect(Collectors.toList()); }  IUserManager getUserManager(); void setUserManager(IUserManager userManager); IUserProfileManager getUserProfileManager(); void setUserProfileManager(IUserProfileManager userProfileManager); IAuthorizationManager getAuthorizationManager(); void setAuthorizationManager(IAuthorizationManager authorizationManager); IAuthenticationProviderManager getAuthenticationProvider(); void setAuthenticationProvider(IAuthenticationProviderManager authenticationProvider); IDtoBuilder<UserDetails, UserDto> getDtoBuilder(); void setDtoBuilder(IDtoBuilder<UserDetails, UserDto> dtoBuilder); @Override List<UserAuthorityDto> getUserAuthorities(String username); @Override List<UserAuthorityDto> addUserAuthorities(String username, UserAuthoritiesRequest request); @Override List<UserAuthorityDto> updateUserAuthorities(String username, UserAuthoritiesRequest request); @Override void deleteUserAuthorities(String username); @Override PagedMetadata<UserDto> getUsers(RestListRequest requestList, String withProfile); @Override UserDto getUser(String username); @Override UserDto updateUser(UserRequest userRequest); @Override UserDto addUser(UserRequest userRequest); @Override void removeUser(String username); @Override UserDto updateUserPassword(UserPasswordRequest passwordRequest); @Override List<UserGroupPermissions> getMyGroupPermissions(UserDetails user);  }### Answer:
@Test public void getMyGroupPermissionsTest() { userDetails.addAuthorizations(authorizationList); List<UserGroupPermissions> expectedList = authorizationList.stream() .map(authorization -> new UserGroupPermissions(authorization.getGroup().getName(), authorization.getRole().getPermissions())) .collect(Collectors.toList()); List<UserGroupPermissions> actualList = userService.getMyGroupPermissions(userDetails); UserGroupPermissionAssertionHelper.assertUserGroupPermissions(expectedList, actualList); }
@Test public void getMyGroupPermissionsWithNoAuthorizationsTest() { List<UserGroupPermissions> actualList = userService.getMyGroupPermissions(userDetails); assertEquals(0, actualList.size()); }
@Test public void getMyGroupPermissionsWithNullUserShouldReturnEmptyListTest() { List<UserGroupPermissions> actualList = userService.getMyGroupPermissions(null); assertEquals(0, actualList.size()); }