diff options
Diffstat (limited to 'server/sonar-db-dao')
2 files changed, 11 insertions, 4 deletions
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java index 96500a78418..6f1c4cc41a7 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java @@ -19,6 +19,7 @@ */ package org.sonar.db.permission.template; +import java.util.function.Consumer; import javax.annotation.Nullable; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -59,8 +60,9 @@ public class PermissionTemplateDbTester { ofNullable(portfoliosDefaultTemplate).map(PermissionTemplateDto::getUuid).orElse(null)); } - public PermissionTemplateDto insertTemplate() { - return insertTemplate(newPermissionTemplateDto()); + @SafeVarargs + public final PermissionTemplateDto insertTemplate(Consumer<PermissionTemplateDto>... populators) { + return insertTemplate(newPermissionTemplateDto(populators)); } public PermissionTemplateDto insertTemplate(PermissionTemplateDto template) { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateTesting.java index 7f66840d1a6..61279e233ec 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateTesting.java @@ -20,21 +20,26 @@ package org.sonar.db.permission.template; import java.util.Date; +import java.util.function.Consumer; import org.apache.commons.lang.math.RandomUtils; import org.sonar.core.util.Uuids; import org.sonar.db.permission.PermissionsTestHelper; +import static java.util.Arrays.stream; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang.RandomStringUtils.randomAscii; public class PermissionTemplateTesting { - public static PermissionTemplateDto newPermissionTemplateDto() { - return new PermissionTemplateDto() + @SafeVarargs + public static PermissionTemplateDto newPermissionTemplateDto(Consumer<PermissionTemplateDto>... populators) { + PermissionTemplateDto dto = new PermissionTemplateDto() .setName(randomAlphanumeric(60)) .setDescription(randomAscii(500)) .setUuid(Uuids.create()) .setCreatedAt(new Date()) .setUpdatedAt(new Date()); + stream(populators).forEach(p -> p.accept(dto)); + return dto; } public static PermissionTemplateUserDto newPermissionTemplateUserDto() { |