@Test public void keep_authorized_users_for_role_and_project_for_group() { db.prepareDbUnit(getClass(), "keep_authorized_users_for_role_and_project_for_group.xml"); assertThat( underTest.keepAuthorizedUsersForRoleAndProject( dbSession, // Only 100 and 101 has 'user' role on project newHashSet(100L, 101L, 102L), "user", PROJECT_ID)) .containsOnly(100L, 101L); assertThat( underTest.keepAuthorizedUsersForRoleAndProject( dbSession, newHashSet(100L), "user", PROJECT_ID)) .containsOnly(100L); // user does not have the role "admin" assertThat( underTest.keepAuthorizedUsersForRoleAndProject( dbSession, newHashSet(100L), "admin", PROJECT_ID)) .isEmpty(); // Empty list assertThat( underTest.keepAuthorizedUsersForRoleAndProject( dbSession, Collections.emptySet(), "user", PROJECT_ID)) .isEmpty(); }
@Test public void keep_authorized_users_returns_empty_list_for_role_and_project_for_anonymous() { db.prepareDbUnit(getClass(), "keep_authorized_users_for_role_and_project_for_anonymous.xml"); assertThat( underTest.keepAuthorizedUsersForRoleAndProject( dbSession, // Only 100 and 101 has 'user' role on project newHashSet(100L, 101L, 102L), "user", PROJECT_ID)) .isEmpty(); }