public UserGroupDto addMembership(String groupUuid, String userUuid) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      UserDto userDto = findUserOrThrow(userUuid, dbSession);
      GroupDto groupDto = findNonDefaultGroupOrThrow(groupUuid, dbSession);
      UserGroupDto userGroupDto = new UserGroupDto().setGroupUuid(groupUuid).setUserUuid(userUuid);
      checkArgument(isNotInGroup(dbSession, groupUuid, userUuid), "User '%s' is already a member of group '%s'", userDto.getLogin(), groupDto.getName());
      userGroupDao.insert(dbSession, userGroupDto, groupDto.getName(), userDto.getLogin());
      dbSession.commit();
      return userGroupDto;
    }
  }
@Test
  public void addMembership_ifGroupNotFound_shouldThrow() {
    mockUserDto();

    assertThatExceptionOfType(NotFoundException.class)
      .isThrownBy(() -> groupMembershipService.addMembership(GROUP_A, USER_1))
      .withMessage("Group 'group_a' not found");
  }