diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2019-10-08 17:51:53 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-11-06 10:04:19 +0100 |
commit | 58d04f69bb33f17cfe6db3d9885fe4c9adabd2d1 (patch) | |
tree | bc48a5c0b0e2884ffa6ec2b61c99326844f030ba /server/sonar-db-dao/src/testFixtures/java/org/sonar | |
parent | f8c9b9c8b3e7040907e0ded89511f86b827449ad (diff) | |
download | sonarqube-58d04f69bb33f17cfe6db3d9885fe4c9adabd2d1.tar.gz sonarqube-58d04f69bb33f17cfe6db3d9885fe4c9adabd2d1.zip |
SONAR-12512 Allow configuration of multiple GitHub instances
Diffstat (limited to 'server/sonar-db-dao/src/testFixtures/java/org/sonar')
3 files changed, 91 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java index 1fc19513ada..a39cd1dea64 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java @@ -33,6 +33,7 @@ import org.picocontainer.containers.TransientPicoContainer; import org.sonar.api.utils.System2; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.alm.AlmDbTester; +import org.sonar.db.almsettings.AlmSettingsDbTester; import org.sonar.db.component.ComponentDbTester; import org.sonar.db.component.ProjectLinkDbTester; import org.sonar.db.event.EventDbTester; @@ -96,6 +97,7 @@ public class DbTester extends AbstractDbTester<TestDbImpl> { private final WebhookDeliveryDbTester webhookDeliveryDbTester; private final AlmDbTester almDbTester; private final InternalComponentPropertyDbTester internalComponentPropertyTester; + private final AlmSettingsDbTester almSettingsDbTester; private DbTester(System2 system2, @Nullable String schemaPath, MyBatisConfExtension... confExtensions) { super(TestDbImpl.create(schemaPath, confExtensions)); @@ -124,6 +126,7 @@ public class DbTester extends AbstractDbTester<TestDbImpl> { this.almDbTester = new AlmDbTester(this); this.internalComponentPropertyTester = new InternalComponentPropertyDbTester(this); this.newCodePeriodTester = new NewCodePeriodDbTester(this); + this.almSettingsDbTester = new AlmSettingsDbTester(this); } public static DbTester create() { @@ -294,6 +297,10 @@ public class DbTester extends AbstractDbTester<TestDbImpl> { return internalComponentPropertyTester; } + public AlmSettingsDbTester almSettings() { + return almSettingsDbTester; + } + @Override protected void after() { if (session != null) { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsDbTester.java new file mode 100644 index 00000000000..0a74acc40cf --- /dev/null +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsDbTester.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.almsettings; + +import java.util.function.Consumer; +import org.sonar.db.DbTester; +import org.sonar.db.alm.setting.AlmSettingDto; + +import static java.util.Arrays.stream; +import static org.sonar.db.almsettings.AlmSettingsTesting.newGithubAlmSettingDto; + +public class AlmSettingsDbTester { + + private final DbTester db; + + public AlmSettingsDbTester(DbTester db) { + this.db = db; + } + + @SafeVarargs + public final AlmSettingDto insertGitHubAlmSetting(Consumer<AlmSettingDto>... populators) { + AlmSettingDto dto = newGithubAlmSettingDto(); + stream(populators).forEach(p -> p.accept(dto)); + + db.getDbClient().almSettingDao().insert(db.getSession(), dto); + db.commit(); + return dto; + } + +} diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsTesting.java new file mode 100644 index 00000000000..e799a859f8f --- /dev/null +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/almsettings/AlmSettingsTesting.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.almsettings; + +import org.sonar.db.alm.setting.ALM; +import org.sonar.db.alm.setting.AlmSettingDto; + +import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; + +public class AlmSettingsTesting { + + public static AlmSettingDto newGithubAlmSettingDto() { + return new AlmSettingDto() + .setKey(randomAlphanumeric(40)) + .setUrl(randomAlphanumeric(2000)) + .setAppId(randomAlphanumeric(80)) + .setAlm(ALM.GITHUB) + .setPrivateKey(randomAlphanumeric(2000)); + } +} |