@Test
public void findAll_returnsAllEntries() {
- ScimGroupDto scimGroup1 = insertScimGroup();
- ScimGroupDto scimGroup2 = insertScimGroup();
+ ScimGroupDto scimGroup1 = db.users().insertScimGroup(db.users().insertGroup());
+ ScimGroupDto scimGroup2 = db.users().insertScimGroup(db.users().insertGroup());
List<ScimGroupDto> underTest = scimGroupDao.findAll(db.getSession());
@Test
public void findByScimUuid_whenScimUuidFound_shouldReturnDto() {
- ScimGroupDto scimGroupDto = insertScimGroup();
- insertScimGroup();
+ ScimGroupDto scimGroupDto = db.users().insertScimGroup(db.users().insertGroup());
+ db.users().insertScimGroup(db.users().insertGroup());
ScimGroupDto underTest = scimGroupDao.findByScimUuid(db.getSession(), scimGroupDto.getScimGroupUuid())
.orElseGet(() -> fail("Group not found"));
@Test
public void findByGroupUuid_whenScimUuidFound_shouldReturnDto() {
- ScimGroupDto scimGroupDto = insertScimGroup();
- insertScimGroup();
+ ScimGroupDto scimGroupDto = db.users().insertScimGroup(db.users().insertGroup());
+ db.users().insertScimGroup(db.users().insertGroup());
ScimGroupDto underTest = scimGroupDao.findByGroupUuid(db.getSession(), scimGroupDto.getGroupUuid())
.orElseGet(() -> fail("Group not found"));
@Test
public void deleteByGroupUuid_shouldDeleteScimGroup() {
- ScimGroupDto scimGroupDto = insertScimGroup();
+ ScimGroupDto scimGroupDto = db.users().insertScimGroup(db.users().insertGroup());
scimGroupDao.deleteByGroupUuid(db.getSession(), scimGroupDto.getGroupUuid());
@Test
public void deleteByScimUuid_shouldDeleteScimGroup() {
- ScimGroupDto scimGroupDto1 = insertScimGroup();
- ScimGroupDto scimGroupDto2 = insertScimGroup();
+ ScimGroupDto scimGroupDto1 = db.users().insertScimGroup(db.users().insertGroup());
+ ScimGroupDto scimGroupDto2 = db.users().insertScimGroup(db.users().insertGroup());
scimGroupDao.deleteByScimUuid(db.getSession(), scimGroupDto1.getScimGroupUuid());
assertThatCode(() -> scimGroupDao.deleteByGroupUuid(db.getSession(), randomAlphanumeric(6))).doesNotThrowAnyException();
}
- private ScimGroupDto insertScimGroup() {
- return scimGroupDao.enableScimForGroup(db.getSession(), randomAlphanumeric(40));
- }
}
import org.sonar.db.permission.GroupPermissionDto;
import org.sonar.db.permission.UserPermissionDto;
import org.sonar.db.project.ProjectDto;
+import org.sonar.db.scim.ScimGroupDto;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Arrays.stream;
return dto;
}
+ public ScimGroupDto insertScimGroup(GroupDto dto) {
+ ScimGroupDto result = db.getDbClient().scimGroupDao().enableScimForGroup(db.getSession(), dto.getUuid());
+ db.commit();
+ return result;
+ }
+
public GroupDto insertDefaultGroup() {
GroupDto dto = db.getDbClient().groupDao().insert(db.getSession(), newGroupDto().setName(DefaultGroups.USERS).setDescription("Users"));
db.commit();