Source:
public void keepAuthorizedLoginsOnProject_return_correct_users_on_private_project() { ComponentDto project = db.components().insertPrivateProject(organization); GroupDto userGroup = db.users().insertGroup(organization, "USERS"); GroupDto adminGroup = db.users().insertGroup(organization, "ADMIN"); db.users().insertProjectPermissionOnGroup(userGroup, UserRole.USER, project); db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project); UserDto admin1 = db.users().insertUser(); db.users().insertProjectPermissionOnUser(admin1, UserRole.ADMIN, project); UserDto admin2 = db.users().insertUser(); db.users().insertMember(adminGroup, admin2); UserDto user1 = db.users().insertUser(); db.users().insertProjectPermissionOnUser(user1, UserRole.USER, project); UserDto user2 = db.users().insertUser(); db.users().insertMember(userGroup, user2); UserDto userWithNoRole = db.users().insertUser(); List<String> allLogins = Arrays.asList(admin1.getLogin(), admin2.getLogin(), user1.getLogin(), user2.getLogin(), userWithNoRole.getLogin()); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, asList(userWithNoRole.getLogin()), project.getRootUuid(), UserRole.USER)) .isEmpty(); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, asList(user1.getLogin()), project.getRootUuid(), UserRole.USER)) .containsOnly(user1.getLogin()); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.getRootUuid(), UserRole.USER)) .containsOnly(user1.getLogin(), user2.getLogin()); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.getRootUuid(), UserRole.ADMIN)) .containsOnly(admin1.getLogin(), admin2.getLogin()); }

Target:
public void keepAuthorizedLoginsOnProject_return_correct_users_on_private_project() { ComponentDto project = db.components().insertPrivateProject(organization); GroupDto userGroup = db.users().insertGroup(organization, "USERS"); GroupDto adminGroup = db.users().insertGroup(organization, "ADMIN"); db.users().insertProjectPermissionOnGroup(userGroup, UserRole.USER, project); db.users().insertProjectPermissionOnGroup(adminGroup, UserRole.ADMIN, project); UserDto admin1 = db.users().insertUser(); db.users().insertProjectPermissionOnUser(admin1, UserRole.ADMIN, project); UserDto admin2 = db.users().insertUser(); db.users().insertMember(adminGroup, admin2); UserDto user1 = db.users().insertUser(); db.users().insertProjectPermissionOnUser(user1, UserRole.USER, project); UserDto user2 = db.users().insertUser(); db.users().insertMember(userGroup, user2); UserDto userWithNoRole = db.users().insertUser(); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(userWithNoRole.getLogin()), project.uuid(), UserRole.USER)) .isEmpty(); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, newHashSet(user1.getLogin()), project.uuid(), UserRole.USER)) .containsOnly(user1.getLogin()); Set<String> allLogins = newHashSet(admin1.getLogin(), admin2.getLogin(), user1.getLogin(), user2.getLogin(), userWithNoRole.getLogin()); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.uuid(), UserRole.USER)) .containsOnly(user1.getLogin(), user2.getLogin()); assertThat(underTest.keepAuthorizedLoginsOnProject(dbSession, allLogins, project.uuid(), UserRole.ADMIN)) .containsOnly(admin1.getLogin(), admin2.getLogin()); }