aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-core
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2020-12-21 17:55:10 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:39 +0000
commit5bfa95f6d5928460f1d8102417d5b6604f96feba (patch)
treeb3bec61cc2bed8fbdbbb31d80385b228686ffa33 /server/sonar-webserver-core
parent255d1fb82f78f046ef95f2e7a45cc5d4ba94c97e (diff)
downloadsonarqube-5bfa95f6d5928460f1d8102417d5b6604f96feba.tar.gz
sonarqube-5bfa95f6d5928460f1d8102417d5b6604f96feba.zip
SONAR-13999 Remove OrganizationDbTester
Diffstat (limited to 'server/sonar-webserver-core')
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java7
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java18
2 files changed, 10 insertions, 15 deletions
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
index 581b78ee09e..7bd80d56850 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
@@ -37,7 +37,6 @@ import org.sonar.db.metric.MetricDto;
import org.sonar.server.es.EsTester;
import org.sonar.server.measure.index.ProjectMeasuresIndex;
import org.sonar.server.measure.index.ProjectMeasuresIndexer;
-import org.sonar.server.organization.DefaultOrganizationProviderImpl;
import org.sonar.server.platform.DockerSupport;
import org.sonar.server.property.InternalProperties;
import org.sonar.server.property.MapInternalProperties;
@@ -105,14 +104,14 @@ public class TelemetryDataLoaderImplTest {
MetricDto coverage = db.measures().insertMetric(m -> m.setKey(COVERAGE_KEY));
MetricDto nclocDistrib = db.measures().insertMetric(m -> m.setKey(NCLOC_LANGUAGE_DISTRIBUTION_KEY));
- ComponentDto project1 = db.components().insertPublicProject(db.getDefaultOrganization());
+ ComponentDto project1 = db.components().insertPublicProject();
ComponentDto project1Branch = db.components().insertProjectBranch(project1);
db.measures().insertLiveMeasure(project1, lines, m -> m.setValue(200d));
db.measures().insertLiveMeasure(project1, ncloc, m -> m.setValue(100d));
db.measures().insertLiveMeasure(project1, coverage, m -> m.setValue(80d));
db.measures().insertLiveMeasure(project1, nclocDistrib, m -> m.setValue(null).setData("java=200;js=50"));
- ComponentDto project2 = db.components().insertPublicProject(db.getDefaultOrganization());
+ ComponentDto project2 = db.components().insertPublicProject();
db.measures().insertLiveMeasure(project2, lines, m -> m.setValue(300d));
db.measures().insertLiveMeasure(project2, ncloc, m -> m.setValue(200d));
db.measures().insertLiveMeasure(project2, coverage, m -> m.setValue(80d));
@@ -150,7 +149,7 @@ public class TelemetryDataLoaderImplTest {
public void take_largest_branches() {
server.setId("AU-TpxcB-iU5OvuD2FL7").setVersion("7.5.4");
MetricDto ncloc = db.measures().insertMetric(m -> m.setKey(NCLOC_KEY));
- ComponentDto project = db.components().insertPublicProject(db.getDefaultOrganization());
+ ComponentDto project = db.components().insertPublicProject();
ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST));
db.measures().insertLiveMeasure(project, ncloc, m -> m.setValue(10d));
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
index 12cfc351d89..ad1ad814f25 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
@@ -45,7 +45,6 @@ import org.sonar.db.component.AnalysisPropertyDto;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.SnapshotDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.server.qualitygate.EvaluatedQualityGate;
import org.sonar.server.qualitygate.changeevent.QGChangeEvent;
@@ -141,8 +140,7 @@ public class WebhookQGChangeEventListenerTest {
@Test
@UseDataProvider("newQGorNot")
public void onIssueChanges_calls_webhook_for_changeEvent_with_webhook_enabled(@Nullable EvaluatedQualityGate newQualityGate) {
- OrganizationDto organization = dbTester.organizations().insert();
- ProjectAndBranch projectBranch = insertBranch(organization, BRANCH, "foo");
+ ProjectAndBranch projectBranch = insertBranch(BRANCH, "foo");
SnapshotDto analysis = insertAnalysisTask(projectBranch);
Configuration configuration = mock(Configuration.class);
mockPayloadSupplierConsumedByWebhooks();
@@ -170,8 +168,7 @@ public class WebhookQGChangeEventListenerTest {
@Test
@UseDataProvider("newQGorNot")
public void onIssueChanges_calls_webhook_on_main_branch(@Nullable EvaluatedQualityGate newQualityGate) {
- OrganizationDto organization = dbTester.organizations().insert();
- ProjectAndBranch mainBranch = insertMainBranch(organization);
+ ProjectAndBranch mainBranch = insertMainBranch();
SnapshotDto analysis = insertAnalysisTask(mainBranch);
Configuration configuration = mock(Configuration.class);
QGChangeEvent qualityGateEvent = newQGChangeEvent(mainBranch, analysis, configuration, newQualityGate);
@@ -193,8 +190,7 @@ public class WebhookQGChangeEventListenerTest {
}
public void onIssueChangesCallsWebhookOnBranch(BranchType branchType) {
- OrganizationDto organization = dbTester.organizations().insert();
- ProjectAndBranch nonMainBranch = insertBranch(organization, branchType, "foo");
+ ProjectAndBranch nonMainBranch = insertBranch(branchType, "foo");
SnapshotDto analysis = insertAnalysisTask(nonMainBranch);
Configuration configuration = mock(Configuration.class);
QGChangeEvent qualityGateEvent = newQGChangeEvent(nonMainBranch, analysis, configuration, null);
@@ -270,15 +266,15 @@ public class WebhookQGChangeEventListenerTest {
return projectAnalysisCaptor.getAllValues();
}
- public ProjectAndBranch insertMainBranch(OrganizationDto organization) {
- ProjectDto project = dbTester.components().insertPrivateProjectDto(organization);
+ public ProjectAndBranch insertMainBranch() {
+ ProjectDto project = dbTester.components().insertPrivateProjectDto();
BranchDto branch = dbTester.getDbClient().branchDao().selectByUuid(dbTester.getSession(), project.getUuid()).get();
dbTester.commit();
return new ProjectAndBranch(project, branch);
}
- public ProjectAndBranch insertBranch(OrganizationDto organization, BranchType type, String branchKey) {
- ProjectDto project = dbTester.components().insertPrivateProjectDto(organization);
+ public ProjectAndBranch insertBranch(BranchType type, String branchKey) {
+ ProjectDto project = dbTester.components().insertPrivateProjectDto();
BranchDto branch = dbTester.components().insertProjectBranch(project, b -> b.setKey(branchKey).setBranchType(type));
return new ProjectAndBranch(project, branch);
}