### Question:
UserGroupServiceImpl implements UserGroupService { @Override public void createGroup(String group, Set<String> roleIds, Set<String> users) { checkAnyRoleFound(roleIds, userRoleDao.addGroupToRole(Collections.singleton(group), roleIds)); log.debug("Adding users {} to group {}", users, group); userGroupDao.addUsers(group, users); }  @Override void createGroup(String group, Set<String> roleIds, Set<String> users); @Override void updateGroup(UserInfo user, String group, Set<String> roleIds, Set<String> users); @Override void removeGroup(String groupId); @Override List<UserGroupDto> getAggregatedRolesByGroup(UserInfo user);  }### Answer:
@Test public void createGroup() { when(userRoleDao.addGroupToRole(anySet(), anySet())).thenReturn(true); userGroupService.createGroup(GROUP, Collections.singleton(ROLE_ID), Collections.singleton(USER)); verify(userRoleDao).addGroupToRole(Collections.singleton(GROUP), Collections.singleton(ROLE_ID)); verify(userGroupDao).addUsers(GROUP, Collections.singleton(USER)); }
@Test public void createGroupWithNoUsers() { when(userRoleDao.addGroupToRole(anySet(), anySet())).thenReturn(true); userGroupService.createGroup(GROUP, Collections.singleton(ROLE_ID), Collections.emptySet()); verify(userRoleDao).addGroupToRole(Collections.singleton(GROUP), Collections.singleton(ROLE_ID)); verify(userGroupDao).addUsers(anyString(), anySet()); }
@Test public void createGroupWhenRoleNotFound() { when(userRoleDao.addGroupToRole(anySet(), anySet())).thenReturn(false); expectedException.expect(ResourceNotFoundException.class); userGroupService.createGroup(GROUP, Collections.singleton(ROLE_ID), Collections.singleton(USER)); }