private final AlmPatsDbTester almPatsDbtester;
private final AuditDbTester auditDbTester;
- private DbTester(System2 system2, @Nullable String schemaPath, AuditPersister auditPersister, MyBatisConfExtension... confExtensions) {
+ private DbTester(System2 system2, boolean useDifferentProjectUuids, @Nullable String schemaPath, AuditPersister auditPersister, MyBatisConfExtension... confExtensions) {
super(TestDbImpl.create(schemaPath, confExtensions));
this.system2 = system2;
this.auditPersister = auditPersister;
initDbClient();
this.userTester = new UserDbTester(this);
- this.componentTester = new ComponentDbTester(this);
+ this.componentTester = new ComponentDbTester(this, useDifferentProjectUuids);
this.componentLinkTester = new ProjectLinkDbTester(this);
this.favoriteTester = new FavoriteDbTester(this);
this.eventTester = new EventDbTester(this);
}
public static DbTester create() {
- return new DbTester(System2.INSTANCE, null, new NoOpAuditPersister());
+ return create(false);
+ }
+
+ public static DbTester create(boolean useDifferentProjectUuids) {
+ return new DbTester(System2.INSTANCE, useDifferentProjectUuids, null, new NoOpAuditPersister());
}
public static DbTester create(AuditPersister auditPersister) {
- return new DbTester(System2.INSTANCE, null, auditPersister);
+ return new DbTester(System2.INSTANCE, false, null, auditPersister);
}
public static DbTester create(System2 system2, AuditPersister auditPersister) {
- return new DbTester(system2, null, auditPersister);
+ return new DbTester(system2, false, null, auditPersister);
}
public static DbTester create(System2 system2) {
- return new DbTester(system2, null, new NoOpAuditPersister());
+ return new DbTester(system2, false, null, new NoOpAuditPersister());
+ }
+
+ public static DbTester create(System2 system2, boolean useDifferentProjectUuids) {
+ return new DbTester(system2, useDifferentProjectUuids, null, new NoOpAuditPersister());
}
public static DbTester createWithExtensionMappers(System2 system2, Class<?> firstMapperClass, Class<?>... otherMapperClasses) {
- return new DbTester(system2, null, new NoOpAuditPersister(), new DbTesterMyBatisConfExtension(firstMapperClass, otherMapperClasses));
+ return createWithExtensionMappers(system2, false, firstMapperClass, otherMapperClasses);
+ }
+
+ public static DbTester createWithExtensionMappers(System2 system2, boolean useDifferentProjectUuids, Class<?> firstMapperClass, Class<?>... otherMapperClasses) {
+ return new DbTester(system2, useDifferentProjectUuids, null, new NoOpAuditPersister(), new DbTesterMyBatisConfExtension(firstMapperClass, otherMapperClasses));
}
private void initDbClient() {
package org.sonar.db.component;
import java.util.Arrays;
+import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
addPortfolioProject(portfolio.uuid(), projectUuids);
}
- public void addPortfolioProject(ComponentDto portfolio, ComponentDto... projects) {
- addPortfolioProject(portfolio, Arrays.stream(projects).map(ComponentDto::uuid).toArray(String[]::new));
+ public void addPortfolioProject(ComponentDto portfolio, ComponentDto... mainBranches) {
+ List<BranchDto> branchDtos = dbClient.branchDao().selectByUuids(db.getSession(), Arrays.stream(mainBranches).map(ComponentDto::uuid).toList());
+ addPortfolioProject(portfolio, branchDtos.stream().map(BranchDto::getProjectUuid).toArray(String[]::new));
}
public void addPortfolioProject(PortfolioDto portfolioDto, ProjectDto... projects) {
return t -> {
};
}
-
- public class ProjectData {
- private final BranchDto mainBranchDto;
- private final ComponentDto mainBranchComponent;
- private final ProjectDto projectDto;
-
-
- public ProjectData(ProjectDto projectDto, BranchDto mainBranchDto, ComponentDto mainBranchComponent) {
- this.mainBranchDto = mainBranchDto;
- this.mainBranchComponent = mainBranchComponent;
- this.projectDto = projectDto;
- }
-
- public ComponentDto getMainBranchComponent() {
- return mainBranchComponent;
- }
-
- public ProjectDto getProjectDto() {
- return projectDto;
- }
-
- public BranchDto getMainBranchDto() {
- return mainBranchDto;
- }
- }
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.component;
+
+import org.sonar.db.project.ProjectDto;
+
+public class ProjectData {
+ private final BranchDto mainBranchDto;
+ private final ComponentDto mainBranchComponent;
+ private final ProjectDto projectDto;
+
+ public ProjectData(ProjectDto projectDto, BranchDto mainBranchDto, ComponentDto mainBranchComponent) {
+ this.mainBranchDto = mainBranchDto;
+ this.mainBranchComponent = mainBranchComponent;
+ this.projectDto = projectDto;
+ }
+
+ public ComponentDto getMainBranchComponent() {
+ return mainBranchComponent;
+ }
+
+ public ProjectDto getProjectDto() {
+ return projectDto;
+ }
+
+ public BranchDto getMainBranchDto() {
+ return mainBranchDto;
+ }
+}