]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13999 drop leftovers of organization from Measures WSs
authorJacek <jacek.poreda@sonarsource.com>
Thu, 17 Dec 2020 10:09:43 +0000 (11:09 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Dec 2020 20:09:38 +0000 (20:09 +0000)
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/MeasureMatrixTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java

index 1e6c45b92603fecdafbe3558f21b841a11734dc6..1da74f0cf6752a07f4d0a97123d6358f94703eae 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.measure.custom.CustomMeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.component.TestComponentFinder;
 import org.sonar.server.es.EsTester;
@@ -284,8 +283,7 @@ public class CreateActionTest {
   @Test
   public void create_custom_measure_on_a_view() {
     MetricDto metric = db.measures().insertMetric(m -> m.setUserManaged(true).setValueType(BOOL.name()));
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto view = db.components().insertPrivatePortfolio(organization);
+    ComponentDto view = db.components().insertPrivatePortfolio();
     UserDto user = db.users().insertUser();
     userSession.logIn(user).addProjectPermission(ADMIN, view);
 
@@ -304,8 +302,7 @@ public class CreateActionTest {
   @Test
   public void create_custom_measure_on_a_sub_view() {
     MetricDto metric = db.measures().insertMetric(m -> m.setUserManaged(true).setValueType(BOOL.name()));
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto view = db.components().insertPrivatePortfolio(organization);
+    ComponentDto view = db.components().insertPrivatePortfolio();
     ComponentDto subView = db.components().insertSubView(view);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).addProjectPermission(ADMIN, view);
index b314dc970bcc47b6fb61523e64686f6f56f22ef8..c20f4656ecdbedf38b881ad57620d3f1d2d7f506 100644 (file)
@@ -60,8 +60,8 @@ public class MetricsActionTest {
   private final DbClient dbClient = db.getDbClient();
   private final DbSession dbSession = db.getSession();
   private ComponentDto defaultProject;
-  private MetricsAction underTest = new MetricsAction(dbClient, userSession, TestComponentFinder.from(db));
-  private WsActionTester tester = new WsActionTester(underTest);
+  private final MetricsAction underTest = new MetricsAction(dbClient, userSession, TestComponentFinder.from(db));
+  private final WsActionTester tester = new WsActionTester(underTest);
 
   @Before
   public void setUp() {
@@ -217,11 +217,9 @@ public class MetricsActionTest {
   }
 
   private ComponentDto insertProject(String projectUuid, String projectKey) {
-    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), projectUuid)
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(projectUuid)
       .setDbKey(projectKey);
-    dbClient.componentDao().insert(dbSession, project);
-    dbSession.commit();
-
+    db.components().insertComponent(project);
     return project;
   }
 
index e626c7205d1f7fdd7c65230bafc07d3abf37f1be..91ebe0fe8114868f9a9d8c287d979a27981e847a 100644 (file)
@@ -49,7 +49,6 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.measure.LiveMeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.project.ProjectDto;
 import org.sonar.server.es.ProjectIndexer;
 import org.sonar.server.es.TestProjectIndexers;
@@ -85,7 +84,6 @@ public class LiveMeasureComputerImplTest {
   private MetricDto intMetric;
   private MetricDto ratingMetric;
   private MetricDto alertStatusMetric;
-  private OrganizationDto organization;
   private ComponentDto project;
   private ProjectDto projectDto;
   private ComponentDto dir;
@@ -102,8 +100,7 @@ public class LiveMeasureComputerImplTest {
     intMetric = db.measures().insertMetric(m -> m.setValueType(Metric.ValueType.INT.name()));
     ratingMetric = db.measures().insertMetric(m -> m.setValueType(Metric.ValueType.RATING.name()));
     alertStatusMetric = db.measures().insertMetric(m -> m.setKey(CoreMetrics.ALERT_STATUS_KEY));
-    organization = db.organizations().insert();
-    project = db.components().insertPublicProject(organization);
+    project = db.components().insertPublicProject();
     projectDto = db.components().getProjectDto(project);
     dir = db.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java"));
     file1 = db.components().insertComponent(ComponentTesting.newFileDto(project, dir));
index 0416ed408b3f1deab6c9655dd6895ea80c4b466b..63ed07d0191740ec1ab6795b175220de29c81063 100644 (file)
@@ -52,7 +52,6 @@ import static java.util.Collections.singleton;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.groups.Tuple.tuple;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
-import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 
 public class LiveQualityGateComputerImplTest {
 
@@ -83,7 +82,7 @@ public class LiveQualityGateComputerImplTest {
   }
 
   @Test
-  public void loadQualityGate_on_branch_returns_organization_default_gate() {
+  public void loadQualityGate_on_branch_returns_default_gate() {
     ProjectDto project = db.components().insertPublicProjectDto();
     BranchDto branch = db.components().insertProjectBranch(project).setBranchType(BranchType.BRANCH);
 
@@ -117,7 +116,7 @@ public class LiveQualityGateComputerImplTest {
 
   @Test
   public void refreshGateStatus_generates_gate_related_measures() {
-    ComponentDto project = ComponentTesting.newPublicProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPublicProjectDto();
     MetricDto conditionMetric = newMetricDto();
     MetricDto statusMetric = newMetricDto().setKey(CoreMetrics.ALERT_STATUS_KEY);
     MetricDto detailsMetric = newMetricDto().setKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY);
@@ -143,7 +142,7 @@ public class LiveQualityGateComputerImplTest {
 
   @Test
   public void refreshGateStatus_provides_measures_to_evaluator() {
-    ComponentDto project = ComponentTesting.newPublicProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPublicProjectDto();
     MetricDto numericMetric = newMetricDto().setValueType(Metric.ValueType.FLOAT.name());
     MetricDto numericNewMetric = newMetricDto().setValueType(Metric.ValueType.FLOAT.name()).setKey("new_metric");
     MetricDto stringMetric = newMetricDto().setValueType(Metric.ValueType.STRING.name());
index f71f39a160032abf39f29aa208697e46ec0cb31c..ceedfb972fb3e564f170263c52c7fefbf5db92bc 100644 (file)
@@ -30,18 +30,15 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.measure.LiveMeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 
 import static java.util.Arrays.asList;
 import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
-import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 
 public class MeasureMatrixTest {
 
-  private static final OrganizationDto ORGANIZATION = newOrganizationDto();
-  private static final ComponentDto PROJECT = ComponentTesting.newPublicProjectDto(ORGANIZATION);
+  private static final ComponentDto PROJECT = ComponentTesting.newPublicProjectDto();
   private static final ComponentDto FILE = ComponentTesting.newFileDto(PROJECT);
   private static final MetricDto METRIC_1 = newMetricDto().setUuid("100");
   private static final MetricDto METRIC_2 = newMetricDto().setUuid("200");
index 68ace74a17d74205f9a4bdb0e2bd07a6559e09a5..fa0d97ee2f36301d8237c0fb8f296f76d3abdca4 100644 (file)
@@ -32,7 +32,6 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.LiveMeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.TestComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -69,7 +68,7 @@ public class ComponentActionTest {
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
 
-  private WsActionTester ws = new WsActionTester(new ComponentAction(db.getDbClient(), TestComponentFinder.from(db), userSession));
+  private final WsActionTester ws = new WsActionTester(new ComponentAction(db.getDbClient(), TestComponentFinder.from(db), userSession));
 
   @Test
   public void definition() {
@@ -396,8 +395,7 @@ public class ComponentActionTest {
 
   @Test
   public void fail_when_using_branch_db_key() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType("INT"));
index 4790e657094af259d88748d4ec48c68c05a188a7..7d36d999000ab26747b94143872ff300a9300184 100644 (file)
@@ -40,7 +40,6 @@ import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.LiveMeasureDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.metric.MetricTesting;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -106,14 +105,14 @@ public class ComponentTreeActionTest {
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
 
-  private I18nRule i18n = new I18nRule();
-  private ResourceTypesRule resourceTypes = new ResourceTypesRule()
+  private final I18nRule i18n = new I18nRule();
+  private final ResourceTypesRule resourceTypes = new ResourceTypesRule()
     .setRootQualifiers(PROJECT)
     .setLeavesQualifiers(FILE, UNIT_TEST_FILE);
-  private DbClient dbClient = db.getDbClient();
-  private DbSession dbSession = db.getSession();
+  private final DbClient dbClient = db.getDbClient();
+  private final DbSession dbSession = db.getSession();
 
-  private WsActionTester ws = new WsActionTester(
+  private final WsActionTester ws = new WsActionTester(
     new ComponentTreeAction(
       dbClient, new ComponentFinder(dbClient, resourceTypes), userSession,
       i18n, resourceTypes));
@@ -529,8 +528,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void branch() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
     SnapshotDto analysis = db.components().insertSnapshot(branch);
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
@@ -552,8 +550,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void pull_request() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
     SnapshotDto analysis = db.components().insertSnapshot(branch);
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
@@ -575,8 +572,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fix_pull_request_new_issue_count_metrics() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
     SnapshotDto analysis = db.components().insertSnapshot(branch);
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
@@ -604,8 +600,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void new_issue_count_measures_are_not_transformed_if_they_dont_exist_in_pr() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setKey("pr").setBranchType(PULL_REQUEST));
     SnapshotDto analysis = db.components().insertSnapshot(pr);
     ComponentDto file = db.components().insertComponent(newFileDto(pr));
@@ -694,7 +689,7 @@ public class ComponentTreeActionTest {
   @Test
   public void project_reference_from_portfolio() {
     ComponentDto project = db.components().insertPrivateProject();
-    ComponentDto view = db.components().insertPrivatePortfolio(db.getDefaultOrganization());
+    ComponentDto view = db.components().insertPrivatePortfolio();
     SnapshotDto viewAnalysis = db.components().insertSnapshot(view);
     ComponentDto projectCopy = db.components().insertComponent(newProjectCopy(project, view));
     MetricDto ncloc = insertNclocMetric();
@@ -978,9 +973,8 @@ public class ComponentTreeActionTest {
   }
 
   @Test
-  public void fail_when_using_branch_db_key() throws Exception {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+  public void fail_when_using_branch_db_key() {
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
     insertNclocMetric();
@@ -996,8 +990,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_using_branch_uuid() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
     insertNclocMetric();
index 18b35e2d157bd3194ddfe7b10704e10cce6a9d42..8aeb6d3a8f215e6cf16c7b200e2bdb81aca979a1 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
@@ -55,9 +54,9 @@ import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
-import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS;
 import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS;
+import static org.sonar.test.JsonAssert.assertJson;
 
 public class SearchActionTest {
 
@@ -70,15 +69,13 @@ public class SearchActionTest {
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
 
-  private WsActionTester ws = new WsActionTester(new SearchAction(userSession, db.getDbClient()));
+  private final WsActionTester ws = new WsActionTester(new SearchAction(userSession, db.getDbClient()));
 
   @Test
   public void json_example() {
-    OrganizationDto organization = db.organizations().insert();
-
-    ComponentDto project1 = db.components().insertPrivateProject(organization, p -> p.setDbKey("MY_PROJECT_1").setName("Project 1"));
-    ComponentDto project2 = db.components().insertPrivateProject(organization, p -> p.setDbKey("MY_PROJECT_2").setName("Project 2"));
-    ComponentDto project3 = db.components().insertPrivateProject(organization, p -> p.setDbKey("MY_PROJECT_3").setName("Project 3"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_1").setName("Project 1"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_2").setName("Project 2"));
+    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setDbKey("MY_PROJECT_3").setName("Project 3"));
 
     userSession.addProjectPermission(UserRole.USER, project1);
     userSession.addProjectPermission(UserRole.USER, project2);
@@ -112,7 +109,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures() {
-    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(project, coverage, m -> m.setValue(15.5d));
@@ -128,7 +125,7 @@ public class SearchActionTest {
 
   @Test
   public void return_best_value() {
-    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto matchBestValue = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()).setBestValue(15.5d));
     db.measures().insertLiveMeasure(project, matchBestValue, m -> m.setValue(15.5d));
@@ -151,8 +148,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures_on_new_code_period() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(project, coverage, m -> m.setValue(15.5d).setVariation(10d));
@@ -173,10 +169,9 @@ public class SearchActionTest {
   public void sort_by_metric_key_then_project_name() {
     MetricDto coverage = db.measures().insertMetric(m -> m.setKey("coverage").setValueType(FLOAT.name()));
     MetricDto complexity = db.measures().insertMetric(m -> m.setKey("complexity").setValueType(INT.name()));
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project1 = db.components().insertPrivateProject(organization, p -> p.setName("C"));
-    ComponentDto project2 = db.components().insertPrivateProject(organization, p -> p.setName("A"));
-    ComponentDto project3 = db.components().insertPrivateProject(organization, p -> p.setName("B"));
+    ComponentDto project1 = db.components().insertPrivateProject(p -> p.setName("C"));
+    ComponentDto project2 = db.components().insertPrivateProject(p -> p.setName("A"));
+    ComponentDto project3 = db.components().insertPrivateProject(p -> p.setName("B"));
     userSession.addProjectPermission(UserRole.USER, project1);
     userSession.addProjectPermission(UserRole.USER, project2);
     userSession.addProjectPermission(UserRole.USER, project3);
@@ -197,8 +192,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures_on_view() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto view = db.components().insertPrivatePortfolio(organization);
+    ComponentDto view = db.components().insertPrivatePortfolio();
     userSession.addProjectPermission(UserRole.USER, view);
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(view, coverage, m -> m.setValue(15.5d));
@@ -214,8 +208,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures_on_application() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto application = db.components().insertPrivateApplication(organization);
+    ComponentDto application = db.components().insertPrivateApplication();
     userSession.addProjectPermission(UserRole.USER, application);
     MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
     db.measures().insertLiveMeasure(application, coverage, m -> m.setValue(15.5d));
@@ -231,8 +224,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures_on_sub_view() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto view = db.components().insertPrivatePortfolio(organization);
+    ComponentDto view = db.components().insertPrivatePortfolio();
     ComponentDto subView = db.components().insertComponent(newSubView(view));
     userSession.addProjectPermission(UserRole.USER, subView);
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
@@ -250,8 +242,8 @@ public class SearchActionTest {
   @Test
   public void only_returns_authorized_projects() {
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
-    ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization());
-    ComponentDto project2 = db.components().insertPrivateProject(db.getDefaultOrganization());
+    ComponentDto project1 = db.components().insertPrivateProject();
+    ComponentDto project2 = db.components().insertPrivateProject();
     db.measures().insertLiveMeasure(project1, metric, m -> m.setValue(15.5d));
     db.measures().insertLiveMeasure(project2, metric, m -> m.setValue(42.0d));
     Arrays.stream(new ComponentDto[] {project1}).forEach(p -> userSession.addProjectPermission(UserRole.USER, p));
@@ -264,7 +256,7 @@ public class SearchActionTest {
   @Test
   public void do_not_verify_permissions_if_user_is_root() {
     MetricDto metric = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
-    ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization());
+    ComponentDto project1 = db.components().insertPrivateProject();
     db.measures().insertLiveMeasure(project1, metric, m -> m.setValue(15.5d));
 
     userSession.setNonRoot();
index b2209f6c6a895819043ebf4cfcb98c2b67f99464..56bdc57d52739436cef2fe44e3091b1715c63d38 100644 (file)
@@ -38,7 +38,6 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.TestComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -84,10 +83,10 @@ public class SearchHistoryActionTest {
   @Rule
   public DbTester db = DbTester.create();
 
-  private DbClient dbClient = db.getDbClient();
-  private DbSession dbSession = db.getSession();
+  private final DbClient dbClient = db.getDbClient();
+  private final DbSession dbSession = db.getSession();
 
-  private WsActionTester ws = new WsActionTester(new SearchHistoryAction(dbClient, TestComponentFinder.from(db), userSession));
+  private final WsActionTester ws = new WsActionTester(new SearchHistoryAction(dbClient, TestComponentFinder.from(db), userSession));
 
   private ComponentDto project;
   private SnapshotDto analysis;
@@ -98,7 +97,7 @@ public class SearchHistoryActionTest {
 
   @Before
   public void setUp() {
-    project = newPrivateProjectDto(db.getDefaultOrganization());
+    project = newPrivateProjectDto();
     analysis = db.components().insertProjectAndSnapshot(project);
     userSession.addProjectPermission(UserRole.USER, project);
     nclocMetric = insertNclocMetric();
@@ -342,8 +341,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void fail_when_using_branch_db_key() {
-    OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(organization);
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     ComponentDto branch = db.components().insertProjectBranch(project);
 
@@ -396,7 +394,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void fail_when_component_is_removed() {
-    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
     db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
     userSession.addProjectPermission(UserRole.USER, project);