]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9140 support public flag in ComponentTesting/ComponentDbTester
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 19 Apr 2017 09:23:38 +0000 (11:23 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 27 Apr 2017 12:25:54 +0000 (14:25 +0200)
177 files changed:
server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDbTester.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentTesting.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDbTester.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/user/RoleDaoTest.java
server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java
server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentDtoToWsComponentTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/SettingsRepositoryTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/EnableAnalysisStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportComputeMeasureVariationsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ValidateProjectStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsPersistAnalysisStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/FavoriteUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ActionFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/AssignActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/SetSeverityActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/SetTypeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/TransitionActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/TransitionServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java
server/sonar-server/src/test/java/org/sonar/server/notification/ws/AddActionTest.java
server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java
server/sonar-server/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/EnableSupportActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/IndexActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteEventActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/EventValidatorTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
server/sonar-server/src/test/java/org/sonar/server/property/ws/IndexActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/QgateProjectFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGateFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/DeselectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchDataLoaderTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/ResetActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/SetActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/SettingsFinderTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java
server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java
server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java
server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/startup/DisplayLogOnDeprecatedProjectsTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java

index 7162d2967a92c1e228c9ef1e90defb8fde6bdda4..dfc955308bc4cca9de4213ccdcfc858a0a437b49 100644 (file)
@@ -713,7 +713,7 @@ public class InternalCeQueueImplTest {
   }
 
   private ComponentDto newComponentDto(String uuid) {
-    return ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setKey("key_" + uuid);
+    return ComponentTesting.newPublicProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setKey("key_" + uuid);
   }
 
   private CeTask submit(String reportType, String componentUuid) {
index 793ea5442bc37492d6d2e59a3c10b0df99cbc3f2..72e3356998669e27471e47538d818fa98e8b7936 100644 (file)
@@ -54,7 +54,7 @@ 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.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN;
@@ -534,11 +534,11 @@ public class ComponentDaoTest {
   @Test
   public void select_projects() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto provisionedProject = db.components().insertProject();
+    ComponentDto provisionedProject = db.components().insertPrivateProject();
     ComponentDto provisionedView = db.components().insertView(organization, (dto) -> {
     });
-    String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid();
-    String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid();
+    String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid();
+    String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid();
     String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid();
 
     assertThat(underTest.selectProjects(dbSession))
@@ -549,10 +549,10 @@ public class ComponentDaoTest {
   @Test
   public void select_provisioned() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto provisionedProject = db.components().insertComponent(newProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project"));
+    ComponentDto provisionedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project"));
     ComponentDto provisionedView = db.components().insertView(organization);
-    String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid();
-    String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid();
+    String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid();
+    String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid();
     String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid();
 
     Set<String> projectQualifiers = newHashSet(Qualifiers.PROJECT);
@@ -595,8 +595,8 @@ public class ComponentDaoTest {
   @Test
   public void count_provisioned() {
     OrganizationDto organization = db.organizations().insert();
-    db.components().insertProject(organization);
-    db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization));
+    db.components().insertPrivateProject(organization);
+    db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization));
     db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization));
 
     assertThat(underTest.countProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.PROJECT))).isEqualTo(1);
@@ -609,25 +609,25 @@ public class ComponentDaoTest {
     OrganizationDto organization = db.organizations().insert();
 
     // ghosts because has at least one snapshot with status U but none with status P
-    ComponentDto ghostProject = db.components().insertProject(organization);
+    ComponentDto ghostProject = db.components().insertPrivateProject(organization);
     db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U"));
     db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U"));
-    ComponentDto ghostProject2 = db.components().insertProject(organization);
+    ComponentDto ghostProject2 = db.components().insertPrivateProject(organization);
     db.components().insertSnapshot(ghostProject2, dto -> dto.setStatus("U"));
-    ComponentDto disabledGhostProject = db.components().insertProject(dto -> dto.setEnabled(false));
+    ComponentDto disabledGhostProject = db.components().insertPrivateProject(dto -> dto.setEnabled(false));
     db.components().insertSnapshot(disabledGhostProject, dto -> dto.setStatus("U"));
 
-    ComponentDto project1 = db.components().insertProject(organization);
+    ComponentDto project1 = db.components().insertPrivateProject(organization);
     db.components().insertSnapshot(project1, dto -> dto.setStatus("P"));
     db.components().insertSnapshot(project1, dto -> dto.setStatus("U"));
     ComponentDto module = db.components().insertComponent(newModuleDto(project1));
     ComponentDto dir = db.components().insertComponent(newDirectory(module, "foo"));
     db.components().insertComponent(newFileDto(module, dir, "bar"));
 
-    ComponentDto provisionedProject = db.components().insertProject(organization);
+    ComponentDto provisionedProject = db.components().insertPrivateProject(organization);
 
     // not a ghost because has at least one snapshot with status P
-    ComponentDto project2 = db.components().insertProject(organization);
+    ComponentDto project2 = db.components().insertPrivateProject(organization);
     db.components().insertSnapshot(project2, dto -> dto.setStatus("P"));
 
     // not a ghost because it's not a project
@@ -748,7 +748,7 @@ public class ComponentDaoTest {
 
   @Test
   public void update() {
-    db.components().insertProject(db.getDefaultOrganization(), "U1");
+    db.components().insertPrivateProject(db.getDefaultOrganization(), "U1");
 
     underTest.update(dbSession, new ComponentUpdateDto()
       .setUuid("U1")
@@ -783,9 +783,9 @@ public class ComponentDaoTest {
 
   @Test
   public void updateBEnabledToFalse() {
-    ComponentDto dto1 = newProjectDto(db.getDefaultOrganization(), "U1");
-    ComponentDto dto2 = newProjectDto(db.getDefaultOrganization(), "U2");
-    ComponentDto dto3 = newProjectDto(db.getDefaultOrganization(), "U3");
+    ComponentDto dto1 = newPrivateProjectDto(db.getDefaultOrganization(), "U1");
+    ComponentDto dto2 = newPrivateProjectDto(db.getDefaultOrganization(), "U2");
+    ComponentDto dto3 = newPrivateProjectDto(db.getDefaultOrganization(), "U3");
     underTest.insert(dbSession, dto1, dto2, dto3);
 
     underTest.updateBEnabledToFalse(dbSession, asList("U1", "U2"));
@@ -834,7 +834,7 @@ public class ComponentDaoTest {
 
   @Test
   public void update_tags() {
-    ComponentDto project = db.components().insertProject(p -> p.setTags(emptyList()));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setTags(emptyList()));
 
     underTest.updateTags(dbSession, project.setTags(newArrayList("finance", "toto", "tutu")));
     dbSession.commit();
@@ -844,8 +844,8 @@ public class ComponentDaoTest {
 
   @Test
   public void delete() throws Exception {
-    ComponentDto project1 = db.components().insertProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_1"));
-    db.components().insertProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_2"));
+    ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_1"));
+    db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_2"));
 
     underTest.delete(dbSession, project1.getId());
     dbSession.commit();
@@ -873,10 +873,10 @@ public class ComponentDaoTest {
   @Test
   public void selectByQuery_with_paging_query_and_qualifiers() {
     OrganizationDto organizationDto = db.organizations().insert();
-    db.components().insertProjectAndSnapshot(newProjectDto(organizationDto).setName("aaaa-name"));
+    db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setName("aaaa-name"));
     db.components().insertProjectAndSnapshot(newView(organizationDto));
     for (int i = 9; i >= 1; i--) {
-      db.components().insertProjectAndSnapshot(newProjectDto(organizationDto).setName("project-" + i));
+      db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project-" + i));
     }
 
     ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("oJect").setQualifiers(Qualifiers.PROJECT).build();
@@ -893,8 +893,8 @@ public class ComponentDaoTest {
   public void selectByQuery_with_organization_filters_on_specified_organization() {
     OrganizationDto organization1 = db.organizations().insert();
     OrganizationDto organization2 = db.organizations().insert();
-    ComponentDto project1 = db.components().insertProject(organization1);
-    ComponentDto project2 = db.components().insertProject(organization2);
+    ComponentDto project1 = db.components().insertPrivateProject(organization1);
+    ComponentDto project2 = db.components().insertPrivateProject(organization2);
 
     assertThat(underTest.selectByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY, 0, 2))
       .extracting(ComponentDto::uuid)
@@ -913,8 +913,8 @@ public class ComponentDaoTest {
   public void countByQuery_with_organization_filters_on_specified_organization() {
     OrganizationDto organization1 = db.organizations().insert();
     OrganizationDto organization2 = db.organizations().insert();
-    ComponentDto project1 = db.components().insertProject(organization1);
-    ComponentDto project2 = db.components().insertProject(organization2);
+    ComponentDto project1 = db.components().insertPrivateProject(organization1);
+    ComponentDto project2 = db.components().insertPrivateProject(organization2);
 
     assertThat(underTest.countByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY))
       .isEqualTo(2);
@@ -928,7 +928,7 @@ public class ComponentDaoTest {
 
   @Test
   public void selectByQuery_name_with_special_characters() {
-    db.components().insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization()).setName("project-\\_%/-name"));
+    db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("project-\\_%/-name"));
 
     ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("-\\_%/-").setQualifiers(Qualifiers.PROJECT).build();
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
@@ -939,7 +939,7 @@ public class ComponentDaoTest {
 
   @Test
   public void selectByQuery_key_with_special_characters() {
-    db.components().insertProjectAndSnapshot(newProjectDto(db.organizations().insert()).setKey("project-_%-key"));
+    db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("project-_%-key"));
 
     ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("project-_%-key").setQualifiers(Qualifiers.PROJECT).build();
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
@@ -950,8 +950,8 @@ public class ComponentDaoTest {
 
   @Test
   public void selectByQuery_filter_on_language() {
-    db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("java-project-key").setLanguage("java"));
-    db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("cpp-project-key").setLanguage("cpp"));
+    db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("java-project-key").setLanguage("java"));
+    db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("cpp-project-key").setLanguage("cpp"));
 
     ComponentQuery query = ComponentQuery.builder().setLanguage("java").setQualifiers(Qualifiers.PROJECT).build();
     List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
@@ -973,9 +973,9 @@ public class ComponentDaoTest {
   @Test
   public void selectByQuery_on_component_ids() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto sonarqube = db.components().insertComponent(newProjectDto(organizationDto));
-    ComponentDto jdk8 = db.components().insertComponent(newProjectDto(organizationDto));
-    ComponentDto cLang = db.components().insertComponent(newProjectDto(organizationDto));
+    ComponentDto sonarqube = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
+    ComponentDto jdk8 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
+    ComponentDto cLang = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     ComponentQuery query = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT)
       .setComponentIds(newHashSet(sonarqube.getId(), jdk8.getId())).build();
@@ -991,7 +991,7 @@ public class ComponentDaoTest {
     // organization
     OrganizationDto organization = db.organizations().insert();
     // project -> module -> file
-    ComponentDto project = newProjectDto(organization, PROJECT_UUID);
+    ComponentDto project = newPrivateProjectDto(organization, PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto(MODULE_UUID, project);
     db.components().insertComponent(module);
@@ -1015,7 +1015,7 @@ public class ComponentDaoTest {
   @Test
   public void select_descendants_with_children_stragegy() {
     // project has 2 children: module and file 1. Other files are part of module.
-    ComponentDto project = newProjectDto(db.organizations().insert(), PROJECT_UUID);
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto(MODULE_UUID, project);
     db.components().insertComponent(module);
@@ -1080,7 +1080,7 @@ public class ComponentDaoTest {
 
   @Test
   public void select_descendants_with_leaves_strategy() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
     db.components().insertProjectAndSnapshot(project);
     db.components().insertComponent(newModuleDto("module-1-uuid", project));
     db.components().insertComponent(newFileDto(project, null, "file-1-uuid"));
@@ -1110,7 +1110,7 @@ public class ComponentDaoTest {
     ComponentDto subView = newSubView(view, "subview-uuid", "subview-key").setName("subview name");
     db.components().insertComponent(subView);
     // one project and its copy linked to the view
-    ComponentDto project = newProjectDto(organizationDto, PROJECT_UUID).setName("project name");
+    ComponentDto project = newPrivateProjectDto(organizationDto, PROJECT_UUID).setName("project name");
     db.components().insertProjectAndSnapshot(project);
     db.components().insertComponent(newProjectCopy("project-copy-uuid", project, view));
     ComponentTreeQuery dbQuery = newTreeQuery(A_VIEW_UUID).setNameOrKeyQuery("name").setStrategy(CHILDREN).build();
@@ -1123,12 +1123,12 @@ public class ComponentDaoTest {
   @Test
   public void select_projects_by_name_query() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project1 = db.components().insertComponent(newProjectDto(organizationDto).setName("project1"));
+    ComponentDto project1 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project1"));
     ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setName("module1"));
     ComponentDto subModule1 = db.components().insertComponent(newModuleDto(module1).setName("subModule1"));
     db.components().insertComponent(newFileDto(subModule1).setName("file"));
-    ComponentDto project2 = db.components().insertComponent(newProjectDto(organizationDto).setName("project2"));
-    ComponentDto project3 = db.components().insertComponent(newProjectDto(organizationDto).setName("project3"));
+    ComponentDto project2 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project2"));
+    ComponentDto project3 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project3"));
 
     assertThat(underTest.selectProjectsByNameQuery(dbSession, null, false)).extracting(ComponentDto::uuid)
       .containsOnly(project1.uuid(), project2.uuid(), project3.uuid());
@@ -1149,11 +1149,11 @@ public class ComponentDaoTest {
 
     OrganizationDto organizationDto = db.organizations().insert();
     String[] uuids = {
-      db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(true)).uuid(),
-      db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(false)).uuid(),
-      db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(true)).uuid(),
-      db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(false)).uuid(),
-      db.components().insertComponent(newProjectDto(organizationDto).setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(),
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(true)).uuid(),
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(false)).uuid(),
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(true)).uuid(),
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(false)).uuid(),
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(),
     };
 
     underTest.setPrivateForRootComponentUuid(db.getSession(), uuid1, true);
index cfe41abee065cf75c9e169284bde3916b5e7e9fb..6a0f6ba0920dfbef39a97b10740caa66f186801f 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 /**
  * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique,
@@ -50,10 +49,10 @@ public class ComponentDaoWithDuplicatedKeysTest {
   @Test
   public void select_components_having_same_key() {
     OrganizationDto organizationDto = db.organizations().insert();
-    insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY));
-    insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY));
-    insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY));
-    insertProject(newProjectDto(organizationDto).setKey("ANOTHER_PROJECT_KEY"));
+    insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
+    insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
+    insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
+    insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("ANOTHER_PROJECT_KEY"));
 
     assertThat(underTest.selectComponentsHavingSameKeyOrderedById(db.getSession(), PROJECT_KEY)).hasSize(3);
   }
index c0f8870fb822cd19f547ca71391d45c391130507..cf985e46b03916c42e3e43317ffd468d3a16a43f 100644 (file)
@@ -21,13 +21,16 @@ package org.sonar.db.component;
 
 import java.util.Arrays;
 import java.util.function.Consumer;
+import javax.annotation.Nullable;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 
+import static com.google.common.base.Preconditions.checkState;
 import static java.util.Arrays.asList;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPublicProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 
@@ -59,53 +62,75 @@ public class ComponentDbTester {
   }
 
   public ComponentDto insertComponent(ComponentDto component) {
-    return insertComponentImpl(component, noExtraConfiguration());
+    return insertComponentImpl(component, null, noExtraConfiguration());
   }
 
-  public ComponentDto insertProject() {
-    return insertComponentImpl(newProjectDto(db.getDefaultOrganization()), noExtraConfiguration());
+  public ComponentDto insertPrivateProject() {
+    return insertComponentImpl(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()), true, noExtraConfiguration());
+  }
+
+  public ComponentDto insertPublicProject() {
+    return insertComponentImpl(ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()), false, noExtraConfiguration());
+  }
+
+  @SafeVarargs
+  public final ComponentDto insertPrivateProject(Consumer<ComponentDto>... dtoPopulators) {
+    return insertComponentImpl(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()), true, dtoPopulators);
+  }
+
+  @SafeVarargs
+  public final ComponentDto insertPublicProject(Consumer<ComponentDto>... dtoPopulators) {
+    return insertComponentImpl(newPublicProjectDto(db.getDefaultOrganization()), false, dtoPopulators);
   }
 
   @SafeVarargs
-  public final ComponentDto insertProject(Consumer<ComponentDto>... dtoPopulators) {
-    return insertComponentImpl(newProjectDto(db.getDefaultOrganization()), dtoPopulators);
+  public final ComponentDto insertPrivateProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) {
+    return insertComponentImpl(ComponentTesting.newPrivateProjectDto(organizationDto), true, dtoPopulators);
   }
 
   @SafeVarargs
-  public final ComponentDto insertProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) {
-    return insertComponentImpl(newProjectDto(organizationDto), dtoPopulators);
+  public final ComponentDto insertPublicProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) {
+    return insertComponentImpl(newPublicProjectDto(organizationDto), true, dtoPopulators);
+  }
+
+  public ComponentDto insertPrivateProject(OrganizationDto organizationDto) {
+    return insertComponentImpl(ComponentTesting.newPrivateProjectDto(organizationDto), true, noExtraConfiguration());
+  }
+
+  public ComponentDto insertPublicProject(OrganizationDto organizationDto) {
+    return insertComponentImpl(newPublicProjectDto(organizationDto), false, noExtraConfiguration());
   }
 
-  public ComponentDto insertProject(OrganizationDto organizationDto) {
-    return insertComponentImpl(newProjectDto(organizationDto), noExtraConfiguration());
+  public ComponentDto insertPrivateProject(OrganizationDto organizationDto, String uuid) {
+    return insertComponentImpl(newPrivateProjectDto(organizationDto, uuid), true, noExtraConfiguration());
   }
 
-  public ComponentDto insertProject(OrganizationDto organizationDto, String uuid) {
-    return insertComponentImpl(newProjectDto(organizationDto, uuid), noExtraConfiguration());
+  public ComponentDto insertPublicProject(OrganizationDto organizationDto, String uuid) {
+    return insertComponentImpl(newPublicProjectDto(organizationDto, uuid), false, noExtraConfiguration());
   }
 
   public ComponentDto insertView() {
-    return insertComponentImpl(newView(db.getDefaultOrganization()), noExtraConfiguration());
+    return insertComponentImpl(newView(db.getDefaultOrganization()), false, noExtraConfiguration());
   }
 
   public ComponentDto insertView(Consumer<ComponentDto> dtoPopulator) {
-    return insertComponentImpl(newView(db.getDefaultOrganization()), dtoPopulator);
+    return insertComponentImpl(newView(db.getDefaultOrganization()), false, dtoPopulator);
   }
 
   public ComponentDto insertView(OrganizationDto organizationDto) {
-    return insertComponentImpl(newView(organizationDto), noExtraConfiguration());
+    return insertComponentImpl(newView(organizationDto), false, noExtraConfiguration());
   }
 
   public ComponentDto insertView(OrganizationDto organizationDto, Consumer<ComponentDto> dtoPopulator) {
-    return insertComponentImpl(newView(organizationDto), dtoPopulator);
+    return insertComponentImpl(newView(organizationDto), false, dtoPopulator);
   }
 
   public ComponentDto insertView(String uuid) {
-    return insertComponentImpl(newView(db.getDefaultOrganization(), uuid), noExtraConfiguration());
+    return insertComponentImpl(newView(db.getDefaultOrganization(), uuid), false, noExtraConfiguration());
   }
 
   public ComponentDto insertView(OrganizationDto organizationDto, String uuid) {
-    return insertComponentImpl(newView(organizationDto, uuid), noExtraConfiguration());
+    return insertComponentImpl(newView(organizationDto, uuid), false, noExtraConfiguration());
   }
 
   private static <T> Consumer<T> noExtraConfiguration() {
@@ -114,9 +139,10 @@ public class ComponentDbTester {
   }
 
   @SafeVarargs
-  private final ComponentDto insertComponentImpl(ComponentDto component, Consumer<ComponentDto>... dtoPopulators) {
+  private final ComponentDto insertComponentImpl(ComponentDto component, @Nullable Boolean isPrivate, Consumer<ComponentDto>... dtoPopulators) {
     Arrays.stream(dtoPopulators)
       .forEach(dtoPopulator -> dtoPopulator.accept(component));
+    checkState(isPrivate == null || component.isPrivate() == isPrivate, "Illegal modification of private flag");
     dbClient.componentDao().insert(dbSession, component);
     db.commit();
 
index 0e21d5d86a8cfff542ec4700c1f84dd9e0fb91c0..8c70e78e17f15881417f4f5c98ee77b196a94384 100644 (file)
@@ -94,7 +94,7 @@ public class ComponentDtoTest {
 
   @Test
   public void test_formatUuidPathFromParent() {
-    ComponentDto parent = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "123").setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
+    ComponentDto parent = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "123").setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
     assertThat(ComponentDto.formatUuidPathFromParent(parent)).isEqualTo(".123.");
   }
 
index af97818229bfd3e948e49d0787b72c75307e4b44..8dd4bbcadce26bd72e0cd2169b4eb1ce582aaf29 100644 (file)
@@ -38,7 +38,7 @@ import static org.sonar.db.component.ComponentKeyUpdaterDao.computeNewKey;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 public class ComponentKeyUpdaterDaoTest {
 
@@ -63,7 +63,7 @@ public class ComponentKeyUpdaterDaoTest {
   @Test
   public void updateKey_does_not_updated_inactive_components() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "A").setKey("my_project"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setKey("my_project"));
     ComponentDto directory = db.components().insertComponent(newDirectory(project, "/directory").setKey("my_project:directory"));
     db.components().insertComponent(newFileDto(project, directory).setKey("my_project:directory/file"));
     ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setKey("my_project:inactive_directory").setEnabled(false));
@@ -89,7 +89,7 @@ public class ComponentKeyUpdaterDaoTest {
 
   @Test
   public void bulk_update_key_does_not_update_inactive_components() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "A").setKey("my_project"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setKey("my_project"));
     db.components().insertComponent(newModuleDto(project).setKey("my_project:module"));
     db.components().insertComponent(newModuleDto(project).setKey("my_project:inactive_module").setEnabled(false));
 
@@ -144,7 +144,7 @@ public class ComponentKeyUpdaterDaoTest {
   @Test
   public void updateKey_throws_IAE_when_sub_component_key_is_too_long() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = newProjectDto(organizationDto, "project-uuid").setKey("old-project-key");
+    ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setKey("old-project-key");
     db.components().insertComponent(project);
     db.components().insertComponent(newFileDto(project, null).setKey("old-project-key:file"));
     String newLongProjectKey = Strings.repeat("a", 400);
@@ -156,7 +156,7 @@ public class ComponentKeyUpdaterDaoTest {
 
   @Test
   public void fail_when_new_key_is_invalid() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     thrown.expect(IllegalArgumentException.class);
     thrown.expectMessage("Malformed key for 'my?project?key'. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.");
@@ -178,8 +178,8 @@ public class ComponentKeyUpdaterDaoTest {
   @Test
   public void check_component_keys_checks_inactive_components() {
     OrganizationDto organizationDto = db.organizations().insert();
-    db.components().insertComponent(newProjectDto(organizationDto).setKey("my-project"));
-    db.components().insertComponent(newProjectDto(organizationDto).setKey("your-project").setEnabled(false));
+    db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("my-project"));
+    db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("your-project").setEnabled(false));
 
     Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("my-project", "your-project", "new-project"));
 
@@ -201,7 +201,7 @@ public class ComponentKeyUpdaterDaoTest {
 
   @Test
   public void simulate_bulk_update_key_do_not_return_disable_components() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "A").setKey("project"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setKey("project"));
     db.components().insertComponent(newModuleDto(project).setKey("project:enabled-module"));
     db.components().insertComponent(newModuleDto(project).setKey("project:disabled-module").setEnabled(false));
 
@@ -215,7 +215,7 @@ public class ComponentKeyUpdaterDaoTest {
   @Test
   public void simulate_bulk_update_key_fails_if_invalid_componentKey() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "A").setKey("project"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setKey("project"));
     db.components().insertComponent(newModuleDto(project).setKey("project:enabled-module"));
     db.components().insertComponent(newModuleDto(project).setKey("project:disabled-module").setEnabled(false));
 
index f053971523954ddc1c1fb3a8dea93e923f3b4541..dc8a2130845a8634a1106f8f2194d38a0ee1ff53 100644 (file)
@@ -26,6 +26,7 @@ import org.sonar.api.resources.Scopes;
 import org.sonar.core.util.Uuids;
 import org.sonar.db.organization.OrganizationDto;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
 
@@ -96,15 +97,23 @@ public class ComponentTesting {
     return newModuleDto(Uuids.createFast(), subProjectOrProject);
   }
 
-  public static ComponentDto newProjectDto(OrganizationDto organizationDto) {
-    return newProjectDto(organizationDto.getUuid(), Uuids.createFast());
+  public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto) {
+    return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), true);
   }
 
-  public static ComponentDto newProjectDto(OrganizationDto organizationDto, String uuid) {
-    return newProjectDto(organizationDto.getUuid(), uuid);
+  public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto, String uuid) {
+    return newProjectDto(organizationDto.getUuid(), uuid, true);
   }
 
-  private static ComponentDto newProjectDto(String organizationUuid, String uuid) {
+  public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto) {
+    return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), false);
+  }
+
+  public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto, String uuid) {
+    return newProjectDto(organizationDto.getUuid(), uuid, false);
+  }
+
+  private static ComponentDto newProjectDto(String organizationUuid, String uuid, boolean isPrivate) {
     return new ComponentDto()
       .setOrganizationUuid(organizationUuid)
       .setUuid(uuid)
@@ -120,7 +129,8 @@ public class ComponentTesting {
       .setQualifier(Qualifiers.PROJECT)
       .setPath(null)
       .setLanguage(null)
-      .setEnabled(true);
+      .setEnabled(true)
+        .setPrivate(isPrivate);
   }
 
   public static ComponentDto newView(OrganizationDto organizationDto) {
@@ -128,17 +138,18 @@ public class ComponentTesting {
   }
 
   public static ComponentDto newView(OrganizationDto organizationDto, String uuid) {
-    return newProjectDto(organizationDto, uuid)
+    return newPrivateProjectDto(organizationDto, uuid)
       .setUuid(uuid)
       .setScope(Scopes.PROJECT)
-      .setQualifier(Qualifiers.VIEW);
+      .setQualifier(Qualifiers.VIEW)
+      .setPrivate(false);
   }
 
   private static ComponentDto newView(String organizationUuid, String uuid) {
-    return newProjectDto(organizationUuid, uuid)
-        .setUuid(uuid)
-        .setScope(Scopes.PROJECT)
-        .setQualifier(Qualifiers.VIEW);
+    return newProjectDto(organizationUuid, uuid, false)
+      .setUuid(uuid)
+      .setScope(Scopes.PROJECT)
+      .setQualifier(Qualifiers.VIEW);
   }
 
   public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) {
@@ -156,6 +167,9 @@ public class ComponentTesting {
   }
 
   public static ComponentDto newChildComponent(String uuid, ComponentDto moduleOrProject, ComponentDto parent) {
+    checkArgument(moduleOrProject.isPrivate() == parent.isPrivate(),
+      "private flag inconsistent between moduleOrProject (%s) and parent (%s)",
+      moduleOrProject.isPrivate(), parent.isPrivate());
     return new ComponentDto()
       .setOrganizationUuid(parent.getOrganizationUuid())
       .setUuid(uuid)
@@ -165,6 +179,7 @@ public class ComponentTesting {
       .setModuleUuid(moduleOrProject.uuid())
       .setModuleUuidPath(moduleOrProject.moduleUuidPath())
       .setCreatedAt(new Date())
-      .setEnabled(true);
+      .setEnabled(true)
+      .setPrivate(moduleOrProject.isPrivate());
   }
 }
index a60a8a685593adb679d5ee74686d33e35b5c2508..c3e9e10660da489b42ba3b1db01a5aaef9713bf3 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN;
 import static org.sonar.db.component.ComponentTreeQuery.Strategy.LEAVES;
 import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
@@ -70,10 +70,10 @@ public class ComponentTreeQueryTest {
   @Test
   public void test_getUuidPath() throws Exception {
     assertThat(ComponentTreeQuery.builder().setBaseUuid(BASE_UUID).setStrategy(CHILDREN)
-      .build().getUuidPath(newProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");
+      .build().getUuidPath(newPrivateProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");
 
     assertThat(ComponentTreeQuery.builder().setBaseUuid(BASE_UUID).setStrategy(LEAVES)
-      .build().getUuidPath(newProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%");
+      .build().getUuidPath(newPrivateProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%");
   }
 
   @Test
index d0d50ce382d8c5e0770051680a08d4ff4180474b..f026bbbf4e9031758158477afbdd2379f7645077 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.db.organization.OrganizationTesting;
 import static com.google.common.collect.Lists.newArrayList;
 import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED;
 import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED;
 import static org.sonar.db.component.SnapshotQuery.SORT_FIELD.BY_DATE;
@@ -57,7 +57,7 @@ public class SnapshotDaoTest {
 
   @Test
   public void test_selectByUuid() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project)
       .setUuid("ABCD")
       .setStatus("P")
@@ -122,12 +122,12 @@ public class SnapshotDaoTest {
 
   @Test
   public void selectLastSnapshotsByRootComponentUuids_returns_snapshots_flagged_as_last() {
-    ComponentDto firstProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_1"));
+    ComponentDto firstProject = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_1"));
     dbClient.snapshotDao().insert(dbSession, newAnalysis(firstProject).setLast(false));
     SnapshotDto lastSnapshotOfFirstProject = dbClient.snapshotDao().insert(dbSession, newAnalysis(firstProject).setLast(true));
-    ComponentDto secondProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_2"));
+    ComponentDto secondProject = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_2"));
     SnapshotDto lastSnapshotOfSecondProject = dbClient.snapshotDao().insert(dbSession, newAnalysis(secondProject).setLast(true));
-    db.components().insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization()));
+    db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
 
     List<SnapshotDto> result = underTest.selectLastAnalysesByRootComponentUuids(dbSession, newArrayList(firstProject.uuid(), secondProject.uuid()));
 
@@ -182,7 +182,7 @@ public class SnapshotDaoTest {
 
   @Test
   public void select_first_snapshots() throws Exception {
-    ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     db.getDbClient().componentDao().insert(dbSession, project);
 
     db.getDbClient().snapshotDao().insert(dbSession,
@@ -200,7 +200,7 @@ public class SnapshotDaoTest {
 
   @Test
   public void insert() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     SnapshotDto dto = underTest.insert(db.getSession(), newAnalysis(project)
       .setStatus("P")
@@ -229,7 +229,7 @@ public class SnapshotDaoTest {
 
   @Test
   public void insert_snapshots() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     underTest.insert(db.getSession(),
       newAnalysis(project).setLast(false).setUuid("u5"),
@@ -307,7 +307,7 @@ public class SnapshotDaoTest {
   }
 
   private SnapshotDto insertAnalysis(String projectUuid, String uuid, String status, boolean isLastFlag) {
-    SnapshotDto snapshot = newAnalysis(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid))
+    SnapshotDto snapshot = newAnalysis(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid))
       .setLast(isLastFlag)
       .setStatus(status)
       .setUuid(uuid);
index ade29186355720ae8c90d7fd6cd9b6253d66dfcc..073298547a9b221e736903a0e866d9a5481d1b00 100644 (file)
@@ -29,11 +29,11 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 
 import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.event.EventTesting.newEvent;
 
@@ -51,7 +51,7 @@ public class EventDaoTest {
 
   @Test
   public void select_by_uuid() {
-    SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.organizations().insert()));
+    SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     dbTester.events().insertEvent(newEvent(analysis).setUuid("A1"));
     dbTester.events().insertEvent(newEvent(analysis).setUuid("A2"));
     dbTester.events().insertEvent(newEvent(analysis).setUuid("A3"));
@@ -87,7 +87,7 @@ public class EventDaoTest {
 
   @Test
   public void select_by_analysis_uuid() {
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     SnapshotDto otherAnalysis = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
     dbTester.commit();
@@ -106,7 +106,7 @@ public class EventDaoTest {
 
   @Test
   public void select_by_analysis_uuids() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     SnapshotDto a1 = dbTester.components().insertSnapshot(newAnalysis(project));
     SnapshotDto a2 = dbTester.components().insertSnapshot(newAnalysis(project));
     SnapshotDto a42 = dbTester.components().insertSnapshot(newAnalysis(project));
@@ -156,7 +156,7 @@ public class EventDaoTest {
 
   @Test
   public void update_name_and_description() {
-    SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.organizations().insert()));
+    SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     dbTester.events().insertEvent(newEvent(analysis).setUuid("E1"));
 
     underTest.update(dbSession, "E1", "New Name", "New Description");
@@ -178,7 +178,7 @@ public class EventDaoTest {
 
   @Test
   public void delete_by_uuid() {
-    dbTester.events().insertEvent(newEvent(newAnalysis(newProjectDto(dbTester.getDefaultOrganization()))).setUuid("E1"));
+    dbTester.events().insertEvent(newEvent(newAnalysis(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()))).setUuid("E1"));
 
     underTest.delete(dbTester.getSession(), "E1");
     dbTester.commit();
index 75b5864f6597b472014a11a395063105fb351a81..03c8a6317aedd5c1c5083f3fa6db9d71168aba5e 100644 (file)
@@ -151,7 +151,7 @@ public class IssueDaoTest {
   private void prepareTables() {
     dbTester.rules().insertRule(RULE);
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto projectDto = dbTester.components().insertProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto projectDto = dbTester.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
     dbTester.components().insertComponent(ComponentTesting.newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
     underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY1)
       .setMessage("the message")
index 0b1d5ee0970b7cff284f750bde28900a1fa85cd9..0c090b4787196a4315f4f462f86f5fa0498780f4 100644 (file)
@@ -73,7 +73,7 @@ public class IssueDbTester {
 
   public IssueDto insertIssue(OrganizationDto organizationDto, Consumer<IssueDto> populateIssueDto) {
     RuleDefinitionDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertProject(organizationDto);
+    ComponentDto project = db.components().insertPrivateProject(organizationDto);
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     IssueDto issueDto = newIssue(rule, file, project);
     populateIssueDto.accept(issueDto);
index 47871824987bd93ff045a3973d7de21f020641f2..3fabfe1f864c3bc5f8702fab7e40d96cb8f0075b 100644 (file)
@@ -48,7 +48,7 @@ public class IssueMapperTest {
   @Before
   public void setUp() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    project = ComponentTesting.newProjectDto(organizationDto);
+    project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbTester.getDbClient().componentDao().insert(dbSession, project);
     file = ComponentTesting.newFileDto(project, null);
     dbTester.getDbClient().componentDao().insert(dbSession, file);
index 3e9d52aae2c3e98ff3ab18a4a387a046013f2a54..3e5bcfe2499f2e9daaccd0278024c1a8140f0958 100644 (file)
@@ -71,7 +71,7 @@ public class MeasureDaoTest {
 
   @Test
   public void test_inserted_and_selected_columns() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true);
     db.components().insertComponent(newFileDto(project).setUuid("C4"));
 
@@ -105,7 +105,7 @@ public class MeasureDaoTest {
 
   @Test
   public void selectByQuery() {
-    ComponentDto project1 = db.components().insertProject();
+    ComponentDto project1 = db.components().insertPrivateProject();
     ComponentDto module = db.components().insertComponent(newModuleDto(project1));
     db.components().insertComponent(newFileDto(module).setUuid("C1"));
     db.components().insertComponent(newFileDto(module).setUuid("C2"));
@@ -113,7 +113,7 @@ public class MeasureDaoTest {
     insertAnalysis(OTHER_ANALYSIS_UUID, project1.uuid(), false);
 
     String project2LastAnalysisUuid = "P2_LAST_ANALYSIS";
-    ComponentDto project2 = db.components().insertProject();
+    ComponentDto project2 = db.components().insertPrivateProject();
     insertAnalysis(project2LastAnalysisUuid, project2.uuid(), true);
 
     // project 1
@@ -200,7 +200,7 @@ public class MeasureDaoTest {
 
   @Test
   public void selectSingle() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertComponent(newFileDto(project).setUuid("C1"));
     insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true);
     insertMeasure("M1", LAST_ANALYSIS_UUID, "C1", NCLOC_METRIC_ID);
@@ -221,7 +221,7 @@ public class MeasureDaoTest {
 
   @Test
   public void select_tree_by_query() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto module1 = db.components().insertComponent(newModuleDto(project));
     ComponentDto module2 = db.components().insertComponent(newModuleDto(project));
     ComponentDto file1 = db.components().insertComponent(newFileDto(module1).setUuid("C1").setName("File One"));
@@ -272,7 +272,7 @@ public class MeasureDaoTest {
 
   @Test
   public void select_tree_by_query_use_only_latest_analysis() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file1 = db.components().insertComponent(newFileDto(project).setUuid("C1").setName("File One"));
     db.components().insertComponent(newFileDto(project).setUuid("C2").setName("File Two").setQualifier(UNIT_TEST_FILE));
     insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true);
@@ -305,7 +305,7 @@ public class MeasureDaoTest {
 
   @Test
   public void select_past_measures_with_several_analyses() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     long lastAnalysisDate = parseDate("2017-01-25").getTime();
     long previousAnalysisDate = lastAnalysisDate - 10_000_000_000L;
     long oldAnalysisDate = lastAnalysisDate - 100_000_000_000L;
@@ -329,7 +329,7 @@ public class MeasureDaoTest {
 
   @Test
   public void selectByComponentsAndMetrics() {
-    ComponentDto project1 = db.components().insertProject(db.getDefaultOrganization(), "P1");
+    ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), "P1");
     ComponentDto module = db.components().insertComponent(newModuleDto(project1));
     db.components().insertComponent(newFileDto(module).setUuid("C1"));
     db.components().insertComponent(newFileDto(module).setUuid("C2"));
@@ -337,7 +337,7 @@ public class MeasureDaoTest {
     insertAnalysis(OTHER_ANALYSIS_UUID, project1.uuid(), false);
 
     String project2LastAnalysisUuid = "P2_LAST_ANALYSIS";
-    ComponentDto project2 = db.components().insertProject(db.getDefaultOrganization(), "P2");
+    ComponentDto project2 = db.components().insertPrivateProject(db.getDefaultOrganization(), "P2");
     insertAnalysis(project2LastAnalysisUuid, project2.uuid(), true);
 
     // project 1
index 1c33f86531f21188bf1a5a6fc45990c2213047a8..925f0765c95c9afdc2ab013ef5ab06a2accf1919 100644 (file)
@@ -81,10 +81,10 @@ public class MeasureTreeQueryTest {
   @Test
   public void test_getUuidPath() throws Exception {
     assertThat(MeasureTreeQuery.builder().setStrategy(CHILDREN)
-      .build().getUuidPath(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");
+      .build().getUuidPath(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");
 
     assertThat(MeasureTreeQuery.builder().setStrategy(LEAVES)
-      .build().getUuidPath(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%");
+      .build().getUuidPath(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%");
   }
 
   @Test
index 5175730b11e250dfa55876fefa8e447cc87be36e..de2c5745456f3e25b633a5585669bb93798946ea 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures;
 import org.sonar.db.metric.MetricDto;
@@ -47,7 +48,7 @@ import static org.sonar.api.measures.Metric.ValueType.DISTRIB;
 import static org.sonar.api.measures.Metric.ValueType.INT;
 import static org.sonar.api.measures.Metric.ValueType.LEVEL;
 import static org.sonar.api.measures.Metric.ValueType.STRING;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 
@@ -65,7 +66,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   public void return_project_measure() {
     MetricDto metric1 = insertIntMetric("ncloc");
     MetricDto metric2 = insertIntMetric("coverage");
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java");
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasure(project, analysis, metric1, 10d);
     insertMeasure(project, analysis, metric2, 20d);
@@ -86,7 +87,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void return_project_measure_having_leak() throws Exception {
     MetricDto metric = insertIntMetric("new_lines");
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasureOnLeak(project, analysis, metric, 10d);
 
@@ -122,7 +123,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void return_language_distribution_measure() throws Exception {
     MetricDto metric = insertMetric("ncloc_language_distribution", DATA);
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasure(project, analysis, metric, "<null>=2;java=6;xoo=18");
 
@@ -136,7 +137,7 @@ public class ProjectMeasuresIndexerIteratorTest {
     MetricDto dataMetric = insertMetric("data", DATA);
     MetricDto distribMetric = insertMetric("distrib", DISTRIB);
     MetricDto stringMetric = insertMetric("string", STRING);
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasure(project, analysis, dataMetric, "dat");
     insertMeasure(project, analysis, distribMetric, "dis");
@@ -150,7 +151,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void does_not_return_disabled_metrics() throws Exception {
     MetricDto disabledMetric = insertMetric("disabled", false, false, INT);
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasure(project, analysis, disabledMetric, 10d);
 
@@ -162,7 +163,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void fail_when_measure_return_no_value() throws Exception {
     MetricDto metric = insertIntMetric("new_lines");
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
     insertMeasure(project, analysis, metric, 10d);
 
@@ -172,16 +173,16 @@ public class ProjectMeasuresIndexerIteratorTest {
 
   @Test
   public void return_many_project_measures() {
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()));
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()));
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
 
     assertThat(createResultSetAndReturnDocsById()).hasSize(3);
   }
 
   @Test
   public void return_project_without_analysis() throws Exception {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setLast(false));
     dbSession.commit();
 
@@ -195,9 +196,9 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void does_not_return_non_active_projects() throws Exception {
     // Disabled project
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
     // Disabled project with analysis
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setEnabled(false));
     dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
 
     // A view
@@ -211,10 +212,10 @@ public class ProjectMeasuresIndexerIteratorTest {
   @Test
   public void return_only_docs_from_given_project() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto));
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById(project.uuid());
 
@@ -229,7 +230,7 @@ public class ProjectMeasuresIndexerIteratorTest {
 
   @Test
   public void return_nothing_on_unknown_project() throws Exception {
-    dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()));
+    dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
 
     Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById("UNKNOWN");
 
@@ -271,7 +272,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   }
 
   private MeasureDto insertProjectAndMeasure(String projectUuid, MetricDto metric, String value) {
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), projectUuid);
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), projectUuid);
     SnapshotDto analysis1 = dbTester.components().insertProjectAndSnapshot(project);
     return insertMeasure(project, analysis1, metric, value);
   }
index 59f031b29dcf058c2849c836a11b13cb3ab99e0e..832cb34720a8f9e1c976cc7ad5c15226f0d8906a 100644 (file)
@@ -77,7 +77,7 @@ public class AuthorizationDaoTest {
    */
   @Test
   public void selectOrganizationPermissions_for_logged_in_user() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertMember(group1, user);
     db.users().insertPermissionOnUser(org, user, "perm1");
     db.users().insertProjectPermissionOnUser(user, "perm42", project);
@@ -451,7 +451,7 @@ public class AuthorizationDaoTest {
     db.users().insertPermissionOnUser(org3, user, QUALITY_GATE_ADMIN);
 
     // exclude project permission
-    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, db.components().insertProject());
+    db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, db.components().insertPrivateProject());
 
     Set<String> orgUuids = underTest.selectOrganizationUuidsOfUserWithGlobalPermission(dbSession, user.getId(), SCAN_EXECUTION);
 
@@ -470,10 +470,10 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
     db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.USER, project);
-    ComponentDto otherProject = db.components().insertProject();
+    ComponentDto otherProject = db.components().insertPrivateProject();
     db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, otherProject);
 
     assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, project.uuid())).containsOnly(UserRole.CODEVIEWER);
@@ -481,7 +481,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissionsOfAnonymous_returns_empty_set_when_project_does_not_exist() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
 
     assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, "does_not_exist")).isEmpty();
@@ -489,7 +489,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissions_returns_empty_set_when_logged_in_user_and_project_does_not_exist() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
 
     assertThat(underTest.selectProjectPermissions(dbSession, "does_not_exist", user.getId())).isEmpty();
@@ -497,7 +497,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_anonymous_permissions() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
     db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, project);
 
@@ -506,7 +506,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project);
     db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.ISSUE_ADMIN, project);
 
@@ -515,7 +515,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_group_membership() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnGroup(group1, UserRole.CODEVIEWER, project);
     db.users().insertProjectPermissionOnGroup(group2, UserRole.ISSUE_ADMIN, project);
     db.users().insertMember(group1, user);
@@ -525,7 +525,7 @@ public class AuthorizationDaoTest {
 
   @Test
   public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_all_possible_configurations() {
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project);
     db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, project);
     db.users().insertProjectPermissionOnGroup(group1, UserRole.USER, project);
index ca7ae772b8a30a747044355da2e74e17c0329843..ebf1282582c074fd4cb5088e6da85771c23bac06 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.GroupDto;
 
@@ -45,7 +46,6 @@ import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.OrganizationPermission.SCAN;
@@ -72,9 +72,9 @@ public class GroupPermissionDaoTest {
     GroupDto group1 = db.users().insertGroup();
     GroupDto group2 = db.users().insertGroup();
     GroupDto group3 = db.users().insertGroup();
-    ComponentDto project1 = db.components().insertProject();
-    ComponentDto project2 = db.components().insertProject();
-    ComponentDto project3 = db.components().insertProject();
+    ComponentDto project1 = db.components().insertPrivateProject();
+    ComponentDto project2 = db.components().insertPrivateProject();
+    ComponentDto project3 = db.components().insertPrivateProject();
 
     db.users().insertProjectPermissionOnGroup(group1, ISSUE_ADMIN, project1);
     db.users().insertProjectPermissionOnGroup(group1, ADMIN, project2);
@@ -135,7 +135,7 @@ public class GroupPermissionDaoTest {
     GroupDto group2 = db.users().insertGroup(organizationDto, "Group-2");
     GroupDto group3 = db.users().insertGroup(organizationDto, "Group-3");
 
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     db.users().insertPermissionOnAnyone(organizationDto, SCAN);
     db.users().insertPermissionOnAnyone(organizationDto, PROVISION_PROJECTS);
@@ -159,8 +159,8 @@ public class GroupPermissionDaoTest {
     GroupDto group2 = db.users().insertGroup();
     GroupDto group3 = db.users().insertGroup();
 
-    ComponentDto project = db.components().insertProject();
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
 
     db.users().insertProjectPermissionOnGroup(group1, SCAN_EXECUTION, project);
     db.users().insertProjectPermissionOnGroup(group1, PROVISIONING, project);
@@ -217,7 +217,7 @@ public class GroupPermissionDaoTest {
     db.users().insertPermissionOnGroup(group1, SCAN);
 
     GroupDto group2 = db.users().insertGroup(organizationDto, "Group-2");
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
     db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project);
 
     GroupDto group3 = db.users().insertGroup(organizationDto, "Group-3");
@@ -255,7 +255,7 @@ public class GroupPermissionDaoTest {
     db.users().insertPermissionOnGroup(group1, PROVISION_PROJECTS);
 
     GroupDto group2 = db.users().insertGroup(org, "Group-2");
-    ComponentDto project = db.components().insertComponent(newProjectDto(org));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(org));
     db.users().insertProjectPermissionOnGroup(group2, USER, project);
 
     GroupDto group3 = db.users().insertGroup(org, "Group-3");
@@ -291,7 +291,7 @@ public class GroupPermissionDaoTest {
     OrganizationDto org2 = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org1, "group1");
     GroupDto group2 = db.users().insertGroup(org2, "group2");
-    ComponentDto project = db.components().insertProject(org1);
+    ComponentDto project = db.components().insertPrivateProject(org1);
 
     db.users().insertPermissionOnAnyone(org1, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
@@ -313,8 +313,8 @@ public class GroupPermissionDaoTest {
   public void selectProjectPermissionsOfGroup() {
     OrganizationDto org1 = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org1, "group1");
-    ComponentDto project1 = db.components().insertProject(org1);
-    ComponentDto project2 = db.components().insertProject(org1);
+    ComponentDto project1 = db.components().insertPrivateProject(org1);
+    ComponentDto project2 = db.components().insertPrivateProject(org1);
 
     db.users().insertPermissionOnAnyone(org1, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
@@ -337,8 +337,8 @@ public class GroupPermissionDaoTest {
   public void selectAllPermissionsByGroupId() throws Exception {
     OrganizationDto org1 = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org1, "group1");
-    ComponentDto project1 = db.components().insertProject(org1);
-    ComponentDto project2 = db.components().insertProject(org1);
+    ComponentDto project1 = db.components().insertPrivateProject(org1);
+    ComponentDto project2 = db.components().insertPrivateProject(org1);
     db.users().insertPermissionOnAnyone(org1, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
     db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
@@ -358,8 +358,8 @@ public class GroupPermissionDaoTest {
     OrganizationDto org = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org);
     GroupDto group2 = db.users().insertGroup(org);
-    ComponentDto project1 = db.components().insertProject(org);
-    ComponentDto project2 = db.components().insertProject(org);
+    ComponentDto project1 = db.components().insertPrivateProject(org);
+    ComponentDto project2 = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnGroup(group1, "perm1");
     db.users().insertProjectPermissionOnGroup(group1, "perm2", project1);
     db.users().insertProjectPermissionOnAnyone("perm3", project1);
@@ -376,7 +376,7 @@ public class GroupPermissionDaoTest {
   public void delete_global_permission_from_group() {
     OrganizationDto org = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org);
-    ComponentDto project1 = db.components().insertProject(org);
+    ComponentDto project1 = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnAnyone(org, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
     db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
@@ -393,7 +393,7 @@ public class GroupPermissionDaoTest {
   public void delete_global_permission_from_anyone() {
     OrganizationDto org = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org);
-    ComponentDto project1 = db.components().insertProject(org);
+    ComponentDto project1 = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnAnyone(org, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
     db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
@@ -410,7 +410,7 @@ public class GroupPermissionDaoTest {
   public void delete_project_permission_from_group() {
     OrganizationDto org = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org);
-    ComponentDto project1 = db.components().insertProject(org);
+    ComponentDto project1 = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnAnyone(org, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
     db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
@@ -427,7 +427,7 @@ public class GroupPermissionDaoTest {
   public void delete_project_permission_from_anybody() {
     OrganizationDto org = db.organizations().insert();
     GroupDto group1 = db.users().insertGroup(org);
-    ComponentDto project1 = db.components().insertProject(org);
+    ComponentDto project1 = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnAnyone(org, "perm1");
     db.users().insertPermissionOnGroup(group1, "perm2");
     db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
index e46942a42c3026194dfeb0c079bc785c5758b242..e02068b90b45e61223a0bd1a971e24ba0c2f821a 100644 (file)
@@ -70,8 +70,8 @@ public class UserPermissionDaoTest {
     dbClient.userDao().insert(dbSession, user2);
     dbClient.userDao().insert(dbSession, user3);
     organizationDto = dbTester.organizations().insert();
-    project1 = dbTester.components().insertProject(organizationDto);
-    project2 = dbTester.components().insertProject(organizationDto);
+    project1 = dbTester.components().insertPrivateProject(organizationDto);
+    project2 = dbTester.components().insertPrivateProject(organizationDto);
     dbTester.organizations().addMember(organizationDto, user1);
     dbTester.organizations().addMember(organizationDto, user2);
     dbTester.organizations().addMember(organizationDto, user3);
@@ -236,8 +236,8 @@ public class UserPermissionDaoTest {
   public void selectUserIds() {
     OrganizationDto org1 = dbTester.organizations().insert();
     OrganizationDto org2 = dbTester.organizations().insert();
-    ComponentDto project1 = dbTester.components().insertProject(org1);
-    ComponentDto project2 = dbTester.components().insertProject(org2);
+    ComponentDto project1 = dbTester.components().insertPrivateProject(org1);
+    ComponentDto project2 = dbTester.components().insertPrivateProject(org2);
 
     addProjectPermission(org1, USER, user1, project1);
     addProjectPermission(org1, USER, user2, project1);
@@ -353,7 +353,7 @@ public class UserPermissionDaoTest {
   @Test
   public void selectProjectPermissionsOfUser() {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project3 = dbTester.components().insertProject(org);
+    ComponentDto project3 = dbTester.components().insertPrivateProject(org);
     addGlobalPermission(organizationDto, "perm1", user1);
     addProjectPermission(organizationDto, "perm2", user1, project1);
     addProjectPermission(organizationDto, "perm3", user1, project1);
@@ -414,7 +414,7 @@ public class UserPermissionDaoTest {
   public void delete_permissions_of_an_organization_member() {
     OrganizationDto organization1 = dbTester.organizations().insert();
     OrganizationDto organization2 = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization1);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization1);
     UserDto user1 = dbTester.users().insertUser();
     UserDto user2 = dbTester.users().insertUser();
     // user 1 permissions
@@ -442,7 +442,7 @@ public class UserPermissionDaoTest {
   public void deleteByUserId() {
     UserDto user1 = dbTester.users().insertUser();
     UserDto user2 = dbTester.users().insertUser();
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     dbTester.users().insertPermissionOnUser(user1, SCAN);
     dbTester.users().insertPermissionOnUser(user1, ADMINISTER);
     dbTester.users().insertProjectPermissionOnUser(user1, ADMINISTER_QUALITY_GATES.getKey(), project);
index 39e42e0c737fea7799272d571b76b2b855966466..9acec93fd8123f3f911dd18f5d2fce6d3501bea1 100644 (file)
@@ -338,7 +338,7 @@ public class PropertiesDaoTest {
   @UseDataProvider("allValuesForSelect")
   public void selectEnabledDescendantModuleProperties_supports_all_values(String dbValue, String expected) throws SQLException {
     String projectUuid = "A";
-    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid);
     dbClient.componentDao().insert(session, project);
     long projectId = project.getId();
     insertProperty("project.one", dbValue, projectId, null);
@@ -404,7 +404,7 @@ public class PropertiesDaoTest {
 
   @Test
   public void select_component_properties_by_keys() throws Exception {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     UserDto user = dbTester.users().insertUser();
 
     String key = "key";
@@ -425,8 +425,8 @@ public class PropertiesDaoTest {
 
   @Test
   public void select_component_properties_by_ids() throws Exception {
-    ComponentDto project = dbTester.components().insertProject();
-    ComponentDto project2 = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
+    ComponentDto project2 = dbTester.components().insertPrivateProject();
 
     UserDto user = UserTesting.newUserDto();
     dbClient.userDao().insert(session, user);
@@ -453,8 +453,8 @@ public class PropertiesDaoTest {
 
   @Test
   public void select_properties_by_keys_and_component_ids() throws Exception {
-    ComponentDto project = dbTester.components().insertProject();
-    ComponentDto project2 = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
+    ComponentDto project2 = dbTester.components().insertPrivateProject();
 
     UserDto user = UserTesting.newUserDto();
     dbClient.userDao().insert(session, user);
@@ -850,8 +850,8 @@ public class PropertiesDaoTest {
   public void delete_by_organization_and_user() throws SQLException {
     OrganizationDto organization = dbTester.organizations().insert();
     OrganizationDto anotherOrganization = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization);
-    ComponentDto anotherProject = dbTester.components().insertProject(anotherOrganization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    ComponentDto anotherProject = dbTester.components().insertPrivateProject(anotherOrganization);
     UserDto user = dbTester.users().insertUser();
     UserDto anotherUser = dbTester.users().insertUser();
     insertProperty("KEY_11", "VALUE", project.getId(), user.getId());
@@ -872,8 +872,8 @@ public class PropertiesDaoTest {
   public void delete_by_organization_and_matching_login() throws SQLException {
     OrganizationDto organization = dbTester.organizations().insert();
     OrganizationDto anotherOrganization = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization);
-    ComponentDto anotherProject = dbTester.components().insertProject(anotherOrganization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    ComponentDto anotherProject = dbTester.components().insertPrivateProject(anotherOrganization);
     UserDto user = dbTester.users().insertUser();
     UserDto anotherUser = dbTester.users().insertUser();
     insertProperty("KEY_11", user.getLogin(), project.getId(), null);
@@ -892,8 +892,8 @@ public class PropertiesDaoTest {
 
   @Test
   public void delete_by_key_and_value() throws SQLException {
-    ComponentDto project = dbTester.components().insertProject();
-    ComponentDto anotherProject = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
+    ComponentDto anotherProject = dbTester.components().insertPrivateProject();
     insertProperty("KEY", "VALUE", null, null);
     insertProperty("KEY", "VALUE", project.getId(), null);
     insertProperty("KEY", "VALUE", null, 100);
@@ -1091,7 +1091,7 @@ public class PropertiesDaoTest {
 
   private ComponentDto insertProject(String uuid) {
     String key = "project" + uuid;
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), uuid).setKey(key);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setKey(key);
     dbClient.componentDao().insert(session, project);
     dbTester.commit();
     return project;
index 6e8b84d3957be2cd05d1f1dae64871e421005cb2..966708909a120dd436265d3a95c83612d5515a49 100644 (file)
@@ -141,8 +141,8 @@ public class PurgeDaoTest {
 
   @Test
   public void delete_project_in_ce_activity_when_deleting_project() {
-    ComponentDto projectToBeDeleted = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization());
-    ComponentDto anotherLivingProject = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto projectToBeDeleted = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
+    ComponentDto anotherLivingProject = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization());
     dbClient.componentDao().insert(dbSession, projectToBeDeleted, anotherLivingProject);
 
     // Insert 2 rows in CE_ACTIVITY : one for the project that will be deleted, and on on another project
@@ -158,8 +158,8 @@ public class PurgeDaoTest {
 
   @Test
   public void delete_tasks_in_ce_queue_when_deleting_project() {
-    ComponentDto projectToBeDeleted = dbTester.components().insertProject();
-    ComponentDto anotherLivingProject = dbTester.components().insertProject();
+    ComponentDto projectToBeDeleted = dbTester.components().insertPrivateProject();
+    ComponentDto anotherLivingProject = dbTester.components().insertPrivateProject();
 
     // Insert 3 rows in CE_QUEUE: two for the project that will be deleted (in order to check that status
     // is not involved in deletion), and one on another project
index 5cd69a2331766ecfc396c5bc12f67c5e45fd90af..ac367f963819708f543e940f4fa084273a34efd3 100644 (file)
@@ -88,7 +88,7 @@ public class ProjectQgateAssociationDaoTest {
 
   @Test
   public void select_qgate_id_is_absent() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     Optional<Long> result = underTest.selectQGateIdByComponentId(dbSession, project.getId());
 
index ebee92794968bdd4075672f1622287a47c9739b9..f52517ed90a40c277ce8d77f036f1133e9270811 100644 (file)
@@ -128,7 +128,7 @@ public class QualityProfileDaoTest {
   @Test
   public void deleteProjectAssociationsByProfileKeys_does_nothing_if_empty_keys() {
     QualityProfileDto profile1 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization());
-    ComponentDto project1 = dbTester.components().insertProject();
+    ComponentDto project1 = dbTester.components().insertPrivateProject();
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profile1);
 
     underTest.deleteProjectAssociationsByProfileKeys(dbSession, Collections.emptyList());
@@ -140,9 +140,9 @@ public class QualityProfileDaoTest {
   public void deleteProjectAssociationsByProfileKeys_deletes_rows_from_table_project_profiles() {
     QualityProfileDto profile1 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization());
     QualityProfileDto profile2 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization());
-    ComponentDto project1 = dbTester.components().insertProject();
-    ComponentDto project2 = dbTester.components().insertProject();
-    ComponentDto project3 = dbTester.components().insertProject();
+    ComponentDto project1 = dbTester.components().insertPrivateProject();
+    ComponentDto project2 = dbTester.components().insertPrivateProject();
+    ComponentDto project3 = dbTester.components().insertPrivateProject();
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profile1);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project2, profile1);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project3, profile2);
@@ -304,14 +304,14 @@ public class QualityProfileDaoTest {
   public void countProjectsByProfileKey() {
     QualityProfileDto profileWithoutProjects = dbTester.qualityProfiles().insert(organization);
     QualityProfileDto profileWithProjects = dbTester.qualityProfiles().insert(organization);
-    ComponentDto project1 = dbTester.components().insertProject(organization);
-    ComponentDto project2 = dbTester.components().insertProject(organization);
+    ComponentDto project1 = dbTester.components().insertPrivateProject(organization);
+    ComponentDto project2 = dbTester.components().insertPrivateProject(organization);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profileWithProjects);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project2, profileWithProjects);
 
     OrganizationDto otherOrg = dbTester.organizations().insert();
     QualityProfileDto profileInOtherOrg = dbTester.qualityProfiles().insert(otherOrg);
-    ComponentDto projectInOtherOrg = dbTester.components().insertProject(otherOrg);
+    ComponentDto projectInOtherOrg = dbTester.components().insertPrivateProject(otherOrg);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(projectInOtherOrg, profileInOtherOrg);
 
     assertThat(underTest.countProjectsByProfileKey(dbTester.getSession(), organization)).containsOnly(
@@ -357,11 +357,11 @@ public class QualityProfileDaoTest {
 
   @Test
   public void select_selected_projects() throws Exception {
-    ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
     OrganizationDto organization2 = dbTester.organizations().insert();
-    ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
+    ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
 
     QualityProfileDto profile1 = newQualityProfileDto();
     qualityProfileDb.insertQualityProfiles(profile1);
@@ -384,11 +384,11 @@ public class QualityProfileDaoTest {
 
   @Test
   public void select_deselected_projects() throws Exception {
-    ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
     OrganizationDto organization2 = dbTester.organizations().insert();
-    ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
+    ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
 
     QualityProfileDto profile1 = newQualityProfileDto();
     qualityProfileDb.insertQualityProfiles(profile1);
@@ -410,11 +410,11 @@ public class QualityProfileDaoTest {
 
   @Test
   public void select_project_associations() throws Exception {
-    ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
-    ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
+    ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
     OrganizationDto organization2 = dbTester.organizations().insert();
-    ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
+    ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid()));
 
     QualityProfileDto profile1 = newQualityProfileDto();
     qualityProfileDb.insertQualityProfiles(profile1);
@@ -437,7 +437,7 @@ public class QualityProfileDaoTest {
 
   @Test
   public void update_project_profile_association() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     QualityProfileDto profile1Language1 = insertQualityProfileDto("profile1", "Profile 1", "xoo");
     QualityProfileDto profile2Language2 = insertQualityProfileDto("profile2", "Profile 2", "xoo2");
     QualityProfileDto profile3Language1 = insertQualityProfileDto("profile3", "Profile 3", "xoo");
index 81b0e19af65f29af48aeb0eaccd9b78efe031d4f..affc42fd85e05add6f314275a8f7ba9ecd5c14f9 100644 (file)
@@ -53,8 +53,8 @@ public class RoleDaoTest {
   public void setUp() throws Exception {
     user1 = db.users().insertUser();
     user2 = db.users().insertUser();
-    project1 = db.components().insertProject();
-    project2 = db.components().insertProject();
+    project1 = db.components().insertPrivateProject();
+    project2 = db.components().insertPrivateProject();
   }
 
   @Test
@@ -117,7 +117,7 @@ public class RoleDaoTest {
   public void delete_all_group_permissions_by_group_id() {
     GroupDto group1 = db.users().insertGroup();
     GroupDto group2 = db.users().insertGroup();
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertPermissionOnGroup(group1, "admin");
     db.users().insertProjectPermissionOnGroup(group1, "profileadmin", project);
     db.users().insertPermissionOnGroup(group1, "gateadmin");
index 147e1764829f1c78a2b41e2880245e326c25df1a..71829dfd15758bd89ae211c91a088f822af40ff8 100644 (file)
@@ -73,7 +73,7 @@ public class CeQueueImplTest {
 
   @Test
   public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() {
-    ComponentDto componentDto = insertComponent(ComponentTesting.newProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
+    ComponentDto componentDto = insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
     CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto.uuid(), null);
 
     CeTask task = underTest.submit(taskSubmit);
@@ -116,7 +116,7 @@ public class CeQueueImplTest {
 
   @Test
   public void massSubmit_populates_component_name_and_key_of_CeTask_if_component_exists() {
-    ComponentDto componentDto1 = insertComponent(ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1"));
+    ComponentDto componentDto1 = insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1"));
     CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, componentDto1.uuid(), null);
     CeTaskSubmit taskSubmit2 = createTaskSubmit("something", "non existing component uuid", null);
 
index b5c4552c2c7fb611c3c9c7616d447e5a2de085fa..8be279269b529a41a0d7a74e9e8cf818b89a2be0 100644 (file)
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.rules.RuleType.BUG;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.rule.RuleTesting.newRule;
 
 public class IssuesActionTest {
@@ -87,7 +87,7 @@ public class IssuesActionTest {
 
   @Test
   public void return_minimal_fields() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY));
     ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath(null));
     db.rules().insert(RULE_DEFINITION);
@@ -126,7 +126,7 @@ public class IssuesActionTest {
   @Test
   public void issues_from_project() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY));
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY));
     ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java"));
     db.rules().insert(RULE_DEFINITION);
@@ -162,7 +162,7 @@ public class IssuesActionTest {
 
   @Test
   public void issues_from_module() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY));
     ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java"));
     db.rules().insert(RULE_DEFINITION);
@@ -198,7 +198,7 @@ public class IssuesActionTest {
 
   @Test
   public void issues_from_file() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY));
     ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java"));
     db.rules().insert(RULE_DEFINITION);
@@ -235,7 +235,7 @@ public class IssuesActionTest {
   @Test
   public void issues_attached_on_module() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY));
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY));
     db.rules().insert(RULE_DEFINITION);
     db.issues().insert(RULE_DEFINITION, project, module, issue -> issue
@@ -270,7 +270,7 @@ public class IssuesActionTest {
 
   @Test
   public void project_issues_attached_file_on_removed_module() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY));
     // File and module are removed
     ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY).setEnabled(false));
     ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java").setEnabled(false));
@@ -297,7 +297,7 @@ public class IssuesActionTest {
 
   @Test
   public void fail_without_browse_permission_on_file() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
     thrown.expect(ForbiddenException.class);
index 8c70e8e7405d722a5316c86b73e3096d55b32394..de6fc94df451379a3f1f12aba1161d4911c7687d 100644 (file)
@@ -87,7 +87,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_settings_with_global_scan_permission() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -111,7 +111,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_settings_with_project_scan_permission() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn("john").addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -135,7 +135,7 @@ public class ProjectDataLoaderMediumTest {
   public void not_returned_secured_settings_when_lgged_but_no_scan_permission() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn("john").addProjectPermission(UserRole.USER, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -157,7 +157,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_with_module_settings() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -193,7 +193,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_with_module_settings_inherited_from_project() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -224,7 +224,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_with_module_with_sub_module() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -271,7 +271,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_project_with_two_modules() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -317,7 +317,7 @@ public class ProjectDataLoaderMediumTest {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
     // No snapshot attached on the project -> provisioned project
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -338,7 +338,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_sub_module_settings() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
     // No project properties
@@ -372,7 +372,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_sub_module_settings_including_settings_from_parent_modules() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
 
@@ -408,7 +408,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_sub_module_settings_only_inherited_from_project() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
 
@@ -442,7 +442,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_sub_module_settings_inherited_from_project_and_module() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
 
@@ -479,7 +479,7 @@ public class ProjectDataLoaderMediumTest {
 
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
 
@@ -495,7 +495,7 @@ public class ProjectDataLoaderMediumTest {
   public void fail_when_not_preview_and_only_browse_permission_without_scan_permission() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
 
@@ -511,7 +511,7 @@ public class ProjectDataLoaderMediumTest {
   public void fail_when_preview_and_only_scan_permission_without_browse_permission() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
 
@@ -526,7 +526,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_file_data_from_single_project() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -546,7 +546,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_file_data_from_multi_modules() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
@@ -575,7 +575,7 @@ public class ProjectDataLoaderMediumTest {
   public void return_file_data_from_module() {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     dbClient.organizationDao().insert(dbSession, organizationDto);
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(dbSession, project);
     addDefaultProfile();
 
index a5f342d9fd73b18f0fb0e0fbcd28cc5e0c631f25..37718679766a9e443c365aa94235556b134520ae 100644 (file)
@@ -129,7 +129,7 @@ public class ProjectDataLoaderTest {
 
   @Test
   public void throw_ForbiddenException_if_no_browse_permission_nor_scan_permission() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -140,7 +140,7 @@ public class ProjectDataLoaderTest {
 
   @Test
   public void throw_ForbiddenException_if_browse_permission_but_not_scan_permission() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
 
     expectedException.expect(ForbiddenException.class);
@@ -151,7 +151,7 @@ public class ProjectDataLoaderTest {
 
   @Test
   public void issues_mode_is_allowed_if_user_has_browse_permission() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
 
     ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
@@ -161,7 +161,7 @@ public class ProjectDataLoaderTest {
 
   @Test
   public void issues_mode_is_forbidden_if_user_doesnt_have_browse_permission() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(GlobalPermissions.SCAN_EXECUTION, project);
 
     expectedException.expect(ForbiddenException.class);
@@ -172,7 +172,7 @@ public class ProjectDataLoaderTest {
 
   @Test
   public void scan_permission_on_organization_is_enough_even_without_scan_permission_on_project() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn().addPermission(SCAN, project.getOrganizationUuid());
     userSession.logIn().addProjectPermission(UserRole.USER, project);
 
index 272b1233010ba2e3a0ce713e7a50ec434f1cff2b..dc171f42bbfa8250a89db2f17246f4720ecd02bc 100644 (file)
@@ -34,6 +34,7 @@ import org.sonar.db.ce.CeActivityDto;
 import org.sonar.db.ce.CeQueueDto;
 import org.sonar.db.ce.CeTaskTypes;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -52,7 +53,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.sonar.api.utils.DateUtils.formatDate;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_QUERY;
@@ -80,9 +80,9 @@ public class ActivityActionTest {
   public void get_all_past_activity() {
     logInAsSystemAdministrator();
     OrganizationDto org1 = dbTester.organizations().insert();
-    dbTester.components().insertProject(org1, "PROJECT_1");
+    dbTester.components().insertPrivateProject(org1, "PROJECT_1");
     OrganizationDto org2 = dbTester.organizations().insert();
-    dbTester.components().insertProject(org2, "PROJECT_2");
+    dbTester.components().insertPrivateProject(org2, "PROJECT_2");
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
 
@@ -110,8 +110,8 @@ public class ActivityActionTest {
   @Test
   public void filter_by_status() {
     logInAsSystemAdministrator();
-    dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1");
-    dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_2");
+    dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1");
+    dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_2");
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
     insertQueue("T3", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
@@ -142,7 +142,7 @@ public class ActivityActionTest {
   public void filter_by_min_submitted_and_max_executed_at_include_day() {
     logInAsSystemAdministrator();
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    dbTester.components().insertProject(organizationDto, "PROJECT_1");
+    dbTester.components().insertPrivateProject(organizationDto, "PROJECT_1");
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     String today = formatDate(new Date(EXECUTED_AT));
 
@@ -155,7 +155,7 @@ public class ActivityActionTest {
 
   @Test
   public void filter_on_current_activities() {
-    dbTester.components().insertProject(dbTester.organizations().insert(), "PROJECT_1");
+    dbTester.components().insertPrivateProject(dbTester.organizations().insert(), "PROJECT_1");
     logInAsSystemAdministrator();
     // T2 is the current activity (the most recent one)
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
@@ -174,8 +174,8 @@ public class ActivityActionTest {
   public void limit_results() {
     logInAsSystemAdministrator();
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    dbTester.components().insertProject(organizationDto, "PROJECT_1");
-    dbTester.components().insertProject(organizationDto, "PROJECT_2");
+    dbTester.components().insertPrivateProject(organizationDto, "PROJECT_1");
+    dbTester.components().insertPrivateProject(organizationDto, "PROJECT_2");
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
     insertQueue("T3", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
@@ -210,7 +210,7 @@ public class ActivityActionTest {
 
   @Test
   public void project_administrator_can_access_his_project_activity() {
-    ComponentDto project = dbTester.components().insertProject(dbTester.organizations().insert(), "PROJECT_1");
+    ComponentDto project = dbTester.components().insertPrivateProject(dbTester.organizations().insert(), "PROJECT_1");
     // no need to be a system admin
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
@@ -226,7 +226,7 @@ public class ActivityActionTest {
 
   @Test
   public void return_401_if_user_is_not_logged_in() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.anonymous();
 
     expectedException.expect(UnauthorizedException.class);
@@ -238,9 +238,9 @@ public class ActivityActionTest {
   @Test
   public void search_activity_by_component_name() throws IOException {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto struts = newProjectDto(organizationDto).setName("old apache struts").setUuid("P1").setProjectUuid("P1");
-    ComponentDto zookeeper = newProjectDto(organizationDto).setName("new apache zookeeper").setUuid("P2").setProjectUuid("P2");
-    ComponentDto eclipse = newProjectDto(organizationDto).setName("eclipse").setUuid("P3").setProjectUuid("P3");
+    ComponentDto struts = ComponentTesting.newPrivateProjectDto(organizationDto).setName("old apache struts").setUuid("P1").setProjectUuid("P1");
+    ComponentDto zookeeper = ComponentTesting.newPrivateProjectDto(organizationDto).setName("new apache zookeeper").setUuid("P2").setProjectUuid("P2");
+    ComponentDto eclipse = ComponentTesting.newPrivateProjectDto(organizationDto).setName("eclipse").setUuid("P3").setProjectUuid("P3");
     dbTester.components().insertProjectAndSnapshot(struts);
     dbTester.components().insertProjectAndSnapshot(zookeeper);
     dbTester.components().insertProjectAndSnapshot(eclipse);
@@ -270,7 +270,7 @@ public class ActivityActionTest {
   @Test
   public void search_task_id_in_queue_ignoring_other_parameters() throws IOException {
     logInAsSystemAdministrator();
-    dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1");
+    dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1");
     insertQueue("T1", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
 
     ActivityResponse result = call(
@@ -285,7 +285,7 @@ public class ActivityActionTest {
   @Test
   public void search_task_id_in_activity() {
     logInAsSystemAdministrator();
-    dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1");
+    dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1");
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
 
     ActivityResponse result = call(ws.newRequest().setParam(Param.TEXT_QUERY, "T1"));
@@ -311,7 +311,7 @@ public class ActivityActionTest {
 
   @Test
   public void search_task_by_component_id() {
-    ComponentDto project = dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1");
+    ComponentDto project = dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1");
     insertQueue("T1", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
index 35534909ba19c40df607052e5b430c3089dfd567..966563767e96879523c04601a0da38072ac4817f 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.ce.CeActivityDto;
 import org.sonar.db.ce.CeQueueDto;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -43,7 +44,7 @@ import org.sonarqube.ws.WsCe;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.ce.CeQueueTesting.newCeQueueDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_KEY;
@@ -81,9 +82,9 @@ public class ActivityStatusActionTest {
     String projectUuid = "project-uuid";
     String anotherProjectUuid = "another-project-uuid";
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = newProjectDto(organizationDto, projectUuid);
+    ComponentDto project = newPrivateProjectDto(organizationDto, projectUuid);
     db.components().insertComponent(project);
-    db.components().insertComponent(newProjectDto(organizationDto, anotherProjectUuid));
+    db.components().insertComponent(newPrivateProjectDto(organizationDto, anotherProjectUuid));
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     // pending tasks returned
     insertInQueue(CeQueueDto.Status.PENDING, projectUuid);
@@ -115,7 +116,7 @@ public class ActivityStatusActionTest {
 
   @Test
   public void fail_if_component_uuid_and_key_are_provided() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     db.components().insertComponent(project);
     expectedException.expect(IllegalArgumentException.class);
 
@@ -149,7 +150,7 @@ public class ActivityStatusActionTest {
   @Test
   public void throw_ForbiddenException_if_not_administrator_of_requested_project() {
     userSession.logIn();
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
index fa1b0352e99cca92c0ec9c4494ee39f846f04357..9af2de6248cc16a83ae4d86879814136ef1ff706 100644 (file)
@@ -39,7 +39,7 @@ import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.WsCe;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.ce.ws.ComponentAction.PARAM_COMPONENT_ID;
 import static org.sonar.server.ce.ws.ComponentAction.PARAM_COMPONENT_KEY;
 
@@ -60,7 +60,7 @@ public class ComponentActionTest {
 
   @Test
   public void empty_queue_and_empty_activity() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
+    ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
     userSession.addProjectPermission(UserRole.USER, project);
 
     WsCe.ProjectResponse response = ws.newRequest()
@@ -74,7 +74,7 @@ public class ComponentActionTest {
   @Test
   public void project_tasks() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(organizationDto, "PROJECT_1"));
+    ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(organizationDto, "PROJECT_1"));
     userSession.addProjectPermission(UserRole.USER, project);
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
@@ -99,7 +99,7 @@ public class ComponentActionTest {
 
   @Test
   public void search_tasks_by_component_key() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     logInWithBrowsePermission(project);
     insertActivity("T1", project.uuid(), CeActivityDto.Status.SUCCESS);
 
@@ -111,7 +111,7 @@ public class ComponentActionTest {
 
   @Test
   public void canceled_tasks_must_not_be_picked_as_current_analysis() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1"));
+    ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1"));
     userSession.addProjectPermission(UserRole.USER, project);
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
@@ -139,7 +139,7 @@ public class ComponentActionTest {
 
   @Test
   public void throw_ForbiddenException_if_user_cant_access_project() {
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -153,7 +153,7 @@ public class ComponentActionTest {
   @Test
   public void fail_when_no_component_parameter() {
     expectedException.expect(IllegalArgumentException.class);
-    logInWithBrowsePermission(dbTester.components().insertProject());
+    logInWithBrowsePermission(dbTester.components().insertPrivateProject());
 
     ws.newRequest().execute();
   }
index 1380ec2eb123c0727085721847eaaef20685ae3b..2978499f5d0ee78cb55a24ebf29da4438d24f965 100644 (file)
@@ -65,7 +65,7 @@ public class TaskActionTest {
   @Before
   public void setUp() {
     organizationDto = dbTester.organizations().insert();
-    project = dbTester.components().insertProject(organizationDto);
+    project = dbTester.components().insertPrivateProject(organizationDto);
   }
 
   @Test
index 21f03c8c79380b5b6f08d0155fb2a42895e987bf..9edfea2cfd7597e3858ef97828ab7ae2be78dd87 100644 (file)
@@ -78,7 +78,7 @@ public class TaskFormatterTest {
   public void formatQueue_with_component_and_other_fields() throws IOException {
     String uuid = "COMPONENT_UUID";
     OrganizationDto organizationDto = db.organizations().insert();
-    db.components().insertProject(organizationDto, (t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name"));
+    db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name"));
 
     CeQueueDto dto = new CeQueueDto();
     dto.setUuid("UUID");
index e3328c4ea7c3e82c04287fee9038b9e28415a42a..a2fb921d485edcad25cda364a82c9ffa69d99a27 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.issue.IssueDto;
@@ -47,7 +48,7 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 public class ComponentCleanerServiceTest {
 
@@ -93,7 +94,7 @@ public class ComponentCleanerServiceTest {
   @Test
   public void fail_with_IAE_if_not_a_project() throws Exception {
     mockResourceTypeAsValidProject();
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     dbClient.componentDao().insert(dbSession, project);
     ComponentDto file = newFileDto(project, null);
     dbClient.componentDao().insert(dbSession, file);
@@ -108,7 +109,7 @@ public class ComponentCleanerServiceTest {
     ResourceType resourceType = mock(ResourceType.class);
     when(resourceType.getBooleanProperty("deletable")).thenReturn(false);
     when(mockResourceTypes.get(anyString())).thenReturn(resourceType);
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
 
@@ -119,7 +120,7 @@ public class ComponentCleanerServiceTest {
   @Test
   public void fail_to_delete_null_resource_type() throws Exception {
     when(mockResourceTypes.get(anyString())).thenReturn(null);
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
 
@@ -129,7 +130,7 @@ public class ComponentCleanerServiceTest {
 
   private DbData insertData(int id) {
     String suffix = String.valueOf(id);
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid-" + suffix)
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid-" + suffix)
       .setKey("project-key-" + suffix);
     RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("sonarqube", "rule-" + suffix));
     dbClient.ruleDao().insert(dbSession, rule);
index da93c573b4209e751402dbe0a65a369c99810101..60bcef4ae3323ef7a18533b1bc74a41a5a547dbc 100644 (file)
@@ -26,10 +26,11 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.server.exceptions.NotFoundException;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.component.ComponentFinder.ParamNames.ID_AND_KEY;
 
 
@@ -95,7 +96,7 @@ public class ComponentFinderTest {
 
   @Test
   public void get_component_by_uuid() {
-    db.components().insertComponent(newProjectDto(db.organizations().insert(), "project-uuid"));
+    db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
 
     ComponentDto component = underTest.getByUuidOrKey(dbSession, "project-uuid", null, ID_AND_KEY);
 
@@ -104,7 +105,7 @@ public class ComponentFinderTest {
 
   @Test
   public void get_component_by_key() {
-    db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("project-key"));
+    db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key"));
 
     ComponentDto component = underTest.getByUuidOrKey(dbSession, null, "project-key", ID_AND_KEY);
 
index 2698ce6574700cbef0965b2feb5dd057108007da..fd7b5fcabae28abe6f8719d477b299d9cce8168a 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.server.es.ProjectIndexer;
 import org.sonar.server.tester.UserSessionRule;
 
@@ -35,7 +36,6 @@ import static org.assertj.guava.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 public class ComponentServiceTest {
 
@@ -55,7 +55,7 @@ public class ComponentServiceTest {
 
   @Test
   public void bulk_update() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(dbTester.organizations().insert()).setKey("my_project"));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey("my_project"));
     ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
     ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
     ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
index 1fc5f7f6993124e209920c897915d1220c72e0b5..6b2e0933d7cacb499c21f72b5c78380231b9c1c2 100644 (file)
@@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 public class ComponentServiceUpdateKeyTest {
 
@@ -131,7 +130,7 @@ public class ComponentServiceUpdateKeyTest {
   @Test
   public void fail_if_old_key_and_new_key_are_the_same() {
     ComponentDto project = insertSampleRootProject();
-    ComponentDto anotherProject = componentDb.insertProject();
+    ComponentDto anotherProject = componentDb.insertPrivateProject();
     logInAsProjectAdministrator(project);
 
     expectedException.expect(IllegalArgumentException.class);
@@ -176,7 +175,7 @@ public class ComponentServiceUpdateKeyTest {
 
   @Test
   public void bulk_update_key() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()).setKey("my_project"));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my_project"));
     ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
     ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
     ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
@@ -205,7 +204,7 @@ public class ComponentServiceUpdateKeyTest {
   }
 
   private ComponentDto insertProject(String key) {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()).setKey(key));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey(key));
     return project;
   }
 
index dcb18400303bfb8fee78de64432382cac6c4ba89..ff0c96c5efc8e952168a445aa9b22d4396c7bce5 100644 (file)
@@ -164,7 +164,7 @@ public class ComponentUpdaterTest {
 
   @Test
   public void fail_when_project_key_already_exists() throws Exception {
-    ComponentDto existing = db.components().insertProject();
+    ComponentDto existing = db.components().insertPrivateProject();
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("Could not create Project, key already exists: " + existing.key());
@@ -180,7 +180,7 @@ public class ComponentUpdaterTest {
 
   @Test
   public void fail_when_project_key_already_exists_on_other_organization() throws Exception {
-    ComponentDto existing = db.components().insertProject(db.organizations().insert());
+    ComponentDto existing = db.components().insertPrivateProject(db.organizations().insert());
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("Could not create Project, key already exists: " + existing.key());
index 6cc39ae4877aa50e4c0c2f04a7e7b42339f8c24d..4530d4f02e6527bba51ba47d80511edc79c8396f 100644 (file)
@@ -112,10 +112,10 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {
 
   @Test
   public void should_prefer_favorite_over_recently_browsed() {
-    ComponentDto recentlyBrowsed = db.components().insertProject(c -> c.setName("File1"));
+    ComponentDto recentlyBrowsed = db.components().insertPrivateProject(c -> c.setName("File1"));
     index(recentlyBrowsed);
 
-    ComponentDto favorite = db.components().insertProject(c -> c.setName("File2"));
+    ComponentDto favorite = db.components().insertPrivateProject(c -> c.setName("File2"));
     index(favorite);
 
     ComponentIndexQuery query = ComponentIndexQuery.builder()
index f333da67d33075f4efebc957cec97df74761d7bc..49b79d4b857bbf686719a1d0be80e9f6ea505af7 100644 (file)
@@ -125,13 +125,13 @@ public abstract class ComponentIndexTest {
 
   protected ComponentDto indexProject(String key, String name) {
     return index(
-      ComponentTesting.newProjectDto(organization, "UUID_" + key)
+      ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key)
         .setKey(key)
         .setName(name));
   }
 
   protected ComponentDto newProject(String key, String name) {
-    return ComponentTesting.newProjectDto(organization, "UUID_" + key)
+    return ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key)
       .setKey(key)
       .setName(name);
   }
index db53112cdb01a095316a7920965b83830e30cf4d..925de147601850736ad9a109ae8318aad105c944 100644 (file)
@@ -78,7 +78,7 @@ public class ComponentIndexerTest {
 
   @Test
   public void index_everything() {
-    insert(ComponentTesting.newProjectDto(organization));
+    insert(ComponentTesting.newPrivateProjectDto(organization));
 
     index();
     assertThat(count()).isEqualTo(1);
@@ -86,7 +86,7 @@ public class ComponentIndexerTest {
 
   @Test
   public void index_unexisting_project_while_database_contains_another() {
-    insert(ComponentTesting.newProjectDto(organization, "UUID-1"));
+    insert(ComponentTesting.newPrivateProjectDto(organization, "UUID-1"));
 
     index("UUID-2");
     assertThat(count()).isEqualTo(0);
@@ -94,7 +94,7 @@ public class ComponentIndexerTest {
 
   @Test
   public void index_one_project() {
-    ComponentDto project = ComponentTesting.newProjectDto(organization, "UUID-1");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organization, "UUID-1");
     insert(project);
 
     index(project);
@@ -103,7 +103,7 @@ public class ComponentIndexerTest {
 
   @Test
   public void index_one_project_containing_a_file() {
-    ComponentDto projectComponent = ComponentTesting.newProjectDto(organization, "UUID-PROJECT-1");
+    ComponentDto projectComponent = ComponentTesting.newPrivateProjectDto(organization, "UUID-PROJECT-1");
     insert(projectComponent);
     insert(ComponentTesting.newFileDto(projectComponent));
 
@@ -115,7 +115,7 @@ public class ComponentIndexerTest {
   public void index_and_update_and_reindex_project() {
 
     // insert
-    ComponentDto component = ComponentTesting.newProjectDto(organization, "UUID-1").setName("OldName");
+    ComponentDto component = ComponentTesting.newPrivateProjectDto(organization, "UUID-1").setName("OldName");
     insert(component);
 
     // verify insert
@@ -136,7 +136,7 @@ public class ComponentIndexerTest {
   public void index_and_update_and_reindex_project_with_files() {
 
     // insert
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project).setName("OldFile"));
 
     // verify insert
@@ -157,7 +157,7 @@ public class ComponentIndexerTest {
   public void full_reindexing_on_empty_index() {
 
     // insert
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     dbTester.components().insertComponent(ComponentTesting.newFileDto(project).setName("OldFile"));
 
     // verify insert
index 0de565d501fed03aae5dbf8e1cf5b5b56c2d9bd1..124a2ed055c130e3e1b08efcf9f3a01ab93117db 100644 (file)
@@ -139,7 +139,7 @@ public class AppActionTest {
   }
 
   private ComponentDto[] insertComponentsAndAnalysis() {
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), PROJECT_UUID)
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), PROJECT_UUID)
       .setLongName("SonarQube")
       .setKey(PROJECT_KEY);
     ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project)
index d79b53be798dd60a63137d9534ee2ebd9bee6732..75f7a8dc3e1a4e5541c1189bc3d12069cac8e6d1 100644 (file)
@@ -38,7 +38,7 @@ public class ComponentDtoToWsComponentTest {
   public void componentDtoToWsComponent_throws_IAE_if_organization_uuid_of_component_does_not_match_organizationDto_uuid() {
     OrganizationDto organizationDto1 = OrganizationTesting.newOrganizationDto();
     OrganizationDto organizationDto2 = OrganizationTesting.newOrganizationDto();
-    ComponentDto componentDto = ComponentTesting.newProjectDto(organizationDto1);
+    ComponentDto componentDto = ComponentTesting.newPrivateProjectDto(organizationDto1);
 
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("OrganizationUuid (" + organizationDto1.getUuid() + ") of ComponentDto to convert " +
index 8d04e0fe4c7bc3e8c76a22f16b3dc6a794f38ccf..b3d35693ad0399475b3cdc9d7ae402c6f63f72a6 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.ResourceTypesRule;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.UserDto;
@@ -62,7 +63,7 @@ import static org.sonar.core.util.Protobuf.setNullable;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.WsComponents.Component;
@@ -122,8 +123,8 @@ public class SearchActionTest {
   @Test
   public void search_by_key_query() throws IOException {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
-      newProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
 
     SearchWsResponse response = call(new SearchWsRequest().setQuery("project-_%-key").setQualifiers(singletonList(PROJECT)));
 
@@ -132,7 +133,7 @@ public class SearchActionTest {
 
   @Test
   public void search_for_files() throws IOException {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     ComponentDto file1 = newFileDto(project).setKey("file1");
     ComponentDto file2 = newFileDto(project).setKey("file2");
     db.components().insertComponents(project, file1, file2);
@@ -148,7 +149,7 @@ public class SearchActionTest {
     OrganizationDto organizationDto = db.organizations().insert();
     List<ComponentDto> componentDtoList = new ArrayList<>();
     for (int i = 1; i <= 9; i++) {
-      componentDtoList.add(newProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
+      componentDtoList.add(newPrivateProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
     }
     insertProjectsAuthorizedForUser(componentDtoList.toArray(new ComponentDto[] {}));
 
@@ -161,8 +162,8 @@ public class SearchActionTest {
   public void search_with_language() throws IOException {
     OrganizationDto organizationDto = db.organizations().insert();
     insertProjectsAuthorizedForUser(
-      newProjectDto(organizationDto).setKey("java-project").setLanguage("java"),
-      newProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp"));
+      ComponentTesting.newPrivateProjectDto(organizationDto).setKey("java-project").setLanguage("java"),
+      ComponentTesting.newPrivateProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp"));
 
     SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT)));
 
@@ -171,10 +172,10 @@ public class SearchActionTest {
 
   @Test
   public void return_only_components_from_projects_on_which_user_has_browse_permission() throws IOException {
-    ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     ComponentDto file1 = newFileDto(project1).setKey("file1");
     ComponentDto file2 = newFileDto(project1).setKey("file2");
-    ComponentDto project2 = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     ComponentDto file3 = newFileDto(project2).setKey("file3");
     db.components().insertComponents(project1, file1, file2, project2, file3);
     setBrowsePermissionOnUser(project1);
@@ -187,9 +188,9 @@ public class SearchActionTest {
   @Test
   public void do_not_verify_permissions_if_user_is_root() throws IOException {
     OrganizationDto org = db.organizations().insert();
-    ComponentDto project1 = newProjectDto(org);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file1 = newFileDto(project1);
-    ComponentDto project2 = newProjectDto(org);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file2 = newFileDto(project2);
     db.components().insertComponents(project1, file1, project2, file2);
 
@@ -222,7 +223,7 @@ public class SearchActionTest {
   public void test_json_example() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
     db.components().insertComponent(newView(organizationDto));
-    ComponentDto project = newProjectDto(organizationDto, "project-uuid").setName("Project Name").setKey("project-key");
+    ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setName("Project Name").setKey("project-key");
     ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setKey("module-key");
     ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setKey("directory-key").setName("Directory Name");
     db.components().insertComponents(project, module, directory,
index 9d806cc5db451021fdf546d834a34888a3f22d3d..58ebf23fba82819147a6726a90300bd616931690 100644 (file)
@@ -41,6 +41,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.property.PropertyDto;
 import org.sonar.server.es.EsTester;
@@ -80,7 +81,7 @@ import static org.sonar.core.util.stream.MoreCollectors.toList;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -159,16 +160,16 @@ public class SearchProjectsActionTest {
   public void json_example() {
     OrganizationDto organization1Dto = db.organizations().insertForKey("my-org-key-1");
     OrganizationDto organization2Dto = db.organizations().insertForKey("my-org-key-2");
-    ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(organization1Dto)
+    ComponentDto project1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1Dto)
       .setUuid(Uuids.UUID_EXAMPLE_01)
       .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_001)
       .setName("My Project 1")
       .setTagsString("finance, java"));
-    insertProjectInDbAndEs(newProjectDto(organization1Dto)
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1Dto)
       .setUuid(Uuids.UUID_EXAMPLE_02)
       .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_002)
       .setName("My Project 2"));
-    insertProjectInDbAndEs(newProjectDto(organization2Dto)
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2Dto)
       .setUuid(Uuids.UUID_EXAMPLE_03)
       .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_003)
       .setName("My Project 3")
@@ -184,9 +185,9 @@ public class SearchProjectsActionTest {
 
   @Test
   public void order_by_name_case_insensitive() {
-    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Maven"));
-    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Apache"));
-    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("guava"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Maven"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Apache"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("guava"));
 
     SearchProjectsWsResponse result = call(request);
 
@@ -196,7 +197,7 @@ public class SearchProjectsActionTest {
 
   @Test
   public void paginate_result() {
-    IntStream.rangeClosed(1, 9).forEach(i -> insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("PROJECT-" + i)));
+    IntStream.rangeClosed(1, 9).forEach(i -> insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("PROJECT-" + i)));
 
     SearchProjectsWsResponse result = call(request.setPage(2).setPageSize(3));
 
@@ -223,7 +224,7 @@ public class SearchProjectsActionTest {
   @Test
   public void return_only_projects() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = newProjectDto(organizationDto).setName("SonarQube");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto).setName("SonarQube");
     ComponentDto directory = newDirectory(project, "path");
     insertProjectInDbAndEs(project);
     componentDb.insertComponents(newModuleDto(project), newView(organizationDto), directory, newFileDto(project, directory));
@@ -237,9 +238,9 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_with_query() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
     insertMetrics(COVERAGE, NCLOC);
     request.setFilter("coverage <= 80 and ncloc <= 10000");
 
@@ -253,9 +254,9 @@ public class SearchProjectsActionTest {
   public void filter_projects_with_query_within_specified_organization() {
     OrganizationDto organization1 = db.organizations().insert();
     OrganizationDto organization2 = db.organizations().insert();
-    insertProjectInDbAndEs(newProjectDto(organization1).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization1).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization2).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
     insertMetrics(COVERAGE, NCLOC);
 
     assertThat(call(request.setOrganization(null)).getComponentsList())
@@ -272,9 +273,9 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_by_quality_gate() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), "OK");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), "OK");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), "ERROR");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), "OK");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), "OK");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), "ERROR");
     insertMetrics(COVERAGE, NCLOC);
     request.setFilter("alert_status = OK");
 
@@ -286,10 +287,10 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_by_languages() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
     insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
     request.setFilter("languages IN (java, js, <null>)");
 
@@ -301,9 +302,9 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_by_tags() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown").setTags(singletonList("marketing")));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube").setTags(newArrayList("offshore")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown").setTags(singletonList("marketing")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube").setTags(newArrayList("offshore")));
     request.setFilter("tags in (finance, offshore)");
 
     SearchProjectsWsResponse result = call(request);
@@ -314,10 +315,10 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_by_text_query() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-java").setName("Sonar Java"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-groovy").setName("Sonar Groovy"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-markdown").setName("Sonar Markdown"));
-    insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonarqube").setName("Sonar Qube"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-java").setName("Sonar Java"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-groovy").setName("Sonar Groovy"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-markdown").setName("Sonar Markdown"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonarqube").setName("Sonar Qube"));
 
     assertThat(call(request.setFilter("query = \"Groovy\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Groovy");
     assertThat(call(request.setFilter("query = \"oNar\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Groovy", "Sonar Markdown",
@@ -334,13 +335,13 @@ public class SearchProjectsActionTest {
     OrganizationDto organization4 = db.organizations().insert();
     OrganizationDto organization5 = db.organizations().insert();
     List<Map<String, Object>> someMeasure = singletonList(newMeasure(COVERAGE, 81));
-    ComponentDto favourite1_1 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure);
-    ComponentDto favourite1_2 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure);
-    ComponentDto nonFavourite1 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure);
-    ComponentDto favourite2 = insertProjectInDbAndEs(newProjectDto(organization2), someMeasure);
-    ComponentDto nonFavourite2 = insertProjectInDbAndEs(newProjectDto(organization2), someMeasure);
-    ComponentDto favourite3 = insertProjectInDbAndEs(newProjectDto(organization3), someMeasure);
-    ComponentDto nonFavourite4 = insertProjectInDbAndEs(newProjectDto(organization4), someMeasure);
+    ComponentDto favourite1_1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure);
+    ComponentDto favourite1_2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure);
+    ComponentDto nonFavourite1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure);
+    ComponentDto favourite2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2), someMeasure);
+    ComponentDto nonFavourite2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2), someMeasure);
+    ComponentDto favourite3 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization3), someMeasure);
+    ComponentDto nonFavourite4 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization4), someMeasure);
     Stream.of(favourite1_1, favourite1_2, favourite2, favourite3)
       .forEach(this::addFavourite);
     insertMetrics(COVERAGE, NCLOC);
@@ -377,11 +378,11 @@ public class SearchProjectsActionTest {
   @Test
   public void filter_projects_on_favorites() {
     userSession.logIn();
-    ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"),
+    ComponentDto javaProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"),
       newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
-    ComponentDto markDownProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "markdown-id").setName("Sonar Markdown"),
+    ComponentDto markDownProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "markdown-id").setName("Sonar Markdown"),
       newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
     addFavourite(javaProject);
     addFavourite(markDownProject);
     dbSession.commit();
@@ -395,9 +396,9 @@ public class SearchProjectsActionTest {
 
   @Test
   public void filtering_on_favorites_returns_empty_results_if_not_logged_in() {
-    ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"),
+    ComponentDto javaProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"),
       newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
     addFavourite(javaProject);
     dbSession.commit();
     request.setFilter("isFavorite");
@@ -410,7 +411,7 @@ public class SearchProjectsActionTest {
 
   @Test
   public void do_not_return_isFavorite_if_anonymous_user() {
-    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81)));
     insertMetrics(COVERAGE);
     userSession.anonymous();
 
@@ -422,7 +423,7 @@ public class SearchProjectsActionTest {
 
   @Test
   public void empty_list_if_isFavorite_filter_and_anonymous_user() {
-    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81)));
     insertMetrics(COVERAGE);
     userSession.anonymous();
     request.setFilter("isFavorite");
@@ -435,10 +436,10 @@ public class SearchProjectsActionTest {
   @Test
   public void return_nloc_facet() {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
     insertMetrics(COVERAGE, NCLOC);
 
     SearchProjectsWsResponse result = call(request.setFacets(singletonList(NCLOC)));
@@ -461,10 +462,10 @@ public class SearchProjectsActionTest {
   @Test
   public void return_languages_facet() {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
     insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
 
     SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_LANGUAGES)));
@@ -484,8 +485,8 @@ public class SearchProjectsActionTest {
   @Test
   public void return_languages_facet_with_language_having_no_project_if_language_is_in_filter() {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java"));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java"));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java"));
     insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
 
     SearchProjectsWsResponse result = call(request.setFilter("languages = xoo").setFacets(singletonList(FILTER_LANGUAGES)));
@@ -504,9 +505,9 @@ public class SearchProjectsActionTest {
   @Test
   public void return_tags_facet() {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
 
     SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_TAGS)));
 
@@ -525,9 +526,9 @@ public class SearchProjectsActionTest {
   @Test
   public void return_tags_facet_with_tags_having_no_project_if_tags_is_in_filter() {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
 
     SearchProjectsWsResponse result = call(request.setFilter("tags = marketing").setFacets(singletonList(FILTER_TAGS)));
 
@@ -546,10 +547,10 @@ public class SearchProjectsActionTest {
   @Test
   public void default_sort_is_by_ascending_name() throws Exception {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
 
     SearchProjectsWsResponse result = call(request);
 
@@ -559,10 +560,10 @@ public class SearchProjectsActionTest {
   @Test
   public void sort_by_name() throws Exception {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
 
     assertThat(call(request.setSort("name").setAsc(true)).getComponentsList()).extracting(Component::getName)
       .containsExactly("Sonar Groovy", "Sonar Java", "Sonar Markdown", "Sonar Qube");
@@ -573,10 +574,10 @@ public class SearchProjectsActionTest {
   @Test
   public void sort_by_coverage() throws Exception {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
     insertMetrics(COVERAGE);
 
     assertThat(call(request.setSort(COVERAGE).setAsc(true)).getComponentsList()).extracting(Component::getName)
@@ -588,10 +589,10 @@ public class SearchProjectsActionTest {
   @Test
   public void sort_by_quality_gate() throws Exception {
     OrganizationDto organization = db.getDefaultOrganization();
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), "ERROR");
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), "WARN");
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), "OK");
-    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), "OK");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), "ERROR");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), "WARN");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), "OK");
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), "OK");
     dbClient.metricDao().insert(dbSession, newMetricDto().setKey(QUALITY_GATE_STATUS).setValueType(LEVEL.name()).setEnabled(true).setHidden(false));
     db.commit();
 
@@ -604,13 +605,13 @@ public class SearchProjectsActionTest {
   @Test
   public void return_last_analysis_date() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(organizationDto));
+    ComponentDto project1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto));
     db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(10_000_000_000L).setLast(false));
     db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(20_000_000_000L).setLast(true));
-    ComponentDto project2 = insertProjectInDbAndEs(newProjectDto(organizationDto));
+    ComponentDto project2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto));
     db.components().insertSnapshot(newAnalysis(project2).setCreatedAt(30_000_000_000L).setLast(true));
     // No snapshot on project 3
-    insertProjectInDbAndEs(newProjectDto(organizationDto));
+    insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     SearchProjectsWsResponse result = call(request.setAdditionalFields(singletonList("analysisDate")));
 
index 55861bb473f35be4e687acf84a4411e0d0a6c729..41294cd3570a4d0db527e68132544c79aa817cba 100644 (file)
@@ -47,7 +47,7 @@ import static org.sonar.api.utils.DateUtils.parseDateTime;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT;
@@ -93,7 +93,7 @@ public class ShowActionTest {
 
   @Test
   public void show_with_browse_permission() {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     userSession.logIn().addProjectPermission(UserRole.USER, project);
 
@@ -105,7 +105,7 @@ public class ShowActionTest {
   @Test
   public void show_provided_project() {
     userSession.logIn().setRoot();
-    componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setEnabled(false));
+    componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setEnabled(false));
 
     ShowWsResponse response = newRequest("project-uuid", null);
 
@@ -115,7 +115,7 @@ public class ShowActionTest {
 
   @Test
   public void show_with_ancestors_when_not_project() throws Exception {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     ComponentDto module = componentDb.insertComponent(newModuleDto(project));
     ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir"));
     ComponentDto file = componentDb.insertComponent(newFileDto(directory));
@@ -129,7 +129,7 @@ public class ShowActionTest {
 
   @Test
   public void show_without_ancestors_when_project() throws Exception {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     componentDb.insertComponent(newModuleDto(project));
     userSession.addProjectPermission(UserRole.USER, project);
 
@@ -141,7 +141,7 @@ public class ShowActionTest {
 
   @Test
   public void show_with_last_analysis_date() throws Exception {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000_000L).setLast(false));
     componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(2_000_000_000L).setLast(false));
     componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
@@ -154,7 +154,7 @@ public class ShowActionTest {
 
   @Test
   public void show_with_ancestors_and_analysis_date() throws Exception {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
     ComponentDto module = componentDb.insertComponent(newModuleDto(project));
     ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir"));
@@ -173,7 +173,7 @@ public class ShowActionTest {
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
 
     newRequest("project-uuid", null);
   }
@@ -199,7 +199,7 @@ public class ShowActionTest {
 
   private void insertJsonExampleComponentsAndSnapshots() {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
-    ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW")
+    ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW")
       .setKey("com.sonarsource:java-markdown")
       .setName("Java Markdown")
       .setDescription("Java Markdown Project")
index 398f1f42292a477e061b989694eda35398fa1336..c5ad241179594d3c312d851197a8d06605f575bb 100644 (file)
@@ -59,13 +59,13 @@ import static org.assertj.core.groups.Tuple.tuple;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.component.index.ComponentIndexQuery.DEFAULT_LIMIT;
 import static org.sonar.server.component.ws.SuggestionsAction.EXTENDED_LIMIT;
-import static org.sonar.server.component.ws.SuggestionsAction.SHORT_INPUT_WARNING;
 import static org.sonar.server.component.ws.SuggestionsAction.PARAM_MORE;
 import static org.sonar.server.component.ws.SuggestionsAction.PARAM_QUERY;
 import static org.sonar.server.component.ws.SuggestionsAction.PARAM_RECENTLY_BROWSED;
+import static org.sonar.server.component.ws.SuggestionsAction.SHORT_INPUT_WARNING;
 import static org.sonarqube.ws.WsComponents.SuggestionsWsResponse.Category;
 import static org.sonarqube.ws.WsComponents.SuggestionsWsResponse.Organization;
 
@@ -113,7 +113,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void exact_match_in_one_qualifier() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
 
     componentIndexer.indexOnStartup(null);
     authorizationIndexerTester.allowOnlyAnyone(project);
@@ -138,7 +138,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void must_not_search_if_no_valid_tokens_are_provided() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization).setName("SonarQube"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("SonarQube"));
 
     componentIndexer.indexOnStartup(null);
     authorizationIndexerTester.allowOnlyAnyone(project);
@@ -167,11 +167,11 @@ public class SuggestionsActionTest {
     OrganizationDto organization1 = db.organizations().insert(o -> o.setKey("org-1").setName("Organization One"));
     OrganizationDto organization2 = db.organizations().insert(o -> o.setKey("org-2").setName("Organization Two"));
 
-    ComponentDto project1 = db.components().insertComponent(newProjectDto(organization1).setName("Project1"));
+    ComponentDto project1 = db.components().insertComponent(newPrivateProjectDto(organization1).setName("Project1"));
     componentIndexer.indexProject(project1.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION);
     authorizationIndexerTester.allowOnlyAnyone(project1);
 
-    ComponentDto project2 = db.components().insertComponent(newProjectDto(organization2).setName("Project2"));
+    ComponentDto project2 = db.components().insertComponent(newPrivateProjectDto(organization2).setName("Project2"));
     componentIndexer.indexProject(project2.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION);
     authorizationIndexerTester.allowOnlyAnyone(project2);
 
@@ -189,7 +189,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void should_contain_project_names() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
     db.components().insertComponent(newModuleDto(project).setName("Module1"));
     db.components().insertComponent(newModuleDto(project).setName("Module2"));
     componentIndexer.indexProject(project.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION);
@@ -213,7 +213,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void should_mark_recently_browsed_items() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
     ComponentDto module1 = newModuleDto(project).setName("Module1");
     db.components().insertComponent(module1);
     ComponentDto module2 = newModuleDto(project).setName("Module2");
@@ -235,7 +235,7 @@ public class SuggestionsActionTest {
 
   @Test
   public void should_mark_favorite_items() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
     ComponentDto favorite = newModuleDto(project).setName("Module1");
     db.components().insertComponent(favorite);
     doReturn(singletonList(favorite)).when(favoriteFinder).list();
@@ -280,7 +280,7 @@ public class SuggestionsActionTest {
     String namePrefix = "MyProject";
 
     List<ComponentDto> projects = range(0, numberOfProjects)
-      .mapToObj(i -> db.components().insertComponent(newProjectDto(organization).setName(namePrefix + i)))
+      .mapToObj(i -> db.components().insertComponent(newPrivateProjectDto(organization).setName(namePrefix + i)))
       .collect(Collectors.toList());
 
     componentIndexer.indexOnStartup(null);
index 6e83228d6187bcc1908d0daf050f0b1f65727f34..72cad52a3300f1a3d04370a94c25ffeca6dfba2b 100644 (file)
@@ -60,7 +60,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT_ID;
@@ -104,7 +104,7 @@ public class TreeActionTest {
 
   @Test
   public void return_children() throws IOException {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto("module-uuid-1", project);
     componentDb.insertComponent(module);
@@ -134,7 +134,7 @@ public class TreeActionTest {
 
   @Test
   public void return_descendants() throws IOException {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto("module-uuid-1", project);
     componentDb.insertComponent(module);
@@ -164,7 +164,7 @@ public class TreeActionTest {
 
   @Test
   public void filter_descendants_by_qualifier() throws IOException {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     componentDb.insertComponent(newFileDto(project, 1));
     componentDb.insertComponent(newFileDto(project, 2));
@@ -182,7 +182,7 @@ public class TreeActionTest {
 
   @Test
   public void return_leaves() throws IOException {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     ComponentDto module = newModuleDto("module-uuid-1", project);
     componentDb.insertComponent(module);
@@ -206,7 +206,7 @@ public class TreeActionTest {
 
   @Test
   public void sort_descendants_by_qualifier() throws IOException {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     componentDb.insertComponent(newFileDto(project, 1));
     componentDb.insertComponent(newFileDto(project, 2));
@@ -229,7 +229,7 @@ public class TreeActionTest {
     OrganizationDto organizationDto = db.organizations().insert();
     ComponentDto view = newView(organizationDto, "view-uuid");
     componentDb.insertViewAndSnapshot(view);
-    ComponentDto project = newProjectDto(organizationDto, "project-uuid-1").setName("project-name").setKey("project-key-1");
+    ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid-1").setName("project-name").setKey("project-key-1");
     componentDb.insertProjectAndSnapshot(project);
     componentDb.insertComponent(newProjectCopy("project-uuid-1-copy", project, view));
     componentDb.insertComponent(newSubView(view, "sub-view-uuid", "sub-view-key").setName("sub-view-name"));
@@ -248,7 +248,7 @@ public class TreeActionTest {
 
   @Test
   public void response_is_empty_on_provisioned_projects() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     logInWithBrowsePermission(project);
 
     TreeWsResponse response = ws.newRequest()
@@ -263,7 +263,7 @@ public class TreeActionTest {
 
   @Test
   public void return_projects_composing_a_view() {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid");
     componentDb.insertProjectAndSnapshot(project);
     ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid");
     componentDb.insertViewAndSnapshot(view);
@@ -280,7 +280,7 @@ public class TreeActionTest {
 
   @Test
   public void fail_when_not_enough_privileges() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid"));
+    ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
     userSession.logIn()
       .addProjectPermission(UserRole.CODEVIEWER, project);
     db.commit();
@@ -296,7 +296,7 @@ public class TreeActionTest {
   public void fail_when_page_size_above_500() {
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("The 'ps' parameter must be less than 500");
-    componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     db.commit();
 
     ws.newRequest()
@@ -309,7 +309,7 @@ public class TreeActionTest {
   public void fail_when_search_query_has_less_than_3_characters() {
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("The 'q' parameter must have at least 3 characters");
-    componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid"));
+    componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
     db.commit();
 
     ws.newRequest()
@@ -321,7 +321,7 @@ public class TreeActionTest {
   @Test
   public void fail_when_sort_is_unknown() {
     expectedException.expect(IllegalArgumentException.class);
-    componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     db.commit();
 
     ws.newRequest()
@@ -333,7 +333,7 @@ public class TreeActionTest {
   @Test
   public void fail_when_strategy_is_unknown() {
     expectedException.expect(IllegalArgumentException.class);
-    componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid"));
+    componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
     db.commit();
 
     ws.newRequest()
@@ -372,7 +372,7 @@ public class TreeActionTest {
 
   private ComponentDto initJsonExampleComponents() throws IOException {
     OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
-    ComponentDto project = newProjectDto(organizationDto, "MY_PROJECT_ID")
+    ComponentDto project = newPrivateProjectDto(organizationDto, "MY_PROJECT_ID")
       .setKey("MY_PROJECT_KEY")
       .setName("Project Name");
     componentDb.insertProjectAndSnapshot(project);
index 89b050617864670acbbfc9897ddd5d8785acba0c..73ca3e90a9d5de6ee31bdb6d2311724ae77fe0c5 100644 (file)
@@ -58,7 +58,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.OrganizationPermission.SCAN;
 
@@ -103,7 +103,7 @@ public class ReportSubmitterTest {
   public void submit_fails_with_organizationKey_does_not_match_organization_of_specified_component() {
     userSession.logIn().setRoot();
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     mockSuccessfulPrepareSubmitCall();
 
     underTest.submit(organization.getKey(), project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
@@ -111,7 +111,7 @@ public class ReportSubmitterTest {
 
   @Test
   public void submit_a_report_on_existing_project() {
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     userSession.logIn().addProjectPermission(SCAN_EXECUTION, project);
 
     mockSuccessfulPrepareSubmitCall();
@@ -143,7 +143,7 @@ public class ReportSubmitterTest {
       .addPermission(PROVISION_PROJECTS, organization);
 
     mockSuccessfulPrepareSubmitCall();
-    ComponentDto createdProject = newProjectDto(organization, PROJECT_UUID).setKey(PROJECT_KEY);
+    ComponentDto createdProject = newPrivateProjectDto(organization, PROJECT_UUID).setKey(PROJECT_KEY);
     when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(createdProject);
     when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(organization.getUuid()), anyInt(), anyString(),
       eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
@@ -174,7 +174,7 @@ public class ReportSubmitterTest {
       .addPermission(PROVISION_PROJECTS, db.getDefaultOrganization());
 
     mockSuccessfulPrepareSubmitCall();
-    ComponentDto createdProject = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
+    ComponentDto createdProject = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
     when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(createdProject);
     when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(defaultOrganizationUuid), anyInt(), anyString(),
       eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
@@ -193,7 +193,7 @@ public class ReportSubmitterTest {
       .addPermission(PROVISION_PROJECTS, db.getDefaultOrganization());
 
     mockSuccessfulPrepareSubmitCall();
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
     when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(project);
     when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(defaultOrganizationUuid), anyInt(), anyString(),
       eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
@@ -207,7 +207,7 @@ public class ReportSubmitterTest {
   @Test
   public void user_with_scan_permission_on_organization_is_allowed_to_submit_a_report_on_existing_project() {
     OrganizationDto org = db.organizations().insert();
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     userSession.addPermission(SCAN, org);
 
     mockSuccessfulPrepareSubmitCall();
@@ -219,7 +219,7 @@ public class ReportSubmitterTest {
 
   @Test
   public void submit_a_report_on_existing_project_with_project_scan_permission() {
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     userSession.addProjectPermission(SCAN_EXECUTION, project);
 
     mockSuccessfulPrepareSubmitCall();
@@ -238,7 +238,7 @@ public class ReportSubmitterTest {
 
   @Test
   public void fail_with_forbidden_exception_on_new_project_when_only_project_scan_permission() {
-    userSession.addProjectPermission(SCAN_EXECUTION, ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
+    userSession.addProjectPermission(SCAN_EXECUTION, ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
 
     mockSuccessfulPrepareSubmitCall();
     when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(new ComponentDto().setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
@@ -252,12 +252,12 @@ public class ReportSubmitterTest {
    */
   @Test
   public void project_branch_must_not_benefit_from_the_scan_permission_on_main_project() {
-    ComponentDto mainProject = db.components().insertProject();
+    ComponentDto mainProject = db.components().insertPrivateProject();
     userSession.addProjectPermission(GlobalPermissions.SCAN_EXECUTION, mainProject);
 
     // user does not have the "scan" permission on the branch, so it can't scan it
     String branchName = "branchFoo";
-    ComponentDto branchProject = db.components().insertProject(p -> p.setKey(mainProject.getKey() + ":" + branchName));
+    ComponentDto branchProject = db.components().insertPrivateProject(p -> p.setKey(mainProject.getKey() + ":" + branchName));
 
     thrown.expect(ForbiddenException.class);
     underTest.submit(defaultOrganizationKey, mainProject.key(), branchName, PROJECT_NAME, IOUtils.toInputStream("{binary}"));
index 3d501650feba9eab828db1be85704e11e3ebcd2a..9f24e9b29e25cd1f11f3e91bf09853fdf36dcd20 100644 (file)
@@ -76,7 +76,7 @@ public class SettingsRepositoryTest {
 
   @Test
   public void get_project_settings_from_db() {
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
     dbClient.componentDao().insert(session, project);
     dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"));
     session.commit();
index 2dbe1d5d3d9340e40dac0905d8d531a4198d871a..89c69ce0d8612c64639368d0331b1ab7e7b158bc 100644 (file)
@@ -276,7 +276,7 @@ public class IntegrateIssuesVisitorTest {
   }
 
   private void addBaseIssue(RuleKey ruleKey) {
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY);
     ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, file);
 
index f143ae6250e7bb0e7d88ff4f631785d3ccc79f84..02dc51461cde4c34f38d4fdea62103ec0590f755 100644 (file)
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.DIRECTORY;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
@@ -170,7 +170,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void return_existing_uuids() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
     ComponentDto module = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY));
     ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_KEY_1);
     insertComponent(directory.setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
@@ -250,7 +250,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void return_existing_uuids_when_components_were_removed() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
     ComponentDto removedModule = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY).setEnabled(false));
     ComponentDto removedDirectory = insertComponent(newDirectory(removedModule, "CDEF", REPORT_DIR_KEY_1).setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1).setEnabled(false));
     insertComponent(newFileDto(removedModule, removedDirectory, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
@@ -281,7 +281,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void set_no_base_project_snapshot_when_no_last_snapshot() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(false));
 
     reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
@@ -293,7 +293,7 @@ public class BuildComponentTreeStepTest {
   @Test
   public void set_base_project_snapshot_when_last_snapshot_exist() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+    ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(true));
 
     reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
index a16aa7fef42d51bc659b93c935542b9c3c5cd4d9..e191c7f93d7eda2de936eaa63c03bb1e5683a919 100644 (file)
@@ -56,7 +56,7 @@ public class EnableAnalysisStepTest {
   @Test
   public void switch_islast_flag_and_mark_analysis_as_processed() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = ComponentTesting.newProjectDto(organization, REPORT_PROJECT.getUuid());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organization, REPORT_PROJECT.getUuid());
     db.getDbClient().componentDao().insert(db.getSession(), project);
     insertAnalysis(project, PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
     insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false);
@@ -72,7 +72,7 @@ public class EnableAnalysisStepTest {
 
   @Test
   public void set_islast_flag_and_mark_as_processed_if_no_previous_analysis() {
-    ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), REPORT_PROJECT.getUuid());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), REPORT_PROJECT.getUuid());
     db.getDbClient().componentDao().insert(db.getSession(), project);
     insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false);
     db.commit();
index 3e656a2b1ea7db32171b8453fa8c550506e76ba5..d9e9bdb33af9051b858b3f04a1842e73942b44cd 100644 (file)
@@ -108,7 +108,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
 
   @Before
   public void setUp() throws Exception {
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert());
     dbClient.componentDao().insert(dbSession, project);
     SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
     dbClient.snapshotDao().insert(dbSession, projectSnapshot);
@@ -326,7 +326,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
   }
 
   private ComponentDto createProject(String projectKey) {
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(projectKey);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(projectKey);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
     return project;
index 760f975e9d2a4d7d73112e52548b2149f591c8a7..1612e0d333c9592f29893bfe1243be22e1344fae 100644 (file)
@@ -98,7 +98,7 @@ public class PersistIssuesStepTest extends BaseStepTest {
     RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
     dbTester.rules().insert(rule);
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     dbClient.componentDao().insert(session, project);
     ComponentDto file = ComponentTesting.newFileDto(project, null);
     dbClient.componentDao().insert(session, file);
index f96fce3ca7e13d2b4aaf6c9fbe35f38f5c17de27..fcf989d508299587684457ad31420c8f536f9196 100644 (file)
@@ -86,7 +86,7 @@ public class ReportComputeMeasureVariationsStepTest {
 
   @Before
   public void setUp() {
-    project = dbTester.components().insertProject(dbTester.organizations().insert(), PROJECT_UUID);
+    project = dbTester.components().insertPrivateProject(dbTester.organizations().insert(), PROJECT_UUID);
   }
 
   @Test
index f832b216f79bb15a7304a0510529b45260964b19..ecbadf519574cf5fd2b8d7a6290b2de00ae51102 100644 (file)
@@ -99,7 +99,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
   @Test
   public void persist_analysis() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
     ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
     dbClient.componentDao().insert(dbTester.getSession(), moduleDto);
@@ -141,7 +141,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
   @Test
   public void persist_snapshots_with_leak_period() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
     SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
     dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
@@ -165,7 +165,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1"));
 
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
     SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
     dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
@@ -200,7 +200,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
   @Test
   public void set_no_period_on_snapshots_when_no_period() {
-    ComponentDto projectDto = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), projectDto);
     SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto);
     dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
index 48558fc203e2a996dcfcb52032d37047fc35dde4..4e2b40940bc46064fb1158bceda2f571e48a7bcd 100644 (file)
@@ -52,7 +52,7 @@ import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
 import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.FILE;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
@@ -240,7 +240,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persist_only_new_components() {
     // Project and module already exists
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -394,7 +394,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void nothing_to_persist() {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -469,7 +469,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void update_module_name_and_description() {
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description");
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -508,7 +508,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void update_module_path() {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path");
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -535,7 +535,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void update_module_uuid_when_moving_a_module() {
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project)
       .setKey("MODULE_A")
@@ -612,7 +612,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void do_not_update_created_at_on_existing_component() {
     Date oldDate = DateUtils.parseDate("2015-01-01");
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate);
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate);
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path").setCreatedAt(oldDate);
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -630,7 +630,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void persist_components_that_were_previously_removed() {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project)
       .setKey(MODULE_KEY)
@@ -732,7 +732,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void update_module_uuid_when_reactivating_removed_component() {
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
     dbClient.componentDao().insert(dbTester.getSession(), project);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
     ComponentDto removedModule = ComponentTesting.newModuleDto("EDCD", project).setKey("REMOVED_MODULE_KEY").setName("Removed Module").setEnabled(false);
@@ -798,7 +798,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
     OrganizationDto organization = dbTester.organizations().insert();
-    ComponentDto project = newProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
+    ComponentDto project = newPrivateProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(project);
     treeRootHolder.setRoot(createSampleProjectComponentTree(project));
 
@@ -814,7 +814,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
     OrganizationDto organization = dbTester.organizations().insert();
-    ComponentDto project = newProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
+    ComponentDto project = newPrivateProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(project);
     ComponentDto module = newModuleDto(project).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
     dbTester.components().insertComponent(module);
index 7e1c6c2bebbcbb236eca7aeabc6f80ceea501eb7..082456cde60f8c27f5bf750c4616544069194ef5 100644 (file)
@@ -159,7 +159,7 @@ public class ValidateProjectStepTest {
       .setKey(MODULE_KEY)
       .build());
 
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(MODULE_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(MODULE_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), project);
     dbTester.getSession().commit();
 
@@ -192,8 +192,8 @@ public class ValidateProjectStepTest {
       .build());
 
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY);
-    ComponentDto anotherProject = ComponentTesting.newProjectDto(organizationDto).setKey(anotherProjectKey);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY);
+    ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(organizationDto).setKey(anotherProjectKey);
     dbClient.componentDao().insert(dbTester.getSession(), project, anotherProject);
     ComponentDto module = ComponentTesting.newModuleDto("BCDE", anotherProject).setKey(MODULE_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -226,7 +226,7 @@ public class ValidateProjectStepTest {
       .setKey(MODULE_KEY)
       .build());
 
-    ComponentDto anotherProject = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(anotherProjectKey);
+    ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(anotherProjectKey);
     dbClient.componentDao().insert(dbTester.getSession(), anotherProject);
     ComponentDto module = ComponentTesting.newModuleDto("ABCD", anotherProject).setKey(PROJECT_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), module);
@@ -255,7 +255,7 @@ public class ValidateProjectStepTest {
       .addChildRef(2)
       .build());
 
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), project);
     dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1420088400000L)); // 2015-01-01
     dbTester.getSession().commit();
@@ -276,7 +276,7 @@ public class ValidateProjectStepTest {
       .addChildRef(2)
       .build());
 
-    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), project);
     dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1433131200000L)); // 2015-06-01
     dbTester.getSession().commit();
index 79b1f93649a37fb1450966ca13177324c59a71fe..be55fe07d57acc6733b71441bb752a0ff9934702 100644 (file)
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
@@ -99,7 +99,7 @@ public class ViewsPersistAnalysisStepTest extends BaseStepTest {
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW"));
     save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
-    save(newProjectDto(organizationDto, "proj"));
+    save(newPrivateProjectDto(organizationDto, "proj"));
     dbTester.getSession().commit();
 
     Component projectView = ViewsComponent.builder(PROJECT_VIEW, "KEY_PROJECT_COPY").setUuid("UUID_PROJECT_COPY").build();
index b230172d5097c81d7b817e0cb9925d5db55b3e86..cc0d1a52f1d618b5fc74dc5498f9fd6ab67fc928 100644 (file)
@@ -50,7 +50,7 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -133,7 +133,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void persist_view_with_projectView() {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert());
     persistComponents(project);
 
     treeRootHolder.setRoot(
@@ -227,7 +227,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void persist_project_view_under_subview() {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert());
     persistComponents(project);
 
     treeRootHolder.setRoot(
@@ -273,7 +273,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   public void update_project_view() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto view = newViewDto(organizationDto);
-    ComponentDto project = newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     persistComponents(view, project);
     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view)
       .setOrganizationUuid(ORGANIZATION_UUID)
@@ -302,8 +302,8 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   public void update_copy_component_uuid_of_project_view() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto view = newViewDto(organizationDto);
-    ComponentDto project1 = newProjectDto(organizationDto, "P1");
-    ComponentDto project2 = newProjectDto(organizationDto, "P2");
+    ComponentDto project1 = newPrivateProjectDto(organizationDto, "P1");
+    ComponentDto project2 = newPrivateProjectDto(organizationDto, "P2");
     persistComponents(view, project1, project2);
 
     // Project view in DB is associated to project1
@@ -354,7 +354,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
 
   @Test
   public void persists_new_components_as_public_if_root_does_not_exist_yet_out_of_functional_transaction() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     treeRootHolder.setRoot(
       createViewBuilder()
         .addChildren(
@@ -373,7 +373,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     OrganizationDto organization = dbTester.organizations().insert();
     ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(view);
@@ -397,7 +397,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     boolean isRootPrivate = new Random().nextBoolean();
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     OrganizationDto organization = dbTester.organizations().insert();
     ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
     dbTester.components().insertComponent(view);
index fccbd49727ffa8b16b5dec5db15418afc0072699..d51dcc4397cb7f1c8bc6d772e37fa5224b39398a 100644 (file)
@@ -59,7 +59,7 @@ public class DuplicationsJsonWriterTest {
 
   @Before
   public void setUp() {
-    project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto())
+    project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto())
       .setId(1L)
       .setName("SonarQube")
       .setLongName("SonarQube")
index ebd6b06f9160ad07fa5f2c866d5b04f71031ad33..2a38b5607dd67a36bb8aa5ed9bcaa00188d12d83 100644 (file)
@@ -36,11 +36,11 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 
 public class DuplicationsParserTest {
@@ -66,11 +66,11 @@ public class DuplicationsParserTest {
   @Before
   public void setUp() {
     organizationDto = db.organizations().insert();
-    project1 = newProjectDto(organizationDto)
+    project1 = ComponentTesting.newPrivateProjectDto(organizationDto)
       .setName("SonarQube")
       .setLongName("SonarQube")
       .setKey("org.codehaus.sonar:sonar");
-    project2 = newProjectDto(organizationDto);
+    project2 = ComponentTesting.newPrivateProjectDto(organizationDto);
     componentDao.insert(dbSession, project1, project2);
 
     // Current file
@@ -213,7 +213,7 @@ public class DuplicationsParserTest {
     assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 5, 2), new DuplicationsParser.Duplication(fileOnDifferentProject, 2, 2))).isEqualTo(-1);
     assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(1);
     // Files on 2 different projects
-    ComponentDto project3 = newProjectDto(organizationDto).setId(3L);
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setId(3L);
     assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2),
       new DuplicationsParser.Duplication(project3, 2, 2))).isEqualTo(1);
 
index e6cacf51b6e3ba72e41301e19c74209099796018..44e68849ebe1e68614af714a516857ce373cd4c8 100644 (file)
@@ -79,7 +79,7 @@ public class ShowActionTest {
 
   @Test
   public void return_file_with_missing_duplication_data() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
     db.components().insertSnapshot(newAnalysis(project));
 
@@ -102,7 +102,7 @@ public class ShowActionTest {
 
   @Test
   public void return_403_if_user_is_not_allowed_to_access_project() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
     expectedException.expect(ForbiddenException.class);
@@ -115,7 +115,7 @@ public class ShowActionTest {
   }
 
   private void verifyCallToFileWithDuplications(Function<ComponentDto, WsTester.TestRequest> requestFactory) throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
     SnapshotDto snapshot = db.components().insertSnapshot(newAnalysis(project));
     String xml = "<duplications>\n" +
index 604149dad97b136389f64315c382a0802e1b174f..b99b2eae02f69d58cc6f0c71f86adceb4abf6fcf 100644 (file)
@@ -27,17 +27,17 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationTesting;
 import org.sonar.db.property.PropertyQuery;
 import org.sonar.server.exceptions.BadRequestException;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 public class FavoriteUpdaterTest {
   private static final long COMPONENT_ID = 23L;
   private static final String COMPONENT_KEY = "K1";
-  private static final ComponentDto COMPONENT = newProjectDto(OrganizationTesting.newOrganizationDto())
+  private static final ComponentDto COMPONENT = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto())
     .setId(COMPONENT_ID)
     .setKey(COMPONENT_KEY);
   private static final int USER_ID = 42;
index 84130b7b27733644c25f1c92d7211c5436567f7e..5277adc84b695c0ae4a657f511b606d3f62d3cd7 100644 (file)
@@ -46,7 +46,7 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT;
 
 public class AddActionTest {
@@ -142,7 +142,7 @@ public class AddActionTest {
   }
 
   private ComponentDto insertProject() {
-    return db.components().insertComponent(newProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
+    return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
   }
 
   private ComponentDto insertProjectAndPermissions() {
index 584ab17cdb8189f18803119e55d2090f03581121..f23f571b5c81deda613ffcf12972694f44b1839c 100644 (file)
@@ -41,7 +41,7 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT;
 
 public class RemoveActionTest {
@@ -112,7 +112,7 @@ public class RemoveActionTest {
   }
 
   private ComponentDto insertProject() {
-    return db.components().insertComponent(newProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
+    return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
   }
 
   private ComponentDto insertProjectAndPermissions() {
index 08559dcdc965579ee23b885845cd86602008d54b..0b5f908c9ecabcc1edaaa0c6e3dc54f81ac396a8 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.permission.UserPermissionDto;
 import org.sonar.server.exceptions.UnauthorizedException;
@@ -48,7 +49,7 @@ import static org.sonar.api.resources.Qualifiers.FILE;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.WsRequest.Method.POST;
 
@@ -69,10 +70,10 @@ public class SearchActionTest {
 
   @Test
   public void return_favorites() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "P1").setKey("K1").setName("N1");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "P1").setKey("K1").setName("N1");
     addComponent(project);
     addComponent(newFileDto(project).setKey("K11").setName("N11"));
-    addComponent(newProjectDto(db.getDefaultOrganization(), "P2").setKey("K2").setName("N2"));
+    addComponent(newPrivateProjectDto(db.getDefaultOrganization(), "P2").setKey("K2").setName("N2"));
 
     SearchResponse result = call();
 
@@ -98,8 +99,8 @@ public class SearchActionTest {
   @Test
   public void filter_authorized_components() {
     OrganizationDto organizationDto = db.organizations().insert();
-    addComponent(newProjectDto(organizationDto).setKey("K1"));
-    ComponentDto unauthorizedProject = db.components().insertComponent(newProjectDto(organizationDto));
+    addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1"));
+    ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
     db.favorites().add(unauthorizedProject, USER_ID);
 
     SearchResponse result = call();
@@ -111,8 +112,8 @@ public class SearchActionTest {
   @Test
   public void paginate_results() {
     IntStream.rangeClosed(1, 9)
-      .forEach(i -> addComponent(newProjectDto(db.getDefaultOrganization()).setKey("K" + i).setName("N" + i)));
-    ComponentDto unauthorizedProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization()));
+      .forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("K" + i).setName("N" + i)));
+    ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     db.favorites().add(unauthorizedProject, USER_ID);
 
     SearchResponse result = call(2, 3);
@@ -127,8 +128,8 @@ public class SearchActionTest {
   @Test
   public void return_only_users_favorite() {
     OrganizationDto organizationDto = db.organizations().insert();
-    addComponent(newProjectDto(organizationDto).setKey("K1"));
-    ComponentDto otherUserFavorite = newProjectDto(organizationDto).setKey("K42");
+    addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1"));
+    ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K42");
     db.components().insertComponent(otherUserFavorite);
     db.favorites().add(otherUserFavorite, 42);
     dbClient.userPermissionDao().insert(dbSession, new UserPermissionDto(organizationDto.getUuid(), UserRole.USER, 42, otherUserFavorite.getId()));
@@ -142,9 +143,9 @@ public class SearchActionTest {
   @Test
   public void favorites_ordered_by_name() {
     OrganizationDto organizationDto = db.organizations().insert();
-    addComponent(newProjectDto(organizationDto).setName("N2"));
-    addComponent(newProjectDto(organizationDto).setName("N3"));
-    addComponent(newProjectDto(organizationDto).setName("N1"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N2"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N3"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N1"));
 
     SearchResponse result = call();
 
@@ -156,9 +157,9 @@ public class SearchActionTest {
   public void json_example() {
     OrganizationDto organization1 = db.organizations().insertForKey("my-org");
     OrganizationDto organization2 = db.organizations().insertForKey("openjdk");
-    addComponent(newProjectDto(organization1).setKey("K1").setName("Samba"));
-    addComponent(newProjectDto(organization1).setKey("K2").setName("Apache HBase"));
-    addComponent(newProjectDto(organization2).setKey("K3").setName("JDK9"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organization1).setKey("K1").setName("Samba"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organization1).setKey("K2").setName("Apache HBase"));
+    addComponent(ComponentTesting.newPrivateProjectDto(organization2).setKey("K3").setName("JDK9"));
 
     String result = ws.newRequest().execute().getInput();
 
index 2d3ea708c08f93a3c06e4a5ab934de1e9f349799..78a2b6a7afdcf4733020cdaf1ee5e44dbe903158 100644 (file)
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
 import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.issue.IssueTesting.newDto;
 import static org.sonar.db.rule.RuleTesting.newXooX1;
 
@@ -49,7 +49,7 @@ public class ActionFinderTest {
   @Rule
   public UserSessionRule userSession = UserSessionRule.standalone().logIn("arthur");
 
-  private ComponentDto project = newProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setKey(PROJECT_KEY);
+  private ComponentDto project = newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setKey(PROJECT_KEY);
   private IssueDto issue = newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY);
 
   private ActionFinder underTest = new ActionFinder(userSession);
@@ -61,7 +61,7 @@ public class ActionFinderTest {
 
   @Test
   public void return_provided_actions_with_set_severity_and_set_type_when_issue_admin() {
-    userSession.addProjectPermission(ISSUE_ADMIN, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID));
+    userSession.addProjectPermission(ISSUE_ADMIN, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID));
     assertThat(underTest.listAvailableActions(issue)).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "set_severity");
   }
 
index f78180328ead7878df104e54e791f903dea47afd..03249bdce5210306a849271fc05d153948ff6799 100644 (file)
@@ -67,7 +67,7 @@ public class AssignActionTest {
   @Before
   public void setUp() throws Exception {
     issueOrganizationDto = db.organizations().insert();
-    project = db.components().insertProject(issueOrganizationDto);
+    project = db.components().insertPrivateProject(issueOrganizationDto);
     context = new BulkChangeAction.ActionContext(issue, issueChangeContext, project);
   }
 
index bc3f00546e364d38e623917123e58f5130417363..0ece0b05dec320eb0e1da59308fc5031b8adf880 100644 (file)
@@ -91,7 +91,7 @@ public class IssueFinderTest {
 
   private IssueDto insertIssue() {
     RuleDto rule = ruleDbTester.insertRule(newRuleDto());
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
     return issueDbTester.insertIssue(newDto(rule, file, project));
   }
index 7f2c1285656f1e944d7773acb52f9a72163cd09e..3f2a897ab74c9a73607a86bee90cd7e047f522b4 100644 (file)
@@ -58,7 +58,7 @@ public class IssueQueryFactoryTest {
   @Test
   public void create_from_parameters() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
 
@@ -176,7 +176,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void fail_if_componentRoots_references_components_with_different_qualifier() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
     SearchWsRequest request = new SearchWsRequest()
       .setComponentRoots(asList(project.key(), file.key()));
@@ -214,7 +214,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void param_componentUuids_enables_search_on_project_tree_by_default() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SearchWsRequest request = new SearchWsRequest()
       .setComponentUuids(asList(project.uuid()));
 
@@ -225,7 +225,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void onComponentOnly_restricts_search_to_specified_componentKeys() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SearchWsRequest request = new SearchWsRequest()
       .setComponentKeys(asList(project.key()))
       .setOnComponentOnly(true);
@@ -239,7 +239,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void should_search_in_tree_with_module_uuid() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
     SearchWsRequest request = new SearchWsRequest()
       .setComponentUuids(asList(module.uuid()));
@@ -251,7 +251,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void param_componentUuids_enables_search_in_directory_tree() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo"));
     SearchWsRequest request = new SearchWsRequest()
       .setComponentUuids(asList(dir.uuid()));
@@ -265,7 +265,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void param_componentUuids_enables_search_by_file() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
     SearchWsRequest request = new SearchWsRequest()
       .setComponentUuids(asList(file.uuid()));
@@ -277,7 +277,7 @@ public class IssueQueryFactoryTest {
 
   @Test
   public void param_componentUuids_enables_search_by_test_file() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setQualifier(Qualifiers.UNIT_TEST_FILE));
     SearchWsRequest request = new SearchWsRequest()
       .setComponentUuids(asList(file.uuid()));
index 6a24e75d3b6da1838b506f07dc1bd030e25ffde1..aca5eac53284d6ae014b1b90d9e17e5e7f2bb664 100644 (file)
@@ -152,7 +152,7 @@ public class IssueServiceMediumTest {
   private ComponentDto newProject() {
     OrganizationDto organization = OrganizationTesting.newOrganizationDto();
     tester.get(OrganizationDao.class).insert(session, organization);
-    ComponentDto project = ComponentTesting.newProjectDto(organization);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organization);
     tester.get(ComponentDao.class).insert(session, project);
 
     userSessionRule.logIn().addProjectPermission(UserRole.USER, project);
index 162df25f04f2dafecfdbd0f0090d966dfdc45bc8..ec05df31ecabaa4afb52aac216e83ab5f4d40b28 100644 (file)
@@ -98,7 +98,7 @@ public class IssueUpdaterTest {
   @Test
   public void verify_notification() throws Exception {
     RuleDto rule = ruleDbTester.insertRule(newRuleDto());
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
     DefaultIssue issue = issueDbTester.insertIssue(newDto(rule, file, project)).setSeverity(MAJOR).toDefaultIssue();
     IssueChangeContext context = IssueChangeContext.createUser(new Date(), "john");
@@ -123,7 +123,7 @@ public class IssueUpdaterTest {
   @Test
   public void verify_notification_when_issue_is_linked_on_removed_rule() throws Exception {
     RuleDto rule = ruleDbTester.insertRule(newRuleDto().setStatus(RuleStatus.REMOVED));
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
     DefaultIssue issue = issueDbTester.insertIssue(newDto(rule, file, project)).setSeverity(MAJOR).toDefaultIssue();
     IssueChangeContext context = IssueChangeContext.createUser(new Date(), "john");
@@ -137,7 +137,7 @@ public class IssueUpdaterTest {
 
   private IssueDto newIssue() {
     RuleDto rule = ruleDbTester.insertRule(newRuleDto());
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
     return newDto(rule, file, project);
   }
index 15a80439331df3c136b7341154c8056e8eb82bb8..d45f92ae2b22a7bdcf3443fa31711de43d9a568f 100644 (file)
@@ -122,7 +122,7 @@ public class SetSeverityActionTest {
 
   private IssueDto newIssue() {
     RuleDto rule = db.rules().insertRule(newRuleDto());
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     return newDto(rule, file, project);
   }
index f08d793deb8fd7529a5b4b52c443b560ee9df602..05a4f20fed6b94696e049bb9076f95d1cdaf54b3 100644 (file)
@@ -129,7 +129,7 @@ public class SetTypeActionTest {
 
   private IssueDto newIssue() {
     RuleDto rule = db.rules().insertRule(newRuleDto());
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     return newDto(rule, file, project);
   }
index d73a3e066eecc5092fb003b0f12e18d3872b427a..ffbcaad285732f4a97b9c55b565d8a5feba43a46 100644 (file)
@@ -114,13 +114,13 @@ public class TransitionActionTest {
 
   private IssueDto newIssue() {
     RuleDto rule = newRuleDto().setId(10);
-    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto());
     ComponentDto file = (newFileDto(project));
     return newDto(rule, file, project);
   }
 
   private void loginAndAddProjectPermission(String login, String permission) {
-    userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), issue.projectUuid()));
+    userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), issue.projectUuid()));
   }
 
 }
index 68690ec21a97449939c2e1c43680c1259676e218..087a0cbe2da46c199f3763a8e59173a0f5fb79f2 100644 (file)
@@ -62,7 +62,7 @@ public class TransitionServiceTest {
   @Test
   public void list_transitions() throws Exception {
     IssueDto issue = newIssue().setStatus(STATUS_OPEN).setResolution(null);
-    userSession.logIn("john").addProjectPermission(ISSUE_ADMIN, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), issue.getProjectUuid()));
+    userSession.logIn("john").addProjectPermission(ISSUE_ADMIN, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), issue.getProjectUuid()));
 
     List<Transition> result = underTest.listTransitions(issue.toDefaultIssue());
 
@@ -100,7 +100,7 @@ public class TransitionServiceTest {
 
   private IssueDto newIssue() {
     RuleDto rule = newRuleDto().setId(10);
-    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto());
     ComponentDto file = (newFileDto(project));
     return newDto(rule, file, project);
   }
index 1baaaaaea91a5373e62a19a0f96b94d84e926944..06f24f830bcfb3359ca9318d9d36129b24471f04 100644 (file)
@@ -80,8 +80,8 @@ public class IssueIndexDebtTest {
   @Test
   public void facets_on_projects() {
     OrganizationDto organizationDto = newOrganizationDto();
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD");
-    ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto, "EFGH");
 
     indexIssues(
       IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L),
@@ -97,7 +97,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_components() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto(), "A");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto(), "A");
     ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD");
     ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE");
     ComponentDto file3 = ComponentTesting.newFileDto(project, null, "CDEF");
@@ -118,7 +118,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_directories() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
     ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo");
 
@@ -134,7 +134,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_severities() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     indexIssues(
@@ -150,7 +150,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_statuses() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     indexIssues(
@@ -166,7 +166,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_resolutions() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     indexIssues(
@@ -182,7 +182,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_languages() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
     RuleKey ruleKey = RuleKey.of("repo", "X1");
 
@@ -196,7 +196,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_assignees() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     indexIssues(
@@ -213,7 +213,7 @@ public class IssueIndexDebtTest {
 
   @Test
   public void facets_on_authors() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     indexIssues(
@@ -246,8 +246,8 @@ public class IssueIndexDebtTest {
   @Test
   public void deprecated_debt_facets() {
     OrganizationDto organizationDto = newOrganizationDto();
-    ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD");
-    ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto, "EFGH");
 
     indexIssues(
       IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L),
@@ -262,7 +262,7 @@ public class IssueIndexDebtTest {
   }
 
   protected SearchOptions fixtureForCreatedAtFacet() {
-    ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = ComponentTesting.newFileDto(project, null);
 
     IssueDoc issue0 = IssueDocTesting.newDoc("ISSUE0", file).setFuncCreationDate(DateUtils.parseDateTime("2011-04-25T01:05:13+0100"));
index 82937b7944ad2246799fb60867b570f69d6eab46..367da182d68fe167203b540d0646c5ec3a4b3448 100644 (file)
@@ -72,7 +72,7 @@ import static org.sonar.api.rules.RuleType.BUG;
 import static org.sonar.api.utils.DateUtils.parseDate;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 import static org.sonar.db.user.GroupTesting.newGroupDto;
 import static org.sonar.db.user.UserTesting.newUserDto;
@@ -109,7 +109,7 @@ public class IssueIndexTest {
 
   @Test
   public void get_by_key() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     IssueDoc issue = newDoc("ISSUE1", file)
       .setEffort(100L);
@@ -129,7 +129,7 @@ public class IssueIndexTest {
 
   @Test
   public void get_by_key_with_attributes() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     IssueDoc issue = newDoc("ISSUE1", file).setAttributes((KeyValueFormat.format(ImmutableMap.of("jira-issue-key", "SONAR-1234"))));
     indexIssues(issue);
@@ -140,7 +140,7 @@ public class IssueIndexTest {
 
   @Test(expected = IllegalStateException.class)
   public void comments_field_is_not_available() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     IssueDoc issue = newDoc("ISSUE1", file);
     indexIssues(issue);
@@ -151,7 +151,7 @@ public class IssueIndexTest {
 
   @Test(expected = IllegalStateException.class)
   public void is_new_field_is_not_available() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     IssueDoc issue = newDoc("ISSUE1", file);
     indexIssues(issue);
@@ -162,7 +162,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_keys() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
 
     indexIssues(
       newDoc("1", newFileDto(project, null)),
@@ -175,7 +175,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_projects() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto subModule = ComponentTesting.newModuleDto(module);
 
@@ -194,8 +194,8 @@ public class IssueIndexTest {
   @Test
   public void facets_on_projects() {
     OrganizationDto organizationDto = newOrganizationDto();
-    ComponentDto project = newProjectDto(organizationDto, "ABCD");
-    ComponentDto project2 = newProjectDto(organizationDto, "EFGH");
+    ComponentDto project = newPrivateProjectDto(organizationDto, "ABCD");
+    ComponentDto project2 = newPrivateProjectDto(organizationDto, "EFGH");
 
     indexIssues(
       newDoc("ISSUE1", newFileDto(project, null)),
@@ -209,7 +209,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_modules() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto subModule = ComponentTesting.newModuleDto(module);
     ComponentDto file = newFileDto(subModule, null);
@@ -242,7 +242,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_components_on_contextualized_search() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto subModule = ComponentTesting.newModuleDto(module);
     ComponentDto file1 = newFileDto(project, null);
@@ -277,7 +277,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_components_on_non_contextualized_search() {
-    ComponentDto project = newProjectDto(newOrganizationDto(), "project");
+    ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "project");
     ComponentDto file1 = newFileDto(project, null, "file1");
     ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("module");
     ComponentDto file2 = newFileDto(module, null, "file2");
@@ -308,7 +308,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_components() {
-    ComponentDto project = newProjectDto(newOrganizationDto(), "A");
+    ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "A");
     ComponentDto file1 = newFileDto(project, null, "ABCD");
     ComponentDto file2 = newFileDto(project, null, "BCDE");
     ComponentDto file3 = newFileDto(project, null, "CDEF");
@@ -328,7 +328,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_directories() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file1 = newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
     ComponentDto file2 = newFileDto(project, null).setPath("F2.xoo");
 
@@ -343,7 +343,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_directories() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file1 = newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
     ComponentDto file2 = newFileDto(project, null).setPath("F2.xoo");
 
@@ -359,9 +359,9 @@ public class IssueIndexTest {
   @Test
   public void filter_by_views() {
     OrganizationDto organizationDto = newOrganizationDto();
-    ComponentDto project1 = newProjectDto(organizationDto);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto);
     ComponentDto file1 = newFileDto(project1, null);
-    ComponentDto project2 = newProjectDto(organizationDto);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto);
     indexIssues(
       // Project1 has 2 issues (one on a file and one on the project itself)
       newDoc("ISSUE1", project1),
@@ -385,7 +385,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_severities() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -399,7 +399,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_severities() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -414,7 +414,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_statuses() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -429,7 +429,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_statuses() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -444,7 +444,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_resolutions() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -461,7 +461,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_resolutions() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -476,7 +476,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_resolved() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -491,7 +491,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_rules() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     RuleKey ruleKey = RuleKey.of("repo", "X1");
 
@@ -503,7 +503,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_languages() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     RuleKey ruleKey = RuleKey.of("repo", "X1");
 
@@ -516,7 +516,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_languages() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     RuleKey ruleKey = RuleKey.of("repo", "X1");
 
@@ -529,7 +529,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_assignees() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -544,7 +544,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_assignees() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -560,7 +560,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_assignees_supports_dashes() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -577,7 +577,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_assigned() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -592,7 +592,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_authors() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -607,7 +607,7 @@ public class IssueIndexTest {
 
   @Test
   public void facets_on_authors() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -623,7 +623,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_created_after() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -639,7 +639,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_created_before() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -655,7 +655,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_created_after_and_before() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -701,7 +701,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_create_after_and_before_take_into_account_timezone() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -748,7 +748,7 @@ public class IssueIndexTest {
 
   @Test
   public void filter_by_created_at() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")));
@@ -888,7 +888,7 @@ public class IssueIndexTest {
   }
 
   private SearchOptions fixtureForCreatedAtFacet() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     IssueDoc issue0 = newDoc("ISSUE0", file).setFuncCreationDate(parseDateTime("2011-04-25T00:05:13+0000"));
@@ -906,7 +906,7 @@ public class IssueIndexTest {
 
   @Test
   public void paging() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     for (int i = 0; i < 12; i++) {
       indexIssues(newDoc("ISSUE" + i, file));
@@ -929,7 +929,7 @@ public class IssueIndexTest {
 
   @Test
   public void search_with_max_limit() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     List<IssueDoc> issues = newArrayList();
     for (int i = 0; i < 500; i++) {
@@ -945,7 +945,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_status() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -968,7 +968,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_severity() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -997,7 +997,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_assignee() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -1019,7 +1019,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_creation_date() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -1041,7 +1041,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_update_date() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -1063,7 +1063,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_close_date() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
 
     indexIssues(
@@ -1088,7 +1088,7 @@ public class IssueIndexTest {
 
   @Test
   public void sort_by_file_and_line() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file1 = newFileDto(project, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo");
     ComponentDto file2 = newFileDto(project, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo");
 
@@ -1130,11 +1130,11 @@ public class IssueIndexTest {
   @Test
   public void default_sort_is_by_creation_date_then_project_then_file_then_line_then_issue_key() {
     OrganizationDto organizationDto = newOrganizationDto();
-    ComponentDto project1 = newProjectDto(organizationDto, "P1");
+    ComponentDto project1 = newPrivateProjectDto(organizationDto, "P1");
     ComponentDto file1 = newFileDto(project1, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo");
     ComponentDto file2 = newFileDto(project1, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo");
 
-    ComponentDto project2 = newProjectDto(organizationDto, "P2");
+    ComponentDto project2 = newPrivateProjectDto(organizationDto, "P2");
     ComponentDto file3 = newFileDto(project2, null, "F3").setPath("src/main/xoo/org/sonar/samples/File3.xoo");
 
     indexIssues(
@@ -1160,9 +1160,9 @@ public class IssueIndexTest {
   @Test
   public void authorized_issues_on_groups() {
     OrganizationDto org = newOrganizationDto();
-    ComponentDto project1 = newProjectDto(org);
-    ComponentDto project2 = newProjectDto(org);
-    ComponentDto project3 = newProjectDto(org);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org);
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file1 = newFileDto(project1, null);
     ComponentDto file2 = newFileDto(project2, null);
     ComponentDto file3 = newFileDto(project3, null);
@@ -1198,9 +1198,9 @@ public class IssueIndexTest {
   @Test
   public void authorized_issues_on_user() {
     OrganizationDto org = newOrganizationDto();
-    ComponentDto project1 = newProjectDto(org);
-    ComponentDto project2 = newProjectDto(org);
-    ComponentDto project3 = newProjectDto(org);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org);
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file1 = newFileDto(project1, null);
     ComponentDto file2 = newFileDto(project2, null);
     ComponentDto file3 = newFileDto(project3, null);
@@ -1228,7 +1228,7 @@ public class IssueIndexTest {
 
   @Test
   public void root_user_is_authorized_to_access_all_issues() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     indexIssue(newDoc("I1", project));
     userSessionRule.logIn().setRoot();
 
@@ -1237,7 +1237,7 @@ public class IssueIndexTest {
 
   @Test
   public void search_issues_for_batch_return_needed_fields() {
-    ComponentDto project = newProjectDto(newOrganizationDto(), "PROJECT");
+    ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "PROJECT");
     ComponentDto file = newFileDto(project, null).setPath("src/File.xoo");
 
     IssueDoc issue = newDoc("ISSUE", file)
@@ -1275,7 +1275,7 @@ public class IssueIndexTest {
 
   @Test
   public void search_issues_for_batch() {
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto module = ComponentTesting.newModuleDto(project);
     ComponentDto subModule = ComponentTesting.newModuleDto(module);
     ComponentDto file = newFileDto(subModule, null);
@@ -1291,7 +1291,7 @@ public class IssueIndexTest {
     assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(module))).hasSize(3);
     assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(subModule))).hasSize(2);
     assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(file))).hasSize(1);
-    assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(newProjectDto(newOrganizationDto())))).isEmpty();
+    assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(ComponentTesting.newPrivateProjectDto(newOrganizationDto())))).isEmpty();
   }
 
   @Test
@@ -1307,8 +1307,8 @@ public class IssueIndexTest {
   @Test
   public void search_issues_for_batch_return_only_authorized_issues() {
     OrganizationDto org = newOrganizationDto();
-    ComponentDto project1 = newProjectDto(org);
-    ComponentDto project2 = newProjectDto(org);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file1 = newFileDto(project1, null);
     ComponentDto file2 = newFileDto(project2, null);
     GroupDto allowedGroup = newGroupDto();
@@ -1336,7 +1336,7 @@ public class IssueIndexTest {
     ruleIndexer.indexRuleDefinition(r2.getKey());
 
     OrganizationDto org = db.organizations().insert();
-    ComponentDto project = newProjectDto(newOrganizationDto());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
     ComponentDto file = newFileDto(project, null);
     indexIssues(
       newDoc("ISSUE1", file).setOrganizationUuid(org.getUuid()).setRuleKey(r1.getKey().toString()).setTags(of("convention", "java8", "bug")),
@@ -1355,9 +1355,9 @@ public class IssueIndexTest {
   @Test
   public void filter_by_organization() {
     OrganizationDto org1 = newOrganizationDto();
-    ComponentDto projectInOrg1 = newProjectDto(org1);
+    ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1);
     OrganizationDto org2 = newOrganizationDto();
-    ComponentDto projectInOrg2 = newProjectDto(org2);
+    ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2);
 
     indexIssues(newDoc("issueInOrg1", projectInOrg1), newDoc("issue1InOrg2", projectInOrg2), newDoc("issue2InOrg2", projectInOrg2));
 
@@ -1369,9 +1369,9 @@ public class IssueIndexTest {
   @Test
   public void filter_by_organization_and_project() {
     OrganizationDto org1 = newOrganizationDto();
-    ComponentDto projectInOrg1 = newProjectDto(org1);
+    ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1);
     OrganizationDto org2 = newOrganizationDto();
-    ComponentDto projectInOrg2 = newProjectDto(org2);
+    ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2);
 
     indexIssues(newDoc("issueInOrg1", projectInOrg1), newDoc("issue1InOrg2", projectInOrg2), newDoc("issue2InOrg2", projectInOrg2));
 
index 70f394090894e8df748f1952249f51cc1928bc24..dab696ce3ac4a1b00f72156c7ee6fff2330b0162 100644 (file)
@@ -81,7 +81,7 @@ public class IssueIndexerTest {
   @Test
   public void indexOnStartup_loads_and_indexes_all_issues() {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(org);
+    ComponentDto project = dbTester.components().insertPrivateProject(org);
     ComponentDto dir = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo"));
     ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project, dir, "F1"));
     RuleDto rule = dbTester.rules().insertRule();
@@ -97,7 +97,7 @@ public class IssueIndexerTest {
   @Test
   public void index_loads_and_indexes_issues_with_specified_keys() {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(org);
+    ComponentDto project = dbTester.components().insertPrivateProject(org);
     ComponentDto dir = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo"));
     ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project, dir, "F1"));
     RuleDto rule = dbTester.rules().insertRule();
@@ -124,9 +124,9 @@ public class IssueIndexerTest {
   @Test
   public void indexProject_loads_and_indexes_issues_with_specified_project_uuid() {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project1 = dbTester.components().insertProject(org);
+    ComponentDto project1 = dbTester.components().insertPrivateProject(org);
     ComponentDto file1 = dbTester.components().insertComponent(ComponentTesting.newFileDto(project1));
-    ComponentDto project2 = dbTester.components().insertProject(org);
+    ComponentDto project2 = dbTester.components().insertPrivateProject(org);
     ComponentDto file2 = dbTester.components().insertComponent(ComponentTesting.newFileDto(project2));
     RuleDto rule = dbTester.rules().insertRule();
     IssueDto issue1 = dbTester.issues().insertIssue(IssueTesting.newDto(rule, file1, project1));
@@ -151,7 +151,7 @@ public class IssueIndexerTest {
 
   private void verifyThatProjectIsNotIndexed(ProjectIndexer.Cause cause) {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(org);
+    ComponentDto project = dbTester.components().insertPrivateProject(org);
     ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project));
     RuleDto rule = dbTester.rules().insertRule();
     IssueDto issue = dbTester.issues().insertIssue(IssueTesting.newDto(rule, file, project));
index b7d328f46746161ae1219ef63413d40dea35f2cf..daf8308bb58c1d59d6d431de5488aa3e19e696b0 100644 (file)
@@ -123,7 +123,7 @@ public class BulkChangeActionTest {
     issueWorkflow.start();
     rule = db.rules().insertRule(newRuleDto());
     organization = db.organizations().insert();
-    project = db.components().insertProject(organization);
+    project = db.components().insertPrivateProject(organization);
     file = db.components().insertComponent(newFileDto(project));
     user = db.users().insertUser("john");
     when(system2.now()).thenReturn(NOW);
@@ -346,7 +346,7 @@ public class BulkChangeActionTest {
   @Test
   public void issues_on_which_user_has_not_browse_permission_are_ignored() throws Exception {
     setUserProjectPermissions(USER, ISSUE_ADMIN);
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject));
     IssueDto authorizedIssue = db.issues().insertIssue(newUnresolvedIssue(rule, file, project).setType(BUG));
     // User has not browse permission on these 2 issues
@@ -370,7 +370,7 @@ public class BulkChangeActionTest {
   @Test
   public void does_not_update_type_when_no_issue_admin_permission() throws Exception {
     setUserProjectPermissions(USER, ISSUE_ADMIN);
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject));
     addUserProjectPermissions(anotherProject, USER);
 
@@ -396,7 +396,7 @@ public class BulkChangeActionTest {
   @Test
   public void does_not_update_severity_when_no_issue_admin_permission() throws Exception {
     setUserProjectPermissions(USER, ISSUE_ADMIN);
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject));
     addUserProjectPermissions(anotherProject, USER);
 
index 9e7c07db3832e05dc557bfc366144c090dc84641..8a6fc9784e060b4b748466a39038cd717645724c 100644 (file)
@@ -70,7 +70,7 @@ public class ChangelogActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     file = db.components().insertComponent(newFileDto(project));
   }
 
@@ -94,7 +94,7 @@ public class ChangelogActionTest {
   @Test
   public void changelog_of_file_move_contains_file_names() throws Exception {
     RuleDto rule = db.rules().insertRule(newRuleDto());
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     ComponentDto file1 = db.components().insertComponent(newFileDto(project));
     ComponentDto file2 = db.components().insertComponent(newFileDto(project));
     IssueDto issueDto = db.issues().insertIssue(newDto(rule, file2, project));
index 68c91866b99cebff3ec69bad0b2cb79a3d500bb4..783e8fb42476a645565190d1e1f3435b3e132156 100644 (file)
@@ -111,7 +111,7 @@ public class DoTransitionActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = componentDbTester.insertProject();
+    project = componentDbTester.insertPrivateProject();
     file = componentDbTester.insertComponent(newFileDto(project));
     workflow.start();
   }
index 28cd589d3536cea0ff4129d37f3d2eed06e57536..6ba4c155fdfc2c07e60e3a6ff20c50c64c397ad5 100644 (file)
@@ -112,7 +112,7 @@ public class SearchActionComponentsMediumTest {
   @Test
   public void issues_on_different_projects() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     IssueDto issue = IssueTesting.newDto(rule, file, project)
@@ -123,7 +123,7 @@ public class SearchActionComponentsMediumTest {
       .setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
     db.issueDao().insert(session, issue);
 
-    ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P2").setKey("PK2"));
+    ComponentDto project2 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P2").setKey("PK2"));
     setDefaultProjectPermission(project2);
     ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
     IssueDto issue2 = IssueTesting.newDto(rule, file2, project2)
@@ -142,7 +142,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void do_not_return_module_key_on_single_module_projects() throws IOException {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
     ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
@@ -169,7 +169,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_project_uuid() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
@@ -200,7 +200,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_since_leak_period_on_project() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     db.snapshotDao().insert(session,
@@ -228,7 +228,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_since_leak_period_on_file_in_module_project() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto module = insertComponent(newModuleDto(project));
     ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
@@ -257,9 +257,9 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void project_facet_is_sticky() throws Exception {
-    ComponentDto project1 = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
-    ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P2").setKey("PK2"));
-    ComponentDto project3 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P3").setKey("PK3"));
+    ComponentDto project1 = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project2 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P2").setKey("PK2"));
+    ComponentDto project3 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P3").setKey("PK3"));
     setDefaultProjectPermission(project1);
     setDefaultProjectPermission(project2);
     setDefaultProjectPermission(project3);
@@ -283,7 +283,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_file_uuid() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
@@ -314,7 +314,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_file_key() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     ComponentDto unitTest = insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2"));
@@ -338,7 +338,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void display_file_facet() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setKey("FK2"));
@@ -360,7 +360,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_directory_path() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
@@ -392,7 +392,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_directory_path_in_different_modules() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto module1 = insertComponent(newModuleDto("M1", project).setKey("MK1"));
     ComponentDto module2 = insertComponent(newModuleDto("M2", project).setKey("MK2"));
@@ -441,7 +441,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void display_module_facet() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
     ComponentDto subModule1 = insertComponent(newModuleDto("SUBM1", module).setKey("SUBMK1"));
@@ -466,7 +466,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void display_directory_facet() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
     ComponentDto file = insertComponent(newFileDto(project, directory, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
@@ -485,12 +485,12 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_view_uuid() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
 
-    ComponentDto view = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
+    ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
     indexView(view.uuid(), newArrayList(project.uuid()));
 
     setAnyoneProjectPermission(view, UserRole.USER);
@@ -504,12 +504,12 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_view_uuid_return_only_authorized_view() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
 
-    ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
+    ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
     indexView(view.uuid(), newArrayList(project.uuid()));
 
     setAnyoneProjectPermission(view, UserRole.USER);
@@ -524,14 +524,14 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_sub_view_uuid() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
 
-    ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
+    ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
     indexView(view.uuid(), newArrayList(project.uuid()));
-    ComponentDto subView = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView"));
+    ComponentDto subView = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView"));
     indexView(subView.uuid(), newArrayList(project.uuid()));
 
     setAnyoneProjectPermission(view, UserRole.USER);
@@ -545,14 +545,14 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_sub_view_uuid_return_only_authorized_view() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
 
-    ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
+    ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
     indexView(view.uuid(), newArrayList(project.uuid()));
-    ComponentDto subView = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView"));
+    ComponentDto subView = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView"));
     indexView(subView.uuid(), newArrayList(project.uuid()));
 
     setAnyoneProjectPermission(view, UserRole.USER);
@@ -567,7 +567,7 @@ public class SearchActionComponentsMediumTest {
 
   @Test
   public void search_by_author() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
     RuleDto newRule = newRule();
index 7041184c121f0879a6163e1d3d757f150868459b..fe37b1f32a7973e4f66d703920a5ff5c8f6c9a45 100644 (file)
@@ -129,7 +129,7 @@ public class SearchActionMediumTest {
     db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
     db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -158,7 +158,7 @@ public class SearchActionMediumTest {
     db.userDao().insert(session, new UserDto().setLogin("john").setName("John"));
     db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -195,7 +195,7 @@ public class SearchActionMediumTest {
     db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
     db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -230,7 +230,7 @@ public class SearchActionMediumTest {
   public void load_additional_fields() throws Exception {
     db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
     db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
     setProjectPermission(project, USER);
 
@@ -252,7 +252,7 @@ public class SearchActionMediumTest {
   public void load_additional_fields_with_issue_admin_permission() throws Exception {
     db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
     db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
     setProjectPermission(project, USER, ISSUE_ADMIN);
 
@@ -273,7 +273,7 @@ public class SearchActionMediumTest {
   @Test
   public void issue_on_removed_file() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project, null).setUuid("REMOVED_FILE_ID")
       .setKey("REMOVED_FILE_KEY")
@@ -298,7 +298,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void issue_contains_component_id_for_eclipse() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project);
@@ -314,7 +314,7 @@ public class SearchActionMediumTest {
   @Test
   public void apply_paging_with_one_component() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < SearchOptions.MAX_LIMIT + 1; i++) {
@@ -331,7 +331,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void components_contains_sub_projects() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule"));
     setDefaultProjectPermission(project);
     ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile"));
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setKey("FileLinkedToModule"));
@@ -347,7 +347,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void display_facets() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -372,7 +372,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void display_facets_in_effort_mode() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -398,7 +398,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void display_zero_valued_facets_for_selected_items() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
@@ -440,7 +440,7 @@ public class SearchActionMediumTest {
   public void filter_by_assigned_to_me() throws Exception {
     db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newRule();
@@ -485,7 +485,7 @@ public class SearchActionMediumTest {
   public void filter_by_assigned_to_me_unauthenticated() throws Exception {
     userSessionRule.logIn();
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newRule();
@@ -516,7 +516,7 @@ public class SearchActionMediumTest {
   public void assigned_to_me_facet_is_sticky_relative_to_assignees() throws Exception {
     db.userDao().insert(session, new UserDto().setLogin("alice").setName("Alice").setEmail("alice@email.com"));
 
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     RuleDto rule = newRule();
@@ -560,7 +560,7 @@ public class SearchActionMediumTest {
   @Test
   public void sort_by_updated_at() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     db.issueDao().insert(session, IssueTesting.newDto(rule, file, project)
@@ -586,7 +586,7 @@ public class SearchActionMediumTest {
   @Test
   public void paging() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < 12; i++) {
@@ -608,7 +608,7 @@ public class SearchActionMediumTest {
   @Test
   public void paging_with_page_size_to_minus_one() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < 12; i++) {
@@ -630,7 +630,7 @@ public class SearchActionMediumTest {
   @Test
   public void deprecated_paging() throws Exception {
     RuleDto rule = newRule();
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     for (int i = 0; i < 12; i++) {
@@ -659,7 +659,7 @@ public class SearchActionMediumTest {
 
   @Test
   public void display_deprecated_debt_fields() throws Exception {
-    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+    ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
     setDefaultProjectPermission(project);
     ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
     IssueDto issue = IssueTesting.newDto(newRule(), file, project)
index e06e50b8a9c01af8779fd1837e9925ae55c5c2cb..901ea23a3dfba9a38aa906d752d36424901b50fa 100644 (file)
@@ -178,7 +178,7 @@ public class SetSeverityActionTest {
 
   private IssueDto newIssue() {
     RuleDto rule = dbTester.rules().insertRule(newRuleDto());
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
     return newDto(rule, file, project);
   }
index 694e530215f3de1245c86442fe23c2c2693f742f..7df5e6852a12cc6d572912730d0c793009e61f40 100644 (file)
@@ -232,13 +232,13 @@ public class SetTagsActionTest {
 
   private IssueDto newIssue() {
     RuleDefinitionDto rule = db.rules().insert();
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPublicProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     return IssueTesting.newIssue(rule, file, project);
   }
 
   private void setUserWithBrowsePermission(IssueDto issueDto) {
-    logInAndAddProjectPermission(issueDto, USER);
+    userSession.logIn("john").addProjectPermission(USER, dbClient.componentDao().selectByUuid(db.getSession(), issueDto.getProjectUuid()).get());
   }
 
   private void logInAndAddProjectPermission(IssueDto issueDto, String permission) {
index b5e9af4f82eec5e95efeb3880c08ecf09f9a7d3c..ea5b11160a9211303af58df51e08e89928241cbf 100644 (file)
@@ -175,7 +175,7 @@ public class SetTypeActionTest {
 
   private IssueDto newIssue() {
     RuleDto rule = dbTester.rules().insertRule(newRuleDto());
-    ComponentDto project = dbTester.components().insertProject();
+    ComponentDto project = dbTester.components().insertPrivateProject();
     ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
     return newDto(rule, file, project);
   }
index fdadb23e5c43d477e51fc3a96896f34031637fdf..c1b7adad3862883ef084926a4ca9e151e4d7c2f2 100644 (file)
@@ -206,7 +206,7 @@ public class TagsActionTest {
   }
 
   private IssueDto insertIssue(RuleDefinitionDto rule, String... tags) {
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     IssueDto issueDto = IssueTesting.newIssue(rule, file, project).setTags(asList(tags));
     return db.issues().insertIssue(issueDto);
index 13a6c7d1d6936ae883dfc9b12813b162a1f70925..b69556f374d66ce9411c6cb486cc2328c835fa60 100644 (file)
@@ -96,7 +96,7 @@ public class CreateActionTest {
     dbSession.commit();
 
     OrganizationDto organizationDto = db.organizations().insert();
-    project = ComponentTesting.newProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setKey(DEFAULT_PROJECT_KEY);
+    project = ComponentTesting.newPrivateProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setKey(DEFAULT_PROJECT_KEY);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
     userSession.logIn("login").addProjectPermission(UserRole.ADMIN, project);
index ddc01c1061ccbe61340b6f09131fb19a2d3e549c..a3cd6d3633710632513401e931a73dca5d6a8e3d 100644 (file)
@@ -63,7 +63,7 @@ public class DeleteActionTest {
 
   @Test
   public void project_administrator_can_delete_custom_measures() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     long id = insertCustomMeasure(project);
 
@@ -81,7 +81,7 @@ public class DeleteActionTest {
 
   @Test
   public void throw_ForbiddenException_if_not_system_administrator() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     long id = insertCustomMeasure(project);
     userSession.logIn().setNonSystemAdministrator();
 
@@ -91,7 +91,7 @@ public class DeleteActionTest {
 
   @Test
   public void throw_UnauthorizedException_if_not_logged_in() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     long id = insertCustomMeasure(project);
     userSession.anonymous();
 
index a6e20b455a99f0d9d6e4d8ca5161f2f21bf07768..a0c5d48fbb6cbd428778e56e3ac67e24f88da284 100644 (file)
@@ -227,7 +227,7 @@ public class MetricsActionTest {
   }
 
   private ComponentDto insertProject(String projectUuid, String projectKey) {
-    ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), projectUuid)
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), projectUuid)
       .setKey(projectKey);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
index b9ea1be717ef990d103ee42f59602f4579146879..171a4d5ef79728e61eedacf919731b06bb11a5bc 100644 (file)
@@ -265,7 +265,7 @@ public class SearchActionTest {
   }
 
   private ComponentDto insertProject(String projectUuid, String projectKey) {
-    ComponentDto project = ComponentTesting.newProjectDto(db.organizations().insert(), projectUuid)
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert(), projectUuid)
       .setKey(projectKey);
     dbClient.componentDao().insert(dbSession, project);
     dbSession.commit();
index 193f27620d070ae4eeb63d73748523c4e26bd7fc..00269798c5b074755ed475ea5bb31bb06b254e04 100644 (file)
@@ -90,7 +90,7 @@ public class UpdateActionTest {
   @Test
   public void update_text_value_and_description_in_db() throws Exception {
     MetricDto metric = insertNewMetric(ValueType.STRING);
-    ComponentDto component = db.components().insertProject(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto component = db.components().insertPrivateProject(db.getDefaultOrganization(), "project-uuid");
     CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
       .setDescription("custom-measure-description")
       .setTextValue("text-measure-value");
@@ -117,7 +117,7 @@ public class UpdateActionTest {
   public void update_double_value_and_description_in_db() throws Exception {
     MetricDto metric = insertNewMetric(ValueType.INT);
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto component = db.components().insertProject(organizationDto, "project-uuid");
+    ComponentDto component = db.components().insertPrivateProject(organizationDto, "project-uuid");
     CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
       .setDescription("custom-measure-description")
       .setValue(42d);
@@ -144,7 +144,7 @@ public class UpdateActionTest {
       .setKey("metric-key");
     dbClient.metricDao().insert(dbSession, metric);
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto component = ComponentTesting.newProjectDto(organizationDto, "project-uuid").setKey("project-key");
+    ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid").setKey("project-key");
     dbClient.componentDao().insert(dbSession, component);
     CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
       .setCreatedAt(100_000_000L)
@@ -171,7 +171,7 @@ public class UpdateActionTest {
   @Test
   public void update_value_only() throws Exception {
     MetricDto metric = insertNewMetric(ValueType.STRING);
-    ComponentDto component = db.components().insertProject(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto component = db.components().insertPrivateProject(db.getDefaultOrganization(), "project-uuid");
     CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
       .setDescription("custom-measure-description")
       .setTextValue("text-measure-value");
@@ -197,7 +197,7 @@ public class UpdateActionTest {
   public void update_description_only() throws Exception {
     MetricDto metric = insertNewMetric(ValueType.STRING);
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto component = db.components().insertProject(organizationDto, "project-uuid");
+    ComponentDto component = db.components().insertPrivateProject(organizationDto, "project-uuid");
     CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
       .setMetricId(metric.getId())
       .setComponentUuid(component.uuid())
@@ -249,7 +249,7 @@ public class UpdateActionTest {
     userSessionRule.logIn();
     MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(ValueType.STRING.name());
     dbClient.metricDao().insert(dbSession, metric);
-    ComponentDto component = ComponentTesting.newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto component = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     dbClient.componentDao().insert(dbSession, component);
     CustomMeasureDto customMeasure = newCustomMeasureDto()
       .setMetricId(metric.getId())
@@ -276,7 +276,7 @@ public class UpdateActionTest {
     MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(ValueType.STRING.name());
     dbClient.metricDao().insert(dbSession, metric);
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto component = ComponentTesting.newProjectDto(organizationDto, "project-uuid");
+    ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid");
     dbClient.componentDao().insert(dbSession, component);
     CustomMeasureDto customMeasure = newCustomMeasureDto()
       .setMetricId(metric.getId())
index c8d441acf52aea382abdb59371559d0f6334ad52..58ad169b97d751728be3ceaee375c7280c121bbc 100644 (file)
@@ -32,6 +32,7 @@ import org.junit.rules.ExpectedException;
 import org.sonar.api.config.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.organization.OrganizationTesting;
 import org.sonar.db.user.GroupDto;
@@ -58,7 +59,7 @@ import static org.sonar.api.measures.CoreMetrics.COVERAGE_KEY;
 import static org.sonar.api.measures.Metric.Level.ERROR;
 import static org.sonar.api.measures.Metric.Level.OK;
 import static org.sonar.api.measures.Metric.Level.WARN;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.user.GroupTesting.newGroupDto;
 import static org.sonar.db.user.UserTesting.newUserDto;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_TAGS;
@@ -75,9 +76,9 @@ public class ProjectMeasuresIndexTest {
   private static final String LANGUAGES = "languages";
 
   private static final OrganizationDto ORG = OrganizationTesting.newOrganizationDto();
-  private static final ComponentDto PROJECT1 = newProjectDto(ORG).setUuid("Project-1").setName("Project 1").setKey("key-1");
-  private static final ComponentDto PROJECT2 = newProjectDto(ORG).setUuid("Project-2").setName("Project 2").setKey("key-2");
-  private static final ComponentDto PROJECT3 = newProjectDto(ORG).setUuid("Project-3").setName("Project 3").setKey("key-3");
+  private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-1").setName("Project 1").setKey("key-1");
+  private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-2").setName("Project 2").setKey("key-2");
+  private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-3").setName("Project 3").setKey("key-3");
   private static final UserDto USER1 = newUserDto();
   private static final UserDto USER2 = newUserDto();
   private static final GroupDto GROUP1 = newGroupDto();
@@ -103,10 +104,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void default_sort_is_by_ascending_case_insensitive_name_then_by_key() {
-    ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
-    ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
-    ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
-    ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
     index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
 
     assertResults(new ProjectMeasuresQuery(), apache1, apache2, apachee, windows);
@@ -114,9 +115,9 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_insensitive_name() {
-    ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows");
-    ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee");
-    ComponentDto apache = newProjectDto(ORG).setUuid("apache").setName("Apache");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee");
+    ComponentDto apache = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache").setName("Apache");
     index(newDoc(windows), newDoc(apachee), newDoc(apache));
 
     assertResults(new ProjectMeasuresQuery().setSort("name").setAsc(true), apache, apachee, windows);
@@ -136,10 +137,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_a_metric_then_by_name_then_by_key() {
-    ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
-    ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
-    ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
-    ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
     index(
       newDoc(windows, NCLOC, 10_000d),
       newDoc(apachee, NCLOC, 5_000d),
@@ -152,7 +153,7 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_quality_gate_status() {
-    ComponentDto project4 = newProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
+    ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
     index(
       newDoc(PROJECT1).setQualityGateStatus(OK.name()),
       newDoc(PROJECT2).setQualityGateStatus(ERROR.name()),
@@ -165,10 +166,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void sort_by_quality_gate_status_then_by_name_then_by_key() {
-    ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
-    ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
-    ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
-    ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
     index(
       newDoc(windows).setQualityGateStatus(WARN.name()),
       newDoc(apachee).setQualityGateStatus(OK.name()),
@@ -182,7 +183,7 @@ public class ProjectMeasuresIndexTest {
   @Test
   public void paginate_results() {
     IntStream.rangeClosed(1, 9)
-      .forEach(i -> index(newDoc(newProjectDto(ORG, "P" + i))));
+      .forEach(i -> index(newDoc(newPrivateProjectDto(ORG, "P" + i))));
 
     SearchIdResult<String> result = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().setPage(2, 3));
 
@@ -284,7 +285,7 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void filter_on_languages() {
-    ComponentDto project4 = newProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
+    ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
     index(
       newDoc(PROJECT1).setLanguages(singletonList("java")),
       newDoc(PROJECT2).setLanguages(singletonList("xoo")),
@@ -298,10 +299,10 @@ public class ProjectMeasuresIndexTest {
 
   @Test
   public void filter_on_query_text() {
-    ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
-    ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
-    ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
-    ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+    ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
+    ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
+    ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
+    ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
     index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
 
     assertResults(new ProjectMeasuresQuery().setQueryText("windows"), windows);
@@ -338,8 +339,8 @@ public class ProjectMeasuresIndexTest {
   public void filter_on_organization() {
     OrganizationDto org1 = OrganizationTesting.newOrganizationDto();
     OrganizationDto org2 = OrganizationTesting.newOrganizationDto();
-    ComponentDto projectInOrg1 = newProjectDto(org1);
-    ComponentDto projectInOrg2 = newProjectDto(org2);
+    ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1);
+    ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2);
     index(newDoc(projectInOrg1), newDoc(projectInOrg2));
 
     ProjectMeasuresQuery query1 = new ProjectMeasuresQuery().setOrganizationUuid(org1.getUuid());
@@ -1282,7 +1283,7 @@ public class ProjectMeasuresIndexTest {
   }
 
   private static ProjectMeasuresDoc newDoc() {
-    return newDoc(newProjectDto(ORG));
+    return newDoc(ComponentTesting.newPrivateProjectDto(ORG));
   }
 
   private static ProjectMeasuresDoc newDoc(ComponentDto project, String metric1, Object value1) {
@@ -1302,15 +1303,15 @@ public class ProjectMeasuresIndexTest {
   }
 
   private static ProjectMeasuresDoc newDoc(String metric1, Object value1) {
-    return newDoc(newProjectDto(ORG), metric1, value1);
+    return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1);
   }
 
   private static ProjectMeasuresDoc newDoc(String metric1, Object value1, String metric2, Object value2) {
-    return newDoc(newProjectDto(ORG), metric1, value1, metric2, value2);
+    return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1, metric2, value2);
   }
 
   private static ProjectMeasuresDoc newDoc(String metric1, Object value1, String metric2, Object value2, String metric3, Object value3) {
-    return newDoc(newProjectDto(ORG), metric1, value1, metric2, value2, metric3, value3);
+    return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1, metric2, value2, metric3, value3);
   }
 
   private void assertResults(ProjectMeasuresQuery query, ComponentDto... expectedProjects) {
index 047500b8d3fe7bfa721b9cfbb6c40cce87480b0e..def243184f8f0a0aa2f59f2a1249fdb5a1b27762 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.es.EsTester;
@@ -41,7 +42,7 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ANALYSED_AT;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_KEY;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NAME;
@@ -81,9 +82,9 @@ public class ProjectMeasuresIndexerTest {
   @Test
   public void index_all_project() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
-    componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
-    componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
+    componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
+    componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
+    componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     underTest.indexOnStartup(null);
 
@@ -95,7 +96,7 @@ public class ProjectMeasuresIndexerTest {
    */
   @Test
   public void index_provisioned_projects() {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
 
     underTest.indexOnStartup(null);
 
@@ -104,7 +105,7 @@ public class ProjectMeasuresIndexerTest {
 
   @Test
   public void indexProject_indexes_provisioned_project() {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
 
     underTest.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_CREATION);
 
@@ -113,7 +114,7 @@ public class ProjectMeasuresIndexerTest {
 
   @Test
   public void indexProject_indexes_project_when_its_key_is_updated() {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
 
     underTest.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE);
 
@@ -123,9 +124,9 @@ public class ProjectMeasuresIndexerTest {
   @Test
   public void index_one_project() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = newProjectDto(organizationDto);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto);
     componentDbTester.insertProjectAndSnapshot(project);
-    componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
+    componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     underTest.indexProject(project.uuid(), ProjectIndexer.Cause.NEW_ANALYSIS);
 
@@ -141,7 +142,7 @@ public class ProjectMeasuresIndexerTest {
       .setName("Old Name")
       .setTags(singletonList("old tag"))
       .setAnalysedAt(new Date(1_000_000L)));
-    ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), uuid).setKey("New key").setName("New name").setTagsString("new tag");
+    ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setKey("New key").setName("New name").setTagsString("new tag");
     SnapshotDto analysis = componentDbTester.insertProjectAndSnapshot(project);
 
     underTest.indexProject(project.uuid(), ProjectIndexer.Cause.NEW_ANALYSIS);
@@ -162,11 +163,11 @@ public class ProjectMeasuresIndexerTest {
   @Test
   public void delete_project() {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project1 = newProjectDto(organizationDto);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto);
     componentDbTester.insertProjectAndSnapshot(project1);
-    ComponentDto project2 = newProjectDto(organizationDto);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto);
     componentDbTester.insertProjectAndSnapshot(project2);
-    ComponentDto project3 = newProjectDto(organizationDto);
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto);
     componentDbTester.insertProjectAndSnapshot(project3);
     underTest.indexOnStartup(null);
 
@@ -177,7 +178,7 @@ public class ProjectMeasuresIndexerTest {
 
   @Test
   public void does_nothing_when_deleting_unknown_project() throws Exception {
-    ComponentDto project = newProjectDto(dbTester.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert());
     componentDbTester.insertProjectAndSnapshot(project);
     underTest.indexOnStartup(null);
 
index f1147f2bf0dbd034a70b0a6a240988cf90683672..8a648a7d2ce176b8395e676e936ff1f3bbc160b5 100644 (file)
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -93,7 +93,7 @@ public class ComponentActionTest {
 
   @Test
   public void provided_project() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
+    ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
     userSession.addProjectPermission(UserRole.USER, project);
     insertNclocMetric();
 
@@ -106,7 +106,7 @@ public class ComponentActionTest {
 
   @Test
   public void without_additional_fields() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), "project-uuid"));
     insertNclocMetric();
 
     String response = ws.newRequest()
@@ -121,7 +121,7 @@ public class ComponentActionTest {
 
   @Test
   public void reference_uuid_in_the_response() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key");
     componentDb.insertProjectAndSnapshot(project);
     ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid");
     componentDb.insertViewAndSnapshot(view);
@@ -140,7 +140,7 @@ public class ComponentActionTest {
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Component id 'unknown-developer-id' not found");
 
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
     insertNclocMetric();
 
     ws.newRequest()
@@ -151,7 +151,7 @@ public class ComponentActionTest {
 
   @Test
   public void fail_when_a_metric_is_not_found() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), PROJECT_UUID));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID));
     insertNclocMetric();
     insertComplexityMetric();
 
@@ -163,7 +163,7 @@ public class ComponentActionTest {
 
   @Test
   public void fail_when_empty_metric_keys_parameter() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("At least one metric key must be provided");
@@ -174,7 +174,7 @@ public class ComponentActionTest {
   @Test
   public void fail_when_not_enough_permission() {
     userSession.logIn();
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), PROJECT_UUID));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID));
     insertNclocMetric();
 
     expectedException.expect(ForbiddenException.class);
@@ -243,7 +243,7 @@ public class ComponentActionTest {
   }
 
   private void insertJsonExampleData() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
     SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project)
       .setPeriodDate(parseDateTime("2016-01-11T10:49:50+0100").getTime())
       .setPeriodMode("previous_version")
index b40064b13049f2c1508be7e6916ab22e79404bcd..268b0c409c1a1770d9472786b8ebca7cff8e33f4 100644 (file)
@@ -60,7 +60,7 @@ import static org.sonar.api.measures.Metric.ValueType.RATING;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
 import static org.sonar.server.measure.ws.ComponentTreeAction.LEAVES_STRATEGY;
@@ -121,7 +121,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void empty_response() {
-    componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
 
     ComponentTreeWsResponse response = ws.newRequest()
       .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
@@ -136,7 +136,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void load_measures_and_periods() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     componentDb.insertComponent(projectDto);
     SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession,
       newAnalysis(projectDto)
@@ -172,7 +172,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void load_measures_with_best_value() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
     userSession.anonymous().addProjectPermission(UserRole.USER, projectDto);
     ComponentDto directoryDto = newDirectory(projectDto, "directory-uuid", "path/to/directory").setName("directory-1");
@@ -216,7 +216,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void use_best_value_for_rating() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     userSession.anonymous().addProjectPermission(UserRole.USER, projectDto);
     componentDb.insertComponent(projectDto);
     SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(projectDto)
@@ -249,7 +249,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void load_measures_multi_sort_with_metric_key_and_paginated() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
     ComponentDto file9 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-9").setName("file-1"));
     ComponentDto file8 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-8").setName("file-1"));
@@ -292,7 +292,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void sort_by_metric_value() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
     ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4"));
     ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
@@ -319,7 +319,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void remove_components_without_measure_on_the_metric_sort() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
     ComponentDto file1 = newFileDto(project, null, "file-uuid-1");
     ComponentDto file2 = newFileDto(project, null, "file-uuid-2");
@@ -355,7 +355,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void sort_by_metric_period() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
     ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
     ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1"));
@@ -381,7 +381,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void remove_components_without_measure_on_the_metric_period_sort() {
-    ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid");
+    ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid");
     SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
     ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4"));
     ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
@@ -415,7 +415,7 @@ public class ComponentTreeActionTest {
   public void load_measures_when_no_leave_qualifier() {
     resourceTypes.setLeavesQualifiers();
     String projectUuid = "project-uuid";
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), projectUuid);
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), projectUuid);
     componentDb.insertProjectAndSnapshot(project);
     componentDb.insertComponent(newFileDto(project, null));
     insertNclocMetric();
@@ -432,7 +432,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_metric_keys_parameter_is_empty() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("The 'metricKeys' parameter must contain at least one metric key");
@@ -445,7 +445,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_a_metric_is_not_found() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     insertNclocMetric();
     insertNewViolationsMetric();
     expectedException.expect(NotFoundException.class);
@@ -458,7 +458,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_using_DISTRIB_metrics() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     dbClient.metricDao().insert(dbSession, newMetricDto().setKey("distrib1").setValueType(DISTRIB.name()));
     dbClient.metricDao().insert(dbSession, newMetricDto().setKey("distrib2").setValueType(DISTRIB.name()));
     db.commit();
@@ -474,7 +474,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_using_DATA_metrics() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     dbClient.metricDao().insert(dbSession, newMetricDto().setKey("data1").setValueType(DISTRIB.name()));
     dbClient.metricDao().insert(dbSession, newMetricDto().setKey("data2").setValueType(DISTRIB.name()));
     db.commit();
@@ -490,7 +490,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_setting_more_than_15_metric_keys() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     List<String> metrics = IntStream.range(0, 20)
       .mapToObj(i -> "metric" + i)
       .collect(MoreCollectors.toList());
@@ -507,7 +507,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_search_query_have_less_than_3_characters() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     insertNclocMetric();
     insertNewViolationsMetric();
     expectedException.expect(BadRequestException.class);
@@ -523,7 +523,7 @@ public class ComponentTreeActionTest {
   @Test
   public void fail_when_insufficient_privileges() {
     userSession.logIn();
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     expectedException.expect(ForbiddenException.class);
 
     ws.newRequest()
@@ -534,7 +534,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_sort_by_metric_and_no_metric_sort_provided() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     expectedException.expect(BadRequestException.class);
     expectedException
       .expectMessage("To sort by a metric, the 's' parameter must contain 'metric' or 'metricPeriod', and a metric key must be provided in the 'metricSort' parameter");
@@ -549,7 +549,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_sort_by_metric_and_not_in_the_list_of_metric_keys() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("To sort by the 'complexity' metric, it must be in the list of metric keys in the 'metricKeys' parameter");
 
@@ -563,7 +563,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_sort_by_metric_period_and_no_metric_period_sort_provided() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("To sort by a metric period, the 's' parameter must contain 'metricPeriod' and the 'metricPeriodSort' must be provided.");
 
@@ -578,7 +578,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_paging_parameter_is_too_big() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     insertNclocMetric();
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("The 'ps' parameter must be less than 500");
@@ -592,7 +592,7 @@ public class ComponentTreeActionTest {
 
   @Test
   public void fail_when_with_measures_only_and_no_metric_sort() {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     insertNclocMetric();
     expectedException.expect(BadRequestException.class);
     expectedException
@@ -614,7 +614,7 @@ public class ComponentTreeActionTest {
   }
 
   private void insertJsonExampleData() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-id")
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-id")
       .setKey("MY_PROJECT")
       .setName("My Project")
       .setQualifier(Qualifiers.PROJECT);
index 50fc5ea2d69f6d50213ab8403ef233f3ab2b16d4..e3d2f73f7efde58b2b00e218457e4e049892625b 100644 (file)
@@ -37,6 +37,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.organization.OrganizationDto;
@@ -59,7 +60,6 @@ import static org.sonar.api.utils.DateUtils.parseDateTime;
 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.newProjectDto;
 import static org.sonar.db.component.ComponentTesting.newSubView;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
@@ -106,7 +106,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures() throws Exception {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto projectSnapshot = db.components().insertProjectAndSnapshot(project);
     setBrowsePermissionOnUser(project);
     MetricDto coverage = insertCoverageMetric();
@@ -124,7 +124,7 @@ public class SearchActionTest {
 
   @Test
   public void return_measures_on_leak_period() throws Exception {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto projectSnapshot = db.components().insertProjectAndSnapshot(project);
     setBrowsePermissionOnUser(project);
     MetricDto coverage = insertCoverageMetric();
@@ -151,11 +151,11 @@ public class SearchActionTest {
     MetricDto coverage = insertCoverageMetric();
     MetricDto complexity = insertComplexityMetric();
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project1 = newProjectDto(organizationDto).setName("C");
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto).setName("C");
     SnapshotDto projectSnapshot1 = db.components().insertProjectAndSnapshot(project1);
-    ComponentDto project2 = newProjectDto(organizationDto).setName("A");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto).setName("A");
     SnapshotDto projectSnapshot2 = db.components().insertProjectAndSnapshot(project2);
-    ComponentDto project3 = newProjectDto(organizationDto).setName("B");
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setName("B");
     SnapshotDto projectSnapshot3 = db.components().insertProjectAndSnapshot(project3);
     setBrowsePermissionOnUser(project1, project2, project3);
     dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, project1, projectSnapshot1).setValue(5.5d));
@@ -214,9 +214,9 @@ public class SearchActionTest {
   @Test
   public void only_returns_authorized_projects() {
     MetricDto metricDto = insertComplexityMetric();
-    ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto projectSnapshot1 = db.components().insertProjectAndSnapshot(project1);
-    ComponentDto project2 = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto projectSnapshot2 = db.components().insertProjectAndSnapshot(project2);
     dbClient.measureDao().insert(dbSession,
       newMeasureDto(metricDto, project1, projectSnapshot1).setValue(15.5d),
@@ -232,7 +232,7 @@ public class SearchActionTest {
   @Test
   public void do_not_verify_permissions_if_user_is_root() {
     MetricDto metricDto = insertComplexityMetric();
-    ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto projectSnapshot1 = db.components().insertProjectAndSnapshot(project1);
     dbClient.measureDao().insert(dbSession, newMeasureDto(metricDto, project1, projectSnapshot1).setValue(15.5d));
     db.commit();
@@ -248,7 +248,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_no_metric() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     setBrowsePermissionOnUser(project);
 
     expectedException.expect(IllegalArgumentException.class);
@@ -259,7 +259,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_empty_metric() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     setBrowsePermissionOnUser(project);
 
     expectedException.expect(IllegalArgumentException.class);
@@ -270,7 +270,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_unknown_metric() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     setBrowsePermissionOnUser(project);
     insertComplexityMetric();
 
@@ -303,7 +303,7 @@ public class SearchActionTest {
   @Test
   public void fail_if_more_than_100_project_keys() {
     List<String> keys = IntStream.rangeClosed(1, 101)
-      .mapToObj(i -> db.components().insertProject())
+      .mapToObj(i -> db.components().insertPrivateProject())
       .map(ComponentDto::key)
       .collect(Collectors.toList());
     insertComplexityMetric();
@@ -317,7 +317,7 @@ public class SearchActionTest {
   @Test
   public void does_not_fail_on_100_projects() {
     List<String> keys = IntStream.rangeClosed(1, 100)
-      .mapToObj(i -> db.components().insertProject())
+      .mapToObj(i -> db.components().insertPrivateProject())
       .map(ComponentDto::key)
       .collect(Collectors.toList());
     insertComplexityMetric();
@@ -327,7 +327,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_module() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto module = db.components().insertComponent(newModuleDto(project));
     setBrowsePermissionOnUser(project);
     insertComplexityMetric();
@@ -340,7 +340,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_directory() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto dir = db.components().insertComponent(newDirectory(project, "dir"));
     setBrowsePermissionOnUser(project);
     insertComplexityMetric();
@@ -353,7 +353,7 @@ public class SearchActionTest {
 
   @Test
   public void fail_if_file() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     setBrowsePermissionOnUser(project);
     insertComplexityMetric();
@@ -460,9 +460,9 @@ public class SearchActionTest {
   private List<String> insertJsonExampleData() {
     List<String> projectKeys = new ArrayList<>();
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project1 = newProjectDto(organizationDto).setKey("MY_PROJECT_1").setName("Project 1");
-    ComponentDto project2 = newProjectDto(organizationDto).setKey("MY_PROJECT_2").setName("Project 2");
-    ComponentDto project3 = newProjectDto(organizationDto).setKey("MY_PROJECT_3").setName("Project 3");
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_1").setName("Project 1");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_2").setName("Project 2");
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_3").setName("Project 3");
     projectKeys.addAll(asList(project1.key(), project2.key(), project3.key()));
     db.components().insertComponents(project1, project2, project3);
     SnapshotDto projectSnapshot1 = dbClient.snapshotDao().insert(dbSession, newAnalysis(project1)
index dfc31efbfd4d8fa78babdb6ca84f22fd2eb1d912..3b77d736887b30c38afa1ef3f1a93f254f8d2b4f 100644 (file)
@@ -36,6 +36,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.server.component.ComponentFinder;
@@ -58,7 +59,6 @@ import static org.sonar.api.utils.DateUtils.formatDateTime;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
@@ -92,7 +92,7 @@ public class SearchHistoryActionTest {
 
   @Before
   public void setUp() {
-    project = newProjectDto(db.getDefaultOrganization());
+    project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     analysis = db.components().insertProjectAndSnapshot(project);
     userSession.addProjectPermission(UserRole.USER, project);
     nclocMetric = insertNclocMetric();
@@ -104,7 +104,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void empty_response() {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     wsRequest
       .setComponent(project.getKey())
@@ -172,7 +172,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void pagination_applies_to_analyses() {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     List<String> analysisDates = LongStream.rangeClosed(1, 9)
       .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(i * 1_000_000_000)))
@@ -191,7 +191,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void inclusive_from_and_to_dates() {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     List<String> analysisDates = LongStream.rangeClosed(1, 9)
       .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(System2.INSTANCE.now() + i * 1_000_000_000L)))
@@ -292,7 +292,7 @@ public class SearchHistoryActionTest {
 
   @Test
   public void json_example() {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     long now = parseDateTime("2017-01-23T17:00:53+0100").getTime();
     LongStream.rangeClosed(0, 2)
index ce999c1ac83b7938fe5fb87938f2d7f99982941a..99b06b03cfae0ddfb436a510c74b252c96343646 100644 (file)
@@ -109,7 +109,7 @@ public class AddActionTest {
 
   @Test
   public void add_a_project_notification() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     call(request.setProject(project.getKey()));
 
@@ -118,7 +118,7 @@ public class AddActionTest {
 
   @Test
   public void add_a_global_notification_when_a_project_one_exists() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     call(request.setProject(project.getKey()));
 
     call(request.setProject(null));
@@ -129,7 +129,7 @@ public class AddActionTest {
 
   @Test
   public void add_a_project_notification_when_a_global_one_exists() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     call(request);
 
     call(request.setProject(project.getKey()));
@@ -172,7 +172,7 @@ public class AddActionTest {
 
   @Test
   public void fail_when_unknown_project_dispatcher() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher3]");
index 254a71e135e32f5c49887df037007cc58475496c..83bbe48a3ab71394f77302333acbbf4dfde4d5d1 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.permission.UserPermissionDto;
 import org.sonar.server.exceptions.UnauthorizedException;
@@ -43,7 +44,6 @@ import org.sonarqube.ws.Notifications.Notification;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION;
 import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
@@ -113,8 +113,8 @@ public class ListActionTest {
 
   @Test
   public void filter_unauthorized_projects() {
-    ComponentDto project = addComponent(newProjectDto(db.organizations().insert()).setKey("K1"));
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("K1"));
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, project);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, anotherProject);
     dbSession.commit();
@@ -148,7 +148,7 @@ public class ListActionTest {
 
   @Test
   public void filter_per_project_dispatchers() {
-    ComponentDto project = addComponent(newProjectDto(db.organizations().insert()).setKey("K1"));
+    ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("K1"));
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, project);
     notificationUpdater.add(dbSession, emailChannel.getKey(), "Unknown Notification", project);
     dbSession.commit();
@@ -163,7 +163,7 @@ public class ListActionTest {
   @Test
   public void order_with_global_then_by_channel_and_dispatcher() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = addComponent(newProjectDto(organization).setKey("K1"));
+    ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("K1"));
     notificationUpdater.add(dbSession, twitterChannel.getKey(), NOTIF_MY_NEW_ISSUES, null);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, null);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_NEW_ISSUES, null);
@@ -188,7 +188,7 @@ public class ListActionTest {
   @Test
   public void json_example() {
     OrganizationDto organization = db.organizations().insertForKey("my-org-1");
-    ComponentDto project = addComponent(newProjectDto(organization).setKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
+    ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
     notificationUpdater.add(dbSession, twitterChannel.getKey(), NOTIF_MY_NEW_ISSUES, null);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, null);
     notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_NEW_ISSUES, null);
index befb39e62b1a4f55500fa3dcf4e57625f566bb44..c467a1cc2af42fe34a80c223bf26e7c388d07795 100644 (file)
@@ -119,7 +119,7 @@ public class RemoveActionTest {
 
   @Test
   public void remove_a_project_notification() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, project);
     dbSession.commit();
 
@@ -130,7 +130,7 @@ public class RemoveActionTest {
 
   @Test
   public void fail_when_remove_a_global_notification_when_a_project_one_exists() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, project);
     dbSession.commit();
 
@@ -142,7 +142,7 @@ public class RemoveActionTest {
 
   @Test
   public void fail_when_remove_a_project_notification_when_a_global_one_exists() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, null);
     dbSession.commit();
 
@@ -187,7 +187,7 @@ public class RemoveActionTest {
 
   @Test
   public void fail_when_unknown_project_dispatcher() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher3]");
index 48b9b2871384f90a0c2a0c162831d02151e85e2a..d1a471340bca576ad2a40d0efbfa77d2d29ed6a5 100644 (file)
@@ -224,7 +224,7 @@ public class DeleteActionTest {
   @Test
   public void request_also_deletes_components_of_specified_organization() {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
     ComponentDto directory = db.components().insertComponent(ComponentTesting.newDirectory(module, "a/b"));
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(module, directory));
@@ -255,8 +255,8 @@ public class DeleteActionTest {
     GroupDto otherGroup1 = db.users().insertGroup(otherOrg);
     GroupDto otherGroup2 = db.users().insertGroup(otherOrg);
 
-    ComponentDto projectDto = db.components().insertProject(org);
-    ComponentDto otherProjectDto = db.components().insertProject(otherOrg);
+    ComponentDto projectDto = db.components().insertPrivateProject(org);
+    ComponentDto otherProjectDto = db.components().insertPrivateProject(otherOrg);
 
     db.users().insertPermissionOnAnyone(org, "u1");
     db.users().insertPermissionOnAnyone(otherOrg, "not deleted u1");
index ad1f8e94a40dad75d669702498b3e6b52b2a0a11..900a24451ba5409d4a76142a2403513a7c1418ef 100644 (file)
@@ -121,7 +121,7 @@ public class EnableSupportActionTest {
     OrganizationDto defaultOrganization = db.getDefaultOrganization();
     UserDto user = db.users().insertUser();
     GroupDto sonarUsersGroup = db.users().insertDefaultGroup(defaultOrganization, "sonar-users");
-    ComponentDto project = db.components().insertProject(defaultOrganization);
+    ComponentDto project = db.components().insertPrivateProject(defaultOrganization);
     db.users().insertPermissionOnGroup(sonarUsersGroup, "user");
     db.users().insertProjectPermissionOnGroup(sonarUsersGroup, "codeviewer", project);
     // Should be ignored
index 0f38de627441967ab5948fc59c3a39b1d923c7f6..e52406a05d1c5a4f5aa53a5e37b29cca0c9bd7e1 100644 (file)
@@ -89,7 +89,7 @@ public class RemoveMemberActionTest {
   @Before
   public void setUp() {
     organization = db.organizations().insert();
-    project = db.components().insertProject(organization);
+    project = db.components().insertPrivateProject(organization);
 
     user = db.users().insertUser();
     db.organizations().addMember(organization, user);
@@ -138,7 +138,7 @@ public class RemoveMemberActionTest {
   public void remove_organization_permissions() {
     UserDto anotherUser = db.users().insertUser();
     OrganizationDto anotherOrganization = db.organizations().insert();
-    ComponentDto anotherProject = db.components().insertProject(anotherOrganization);
+    ComponentDto anotherProject = db.components().insertPrivateProject(anotherOrganization);
     assertMember(organization.getUuid(), user);
     db.users().insertPermissionOnUser(organization, user, ADMINISTER);
     db.users().insertPermissionOnUser(organization, user, SCAN);
@@ -213,7 +213,7 @@ public class RemoveMemberActionTest {
   @Test
   public void remove_from_org_properties() {
     OrganizationDto anotherOrganization = db.organizations().insert();
-    ComponentDto anotherProject = db.components().insertProject(anotherOrganization);
+    ComponentDto anotherProject = db.components().insertPrivateProject(anotherOrganization);
     UserDto anotherUser = db.users().insertUser();
     insertProperty("KEY_11", "VALUE", project.getId(), user.getId());
     insertProperty("KEY_12", "VALUE", project.getId(), user.getId());
@@ -231,7 +231,7 @@ public class RemoveMemberActionTest {
   @Test
   public void remove_from_default_assignee_properties() {
     OrganizationDto anotherOrganization = db.organizations().insert();
-    ComponentDto anotherProject = db.components().insertProject(anotherOrganization);
+    ComponentDto anotherProject = db.components().insertPrivateProject(anotherOrganization);
     UserDto anotherUser = db.users().insertUser();
     insertProperty(DEFAULT_ISSUE_ASSIGNEE, user.getLogin(), project.getId(), null);
     insertProperty("ANOTHER_KEY", user.getLogin(), project.getId(), null);
index f2cc950ca9fb83c97aa0ef067c0b323a4946542e..610d63c951a503c3dd1cbc805272e7aa3c46cbac 100644 (file)
@@ -55,7 +55,7 @@ public class GroupPermissionChangerTest {
   public void setUp() throws Exception {
     org = db.organizations().insert();
     group = db.users().insertGroup(org, "a-group");
-    project = db.components().insertProject(org);
+    project = db.components().insertPrivateProject(org);
   }
 
   @Test
index c6052c3eec0672539a9956e579b851f9c9c71648..3445f219e6d8e1416b1f60c9025970485f35d8f6 100644 (file)
@@ -62,7 +62,7 @@ public class PermissionTemplateServiceTest {
   @Test
   public void apply_permission_template() {
     OrganizationDto organization = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
     GroupDto adminGroup = dbTester.users().insertGroup(organization);
     GroupDto userGroup = dbTester.users().insertGroup(organization);
     UserDto user = dbTester.users().insertUser();
index 6843b70e5f09fbb27452d9c47c28de1b7b68cf26..0bafab157d1f3b2beffa5a4f6cc62837601abab4 100644 (file)
@@ -64,7 +64,7 @@ public class UserPermissionChangerTest {
     org2 = db.organizations().insert();
     user1 = db.users().insertUser();
     user2 = db.users().insertUser();
-    project = db.components().insertProject(org1);
+    project = db.components().insertPrivateProject(org1);
   }
 
   @Test
@@ -137,7 +137,7 @@ public class UserPermissionChangerTest {
 
   @Test
   public void remove_project_permission_from_user() {
-    ComponentDto project2 = db.components().insertProject(org1);
+    ComponentDto project2 = db.components().insertPrivateProject(org1);
     db.users().insertPermissionOnUser(user1, ADMINISTER_QUALITY_GATES);
     db.users().insertProjectPermissionOnUser(user1, ISSUE_ADMIN, project);
     db.users().insertProjectPermissionOnUser(user1, USER, project);
index 6b88025dd53308866a8fdb75b3132b3958d8229f..ee915dfcc3b8e60f1c7aaae2a45d07acd306e22e 100644 (file)
@@ -70,8 +70,8 @@ public class PermissionIndexerDaoTest {
 
   @Before
   public void setUp() throws Exception {
-    project1 = componentDbTester.insertProject();
-    project2 = componentDbTester.insertProject();
+    project1 = componentDbTester.insertPrivateProject();
+    project2 = componentDbTester.insertPrivateProject();
     view1 = componentDbTester.insertView();
     view2 = componentDbTester.insertView();
     user1 = userDbTester.insertUser();
@@ -157,7 +157,7 @@ public class PermissionIndexerDaoTest {
   public void select_by_projects_with_high_number_of_projects() throws Exception {
     List<String> projects = new ArrayList<>();
     for (int i = 0; i < 350; i++) {
-      ComponentDto project = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), Integer.toString(i));
+      ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), Integer.toString(i));
       dbClient.componentDao().insert(dbSession, project);
       projects.add(project.uuid());
       GroupPermissionDto dto = new GroupPermissionDto()
index d26711de259455b92262a58a463871ed55203047..aa6234fcde05c4610333ced4cd22a383eb438683 100644 (file)
@@ -273,13 +273,13 @@ public class PermissionIndexerTest {
   }
 
   private ComponentDto createAndIndexProject() {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     fooIndexer.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_CREATION);
     return project;
   }
 
   private ComponentDto createAndIndexProject(OrganizationDto org) {
-    ComponentDto project = componentDbTester.insertProject(org);
+    ComponentDto project = componentDbTester.insertPrivateProject(org);
     fooIndexer.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_CREATION);
     return project;
   }
index 85d258bdb70180ecab3b8ef8763bbc8d3ec6fdd8..3377321814d696c735ca4571f24191b6c56b6ca8 100644 (file)
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID;
@@ -98,7 +98,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void add_permission_to_project_referenced_by_its_id() throws Exception {
     GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     loginAsAdmin(db.getDefaultOrganization());
 
     newRequest()
@@ -114,7 +114,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void add_permission_to_project_referenced_by_its_key() throws Exception {
     GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     loginAsAdmin(db.getDefaultOrganization());
 
     newRequest()
@@ -171,7 +171,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   public void adding_a_project_permission_fails_if_component_is_not_a_project() throws Exception {
     OrganizationDto organizationDto = db.getDefaultOrganization();
     GroupDto group = db.users().insertGroup(organizationDto, "sonar-administrators");
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project, null, "file-uuid"));
     loginAsAdmin(db.getDefaultOrganization());
 
@@ -251,7 +251,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
     GroupDto group = db.users().insertGroup();
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -282,7 +282,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void adding_project_permission_fails_if_not_administrator_of_project() throws Exception {
     GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -300,7 +300,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
   @Test
   public void adding_project_permission_is_allowed_to_project_administrators() throws Exception {
     GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     newRequest()
index 2cc8fa0bfce11cdc51f57c2d117e088a4a965b92..ef71f25a9d7eb58168ad954d5e0a09ae4923c691 100644 (file)
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ORGANIZATION;
@@ -89,7 +89,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
   public void add_permission_to_project_referenced_by_its_id() throws Exception {
     OrganizationDto organization = db.organizations().insert();
     addUserAsMemberOfOrganization(organization);
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     loginAsAdmin(organization);
 
     newRequest()
@@ -104,7 +104,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void add_permission_to_project_referenced_by_its_key() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     loginAsAdmin(db.getDefaultOrganization());
 
     newRequest()
@@ -159,7 +159,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void fail_when_component_is_not_a_project() throws Exception {
-    db.components().insertComponent(newFileDto(newProjectDto(db.organizations().insert(), "project-uuid"), null, "file-uuid"));
+    db.components().insertComponent(newFileDto(newPrivateProjectDto(db.organizations().insert(), "project-uuid"), null, "file-uuid"));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -208,7 +208,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
-    db.components().insertProject();
+    db.components().insertPrivateProject();
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -236,7 +236,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void adding_project_permission_fails_if_not_administrator_of_project() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -253,7 +253,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
    */
   @Test
   public void adding_project_permission_is_allowed_to_project_administrators() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
@@ -268,7 +268,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
 
   @Test
   public void organization_parameter_must_not_be_set_on_project_permissions() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(IllegalArgumentException.class);
index d755750c72f323d82879debee5d1a08ec84f57ed..a911176c5dab4dcbd4a3bd18406ef6adbca5822c 100644 (file)
@@ -23,6 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.security.DefaultGroups;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.GroupDto;
 import org.sonar.server.exceptions.BadRequestException;
@@ -36,7 +37,7 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.SCAN;
@@ -154,11 +155,11 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
   @Test
   public void search_groups_with_project_permissions() throws Exception {
     OrganizationDto organizationDto = db.getDefaultOrganization();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "project-uuid"));
     GroupDto group = db.users().insertGroup(organizationDto, "project-group-name");
     db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
 
-    ComponentDto anotherProject = db.components().insertComponent(newProjectDto(organizationDto));
+    ComponentDto anotherProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
     GroupDto anotherGroup = db.users().insertGroup(organizationDto, "another-project-group-name");
     db.users().insertProjectPermissionOnGroup(anotherGroup, ISSUE_ADMIN, anotherProject);
 
@@ -179,7 +180,7 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
   @Test
   public void return_also_groups_without_permission_when_search_query() throws Exception {
     OrganizationDto organizationDto = db.getDefaultOrganization();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "project-uuid"));
     GroupDto group = db.users().insertGroup(organizationDto, "group-with-permission");
     db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
 
@@ -201,7 +202,7 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
 
   @Test
   public void return_only_groups_with_permission_when_no_search_query() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "project-group-name");
     db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
 
@@ -221,7 +222,7 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
   @Test
   public void return_anyone_group_when_search_query_and_no_param_permission() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "project-uuid"));
     GroupDto group = db.users().insertGroup(organizationDto, "group-with-permission");
     db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, project);
 
@@ -276,7 +277,7 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
 
   @Test
   public void fail_if_project_uuid_and_project_key_are_provided() throws Exception {
-    db.components().insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
+    db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
 
     expectedException.expect(BadRequestException.class);
 
index 5eb2310c45f193fbefc1b675b040ab880955a1a9..f24afce29f42f30f297c7cb839e23dc64837cb3b 100644 (file)
@@ -23,6 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.GroupDto;
 import org.sonar.server.exceptions.BadRequestException;
@@ -36,7 +37,6 @@ import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID;
@@ -90,7 +90,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
   @Test
   public void remove_project_permission() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertPermissionOnGroup(aGroup, ADMINISTER);
     db.users().insertProjectPermissionOnGroup(aGroup, ADMIN, project);
     db.users().insertProjectPermissionOnGroup(aGroup, ISSUE_ADMIN, project);
@@ -126,7 +126,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
   @Test
   public void remove_with_project_key() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertPermissionOnGroup(aGroup, ADMINISTER);
     db.users().insertProjectPermissionOnGroup(aGroup, ADMIN, project);
     db.users().insertProjectPermissionOnGroup(aGroup, ISSUE_ADMIN, project);
@@ -180,7 +180,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
   @Test
   public void fail_when_component_is_not_a_project() throws Exception {
-    ComponentDto file = db.components().insertComponent(newFileDto(newProjectDto(db.organizations().insert()), null, "file-uuid"));
+    ComponentDto file = db.components().insertComponent(newFileDto(ComponentTesting.newPrivateProjectDto(db.organizations().insert()), null, "file-uuid"));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -232,7 +232,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
   @Test
   public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -275,7 +275,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
 
   @Test
   public void removing_project_permission_fails_if_not_administrator_of_project() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -292,7 +292,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
    */
   @Test
   public void removing_project_permission_is_allowed_to_project_administrators() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertProjectPermissionOnGroup(aGroup, CODEVIEWER, project);
     db.users().insertProjectPermissionOnGroup(aGroup, ISSUE_ADMIN, project);
 
index 2972a411324081a460058fbf9b852af79ee447b9..2b75b50ab4e0dc273ba5da9c805b6f27b9b0ef29 100644 (file)
@@ -23,6 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -37,7 +38,7 @@ import static org.sonar.core.permission.GlobalPermissions.PROVISIONING;
 import static org.sonar.core.permission.GlobalPermissions.QUALITY_GATE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES;
@@ -95,7 +96,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
   @Test
   public void remove_permission_from_project() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     db.users().insertProjectPermissionOnUser(user, CODEVIEWER, project);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
     loginAsAdmin(db.getDefaultOrganization());
@@ -111,7 +112,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
   @Test
   public void remove_with_project_key() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
     db.users().insertProjectPermissionOnUser(user, CODEVIEWER, project);
     loginAsAdmin(db.getDefaultOrganization());
@@ -168,7 +169,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
   @Test
   public void fail_when_component_is_not_a_project() throws Exception {
-    db.components().insertComponent(newFileDto(newProjectDto(db.organizations().insert()), null, "file-uuid"));
+    db.components().insertComponent(newFileDto(ComponentTesting.newPrivateProjectDto(db.organizations().insert()), null, "file-uuid"));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -217,7 +218,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
   @Test
   public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
@@ -245,7 +246,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
 
   @Test
   public void removing_project_permission_fails_if_not_administrator_of_project() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.logIn();
 
     expectedException.expect(ForbiddenException.class);
@@ -262,7 +263,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
    */
   @Test
   public void removing_project_permission_is_allowed_to_project_administrators() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertProjectPermissionOnUser(user, CODEVIEWER, project);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
index 4d14fc200ccaaaf46d3d288835a2e1238dd4aa2d..4659cb5090313d43043cb012160754eabc745225 100644 (file)
@@ -25,6 +25,7 @@ import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.ResourceTypesRule;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.GroupDto;
@@ -39,7 +40,7 @@ import static org.sonar.api.server.ws.WebService.Param.PAGE;
 import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
 import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -116,7 +117,7 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
 
   @Test
   public void search_project_permissions_with_project_permission() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
+    ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"));
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     String result = newRequest()
@@ -130,7 +131,7 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
   public void has_projects_ordered_by_name() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
     for (int i = 9; i >= 1; i--) {
-      db.components().insertComponent(newProjectDto(organizationDto)
+      db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)
         .setName("project-name-" + i));
     }
 
@@ -146,8 +147,8 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
 
   @Test
   public void search_by_query_on_name() throws Exception {
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization()).setName("project-name"));
-    componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization()).setName("another-name"));
+    componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("project-name"));
+    componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("another-name"));
 
     String result = newRequest()
       .setParam(TEXT_QUERY, "project")
@@ -160,8 +161,8 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
   @Test
   public void search_by_query_on_key_must_match_exactly() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
-    componentDb.insertProjectAndSnapshot(newProjectDto(organizationDto).setKey("project-key"));
-    componentDb.insertProjectAndSnapshot(newProjectDto(organizationDto).setKey("another-key"));
+    componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("project-key"));
+    componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("another-key"));
 
     String result = newRequest()
       .setParam(TEXT_QUERY, "project-key")
@@ -175,7 +176,7 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
   @Test
   public void handle_more_than_1000_projects() throws Exception {
     for (int i = 1; i <= 1001; i++) {
-      componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid-" + i));
+      componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-" + i));
     }
 
     String result = newRequest()
@@ -191,7 +192,7 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
   public void filter_by_qualifier() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
     db.components().insertComponent(newView(organizationDto, "view-uuid"));
-    db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
+    db.components().insertComponent(newPrivateProjectDto(organizationDto, "project-uuid"));
 
     WsPermissions.SearchProjectPermissionsWsResponse result = newRequest()
       .setParam(PARAM_QUALIFIER, Qualifiers.PROJECT)
@@ -242,14 +243,14 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
   }
 
   private ComponentDto insertClang() {
-    return db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid-2")
+    return db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-2")
       .setName("Clang")
       .setKey("clang")
       .setUuid("ce4c03d6-430f-40a9-b777-ad877c00aa4d"));
   }
 
   private ComponentDto insertJdk7() {
-    return db.components().insertComponent(newProjectDto(db.getDefaultOrganization())
+    return db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization())
       .setName("JDK 7")
       .setKey("net.java.openjdk:jdk7")
       .setUuid("0bd7b1e7-91d6-439e-a607-4a3a9aad3c6a"));
index 7c224c860430ec90822e4cab9a335be72e7af157..45fed320124973ad7e5bf91a7566a4db11516213 100644 (file)
@@ -24,6 +24,7 @@ import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.server.ws.WebService.SelectionMode;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
 import static org.sonar.api.web.UserRole.ISSUE_ADMIN;
 import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
@@ -81,13 +82,13 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
   @Test
   public void search_for_users_with_permission_on_project() throws Exception {
     // User has permission on project
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     UserDto user = db.users().insertUser(newUserDto());
     db.organizations().addMember(db.getDefaultOrganization(), user);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
 
     // User has permission on another project
-    ComponentDto anotherProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto anotherProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     UserDto userHavePermissionOnAnotherProject = db.users().insertUser(newUserDto());
     db.organizations().addMember(db.getDefaultOrganization(), userHavePermissionOnAnotherProject);
     db.users().insertProjectPermissionOnUser(userHavePermissionOnAnotherProject, ISSUE_ADMIN, anotherProject);
@@ -111,7 +112,7 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
   @Test
   public void search_only_for_users_with_permission_when_no_search_query() throws Exception {
     // User have permission on project
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     UserDto user = db.users().insertUser();
     db.organizations().addMember(db.getDefaultOrganization(), user);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
@@ -134,7 +135,7 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
   @Test
   public void search_also_for_users_without_permission_when_filtering_name() throws Exception {
     // User with permission on project
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     UserDto user = db.users().insertUser(newUserDto("with-permission-login", "with-permission-name", "with-permission-email"));
     db.organizations().addMember(db.getDefaultOrganization(), user);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
@@ -158,7 +159,7 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
   @Test
   public void search_also_for_users_without_permission_when_filtering_email() throws Exception {
     // User with permission on project
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     UserDto user = db.users().insertUser(newUserDto("with-permission-login", "with-permission-name", "with-permission-email"));
     db.organizations().addMember(db.getDefaultOrganization(), user);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
@@ -178,7 +179,7 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
   @Test
   public void search_also_for_users_without_permission_when_filtering_login() throws Exception {
     // User with permission on project
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     UserDto user = db.users().insertUser(newUserDto("with-permission-login", "with-permission-name", "with-permission-email"));
     db.organizations().addMember(db.getDefaultOrganization(), user);
     db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
@@ -259,7 +260,7 @@ public class UsersActionTest extends BasePermissionWsTest<UsersAction> {
 
   @Test
   public void fail_if_project_uuid_and_project_key_are_provided() throws Exception {
-    db.components().insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
+    db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
     loginAsAdmin(db.getDefaultOrganization());
 
     expectedException.expect(BadRequestException.class);
index b5f211943d029fb3ea07144b1274ed31f709d96c..e085cf10041b6c0b17566de2ae30e1f813034fc8 100644 (file)
@@ -89,7 +89,7 @@ public class ApplyTemplateActionTest extends BasePermissionWsTest<ApplyTemplateA
     addGroupToTemplate(group1, template2, UserRole.USER);
     addGroupToTemplate(group2, template2, UserRole.USER);
 
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     db.users().insertProjectPermissionOnUser(user1, UserRole.ADMIN, project);
     db.users().insertProjectPermissionOnUser(user2, UserRole.ADMIN, project);
     db.users().insertProjectPermissionOnGroup(group1, UserRole.ADMIN, project);
index c892b6d2376740bf6b65c095fb4e260c57afe5c4..278282d90681056962e9656f8520b7dca3ed84cc 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.Test;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.permission.PermissionQuery;
 import org.sonar.db.permission.template.PermissionTemplateDto;
@@ -39,7 +40,6 @@ import org.sonar.server.permission.ws.BasePermissionWsTest;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ORGANIZATION;
 import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER;
@@ -97,9 +97,9 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
   public void bulk_apply_template_by_template_uuid() throws Exception {
     // this project should not be applied the template
     OrganizationDto otherOrganization = db.organizations().insert();
-    db.components().insertProject(otherOrganization);
+    db.components().insertPrivateProject(otherOrganization);
 
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     ComponentDto view = db.components().insertView(organization);
     loginAsAdmin(organization);
 
@@ -126,7 +126,7 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
 
   @Test
   public void bulk_apply_template_by_template_name() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization));
     loginAsAdmin(organization);
 
     newRequest()
@@ -139,7 +139,7 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
 
   @Test
   public void apply_template_by_qualifier() throws Exception {
-    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization));
     ComponentDto view = db.components().insertComponent(newView(organization));
     loginAsAdmin(organization);
 
@@ -153,12 +153,12 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
 
   @Test
   public void apply_template_by_query_on_name_and_key() throws Exception {
-    ComponentDto projectFoundByKey = newProjectDto(organization).setKey("sonar");
+    ComponentDto projectFoundByKey = ComponentTesting.newPrivateProjectDto(organization).setKey("sonar");
     db.components().insertProjectAndSnapshot(projectFoundByKey);
-    ComponentDto projectFoundByName = newProjectDto(organization).setName("name-sonar-name");
+    ComponentDto projectFoundByName = ComponentTesting.newPrivateProjectDto(organization).setName("name-sonar-name");
     db.components().insertProjectAndSnapshot(projectFoundByName);
     // match must be exact on key
-    ComponentDto projectUntouched = newProjectDto(organization).setKey("new-sonar").setName("project-name");
+    ComponentDto projectUntouched = ComponentTesting.newPrivateProjectDto(organization).setKey("new-sonar").setName("project-name");
     db.components().insertProjectAndSnapshot(projectUntouched);
     loginAsAdmin(organization);
 
index 3a4336b6938490530d2ab326161a1d452d0e4277..37b7af4377d008dd01f62bc182b6c364eef38f9d 100644 (file)
@@ -141,6 +141,6 @@ public class BackendCleanupTest {
   }
 
   private ComponentDoc newComponentDoc() {
-    return ComponentIndexer.toDocument(ComponentTesting.newProjectDto(organization));
+    return ComponentIndexer.toDocument(ComponentTesting.newPrivateProjectDto(organization));
   }
 }
index 934d94466572fbadd525f97a3108730ea19c4233..36cb89ea124dd6fe097ac0f3ef9f836e2f8def9b 100644 (file)
@@ -74,9 +74,9 @@ public class BulkDeleteActionTest {
   @Test
   public void system_administrator_deletes_projects_by_uuids_in_all_organizations() throws Exception {
     userSession.logIn().setSystemAdministrator();
-    ComponentDto toDeleteInOrg1 = db.components().insertProject(org1);
-    ComponentDto toDeleteInOrg2 = db.components().insertProject(org2);
-    ComponentDto toKeep = db.components().insertProject(org2);
+    ComponentDto toDeleteInOrg1 = db.components().insertPrivateProject(org1);
+    ComponentDto toDeleteInOrg2 = db.components().insertPrivateProject(org2);
+    ComponentDto toKeep = db.components().insertPrivateProject(org2);
 
     WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
       .setParam("ids", toDeleteInOrg1.uuid() + "," + toDeleteInOrg2.uuid())
@@ -89,9 +89,9 @@ public class BulkDeleteActionTest {
   @Test
   public void system_administrator_deletes_projects_by_keys_in_all_organizations() throws Exception {
     userSession.logIn().setSystemAdministrator();
-    ComponentDto toDeleteInOrg1 = db.components().insertProject(org1);
-    ComponentDto toDeleteInOrg2 = db.components().insertProject(org2);
-    ComponentDto toKeep = db.components().insertProject(org2);
+    ComponentDto toDeleteInOrg1 = db.components().insertPrivateProject(org1);
+    ComponentDto toDeleteInOrg2 = db.components().insertPrivateProject(org2);
+    ComponentDto toKeep = db.components().insertPrivateProject(org2);
 
     WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
       .setParam("keys", toDeleteInOrg1.key() + "," + toDeleteInOrg2.key())
@@ -104,8 +104,8 @@ public class BulkDeleteActionTest {
   @Test
   public void projects_that_dont_exist_are_ignored_and_dont_break_bulk_deletion() throws Exception {
     userSession.logIn().setSystemAdministrator();
-    ComponentDto toDelete1 = db.components().insertProject(org1);
-    ComponentDto toDelete2 = db.components().insertProject(org1);
+    ComponentDto toDelete1 = db.components().insertPrivateProject(org1);
+    ComponentDto toDelete2 = db.components().insertPrivateProject(org1);
 
     WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
       .setParam("keys", toDelete1.key() + ",missing," + toDelete2.key() + ",doesNotExist")
@@ -118,7 +118,7 @@ public class BulkDeleteActionTest {
   @Test
   public void throw_ForbiddenException_if_organization_administrator_does_not_set_organization_parameter() throws Exception {
     userSession.logIn().addPermission(ADMINISTER, org1);
-    ComponentDto project = db.components().insertProject(org1);
+    ComponentDto project = db.components().insertPrivateProject(org1);
 
     expectedException.expect(ForbiddenException.class);
     expectedException.expectMessage("Insufficient privileges");
@@ -133,8 +133,8 @@ public class BulkDeleteActionTest {
   @Test
   public void organization_administrator_deletes_projects_by_keys_in_his_organization() throws Exception {
     userSession.logIn().addPermission(ADMINISTER, org1);
-    ComponentDto toDelete = db.components().insertProject(org1);
-    ComponentDto cantBeDeleted = db.components().insertProject(org2);
+    ComponentDto toDelete = db.components().insertPrivateProject(org1);
+    ComponentDto cantBeDeleted = db.components().insertPrivateProject(org2);
 
     WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
       .setParam("organization", org1.getKey())
index e053e8e24e7060571a300436522e6aea5e7e5716..25ec4e611d4e150eac48d1c15dcf024c6a6cd245 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.component.ComponentService;
@@ -56,7 +57,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_DRY_RUN;
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM;
@@ -96,9 +96,9 @@ public class BulkUpdateKeyActionTest {
   @Test
   public void json_example() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto).setKey("my_project"));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("my_project"));
     componentDb.insertComponent(newModuleDto(project).setKey("my_project:module_1"));
-    ComponentDto anotherProject = componentDb.insertComponent(newProjectDto(organizationDto).setKey("another_project"));
+    ComponentDto anotherProject = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("another_project"));
     componentDb.insertComponent(newModuleDto(anotherProject).setKey("my_new_project:module_1"));
     ComponentDto module2 = componentDb.insertComponent(newModuleDto(project).setKey("my_project:module_2"));
     componentDb.insertComponent(newFileDto(module2, null));
@@ -145,7 +145,7 @@ public class BulkUpdateKeyActionTest {
   @Test
   public void bulk_update_provisioned_project_key() {
     String newKey = "provisionedProject2";
-    ComponentDto provisionedProject = componentDb.insertProject();
+    ComponentDto provisionedProject = componentDb.insertPrivateProject();
 
     callByKey(provisionedProject.key(), provisionedProject.getKey(), newKey);
 
@@ -154,8 +154,8 @@ public class BulkUpdateKeyActionTest {
 
   @Test
   public void fail_to_bulk_if_a_component_already_exists_with_the_same_key() {
-    componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("my_project"));
-    componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("your_project"));
+    componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("my_project"));
+    componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("your_project"));
 
     expectedException.expect(BadRequestException.class);
     expectedException.expectMessage("Impossible to update key: a component with key \"your_project\" already exists.");
@@ -259,7 +259,7 @@ public class BulkUpdateKeyActionTest {
   }
 
   private ComponentDto insertMyProject() {
-    return componentDb.insertComponent(newProjectDto(db.organizations().insert()).setKey(MY_PROJECT_KEY));
+    return componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey(MY_PROJECT_KEY));
   }
 
   private BulkUpdateKeyWsResponse callDryRunByUuid(@Nullable String uuid, @Nullable String from, @Nullable String to) {
index eba3ee37746106e10a990cd9147df10628ef7fe3..7f80e9b4cf9fda3a96b6cbfe8202bdf21c1f5201 100644 (file)
@@ -79,7 +79,7 @@ public class DeleteActionTest {
 
   @Test
   public void organization_administrator_deletes_project_by_id() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addPermission(ADMINISTER, project.getOrganizationUuid());
 
     WsTester.TestRequest request = newRequest().setParam(PARAM_PROJECT_ID, project.uuid());
@@ -90,7 +90,7 @@ public class DeleteActionTest {
 
   @Test
   public void organization_administrator_deletes_project_by_key() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addPermission(ADMINISTER, project.getOrganizationUuid());
 
     call(newRequest().setParam(PARAM_PROJECT, project.key()));
@@ -106,7 +106,7 @@ public class DeleteActionTest {
 
   @Test
   public void project_administrator_deletes_the_project_by_uuid() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     call(newRequest().setParam(PARAM_PROJECT_ID, project.uuid()));
@@ -116,7 +116,7 @@ public class DeleteActionTest {
 
   @Test
   public void project_administrator_deletes_the_project_by_key() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
     userSessionRule.logIn().addProjectPermission(UserRole.ADMIN, project);
 
     call(newRequest().setParam(PARAM_PROJECT, project.key()));
@@ -126,7 +126,7 @@ public class DeleteActionTest {
 
   @Test
   public void return_403_if_not_project_admin_nor_org_admin() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
 
     userSessionRule.logIn()
       .addProjectPermission(UserRole.CODEVIEWER, project)
@@ -139,7 +139,7 @@ public class DeleteActionTest {
 
   @Test
   public void return_401_if_not_logged_in() throws Exception {
-    ComponentDto project = componentDbTester.insertProject();
+    ComponentDto project = componentDbTester.insertPrivateProject();
 
     userSessionRule.anonymous();
     expectedException.expect(UnauthorizedException.class);
index 2292a766e9e155e7d9c0d1ce4c3a5d51de4e8964..e73a3405a6a94b9b7bb27a59d8155a40a45499d4 100644 (file)
@@ -188,14 +188,14 @@ public class GhostsActionTest {
   @Test
   public void ghost_projects_base_on_json_example() throws Exception {
     OrganizationDto organization = db.organizations().insert();
-    ComponentDto hBaseProject = ComponentTesting.newProjectDto(organization, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
+    ComponentDto hBaseProject = ComponentTesting.newPrivateProjectDto(organization, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
       .setKey("org.apache.hbas:hbase")
       .setName("HBase")
       .setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"));
     dbClient.componentDao().insert(db.getSession(), hBaseProject);
     dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(hBaseProject)
       .setStatus(STATUS_UNPROCESSED));
-    ComponentDto roslynProject = ComponentTesting.newProjectDto(organization, "c526ef20-131b-4486-9357-063fa64b5079")
+    ComponentDto roslynProject = ComponentTesting.newPrivateProjectDto(organization, "c526ef20-131b-4486-9357-063fa64b5079")
       .setKey("com.microsoft.roslyn:roslyn")
       .setName("Roslyn")
       .setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
@@ -241,13 +241,13 @@ public class GhostsActionTest {
   }
 
   private ComponentDto insertGhostProject(OrganizationDto organization, Consumer<ComponentDto> consumer) {
-    ComponentDto project = db.components().insertProject(organization, consumer);
+    ComponentDto project = db.components().insertPrivateProject(organization, consumer);
     db.components().insertSnapshot(project, dto -> dto.setStatus(STATUS_UNPROCESSED));
     return project;
   }
 
   private ComponentDto insertActiveProject(OrganizationDto organization) {
-    ComponentDto project = db.components().insertProject(organization);
+    ComponentDto project = db.components().insertPrivateProject(organization);
     db.components().insertSnapshot(project, dto -> dto.setStatus(STATUS_PROCESSED));
     return project;
   }
index cb19ed6b29544d77a316135e118fcf9ee43a66c7..a732a8ead2dd5953337bbda32aed829dae7c8d80 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
@@ -39,7 +40,6 @@ import org.sonar.server.ws.WsActionTester;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 
 public class IndexActionTest {
@@ -68,9 +68,9 @@ public class IndexActionTest {
   @Test
   public void search_all_projects() throws Exception {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(null, null, null);
 
@@ -79,8 +79,8 @@ public class IndexActionTest {
 
   @Test
   public void search_projects_with_modules() throws Exception {
-    ComponentDto project1 = newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
-    ComponentDto project2 = newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
     insertProjectsAuthorizedForUser(project1, project2);
     db.components().insertComponents(
       newModuleDto(project1).setKey("org.jenkins-ci.plugins:sonar-common").setName("Common"),
@@ -94,9 +94,9 @@ public class IndexActionTest {
   @Test
   public void search_project_by_key() throws Exception {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call("org.jenkins-ci.plugins:sonar", null, null);
 
@@ -105,11 +105,11 @@ public class IndexActionTest {
 
   @Test
   public void search_project_by_id() throws Exception {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
     insertProjectsAuthorizedForUser(
       project,
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(Long.toString(project.getId()), null, null);
 
@@ -119,9 +119,9 @@ public class IndexActionTest {
   @Test
   public void search_projects_by_name() throws Exception {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(null, "Plu", null);
 
@@ -130,8 +130,8 @@ public class IndexActionTest {
 
   @Test
   public void search_projects_with_modules_by_name() throws Exception {
-    ComponentDto project1 = newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
-    ComponentDto project2 = newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
     insertProjectsAuthorizedForUser(project1, project2);
     db.components().insertComponents(
       newModuleDto(project1).setKey("org.jenkins-ci.plugins:sonar-common-db").setName("Jenkins Common DB"),
@@ -146,9 +146,9 @@ public class IndexActionTest {
   @Test
   public void return_empty_list_when_no_project_match_search() throws Exception {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(null, "Unknown", null);
 
@@ -158,10 +158,10 @@ public class IndexActionTest {
   @Test
   public void return_only_projects_authorized_for_user() throws Exception {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"));
     db.components()
-      .insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      .insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(null, null, null);
 
@@ -170,7 +170,7 @@ public class IndexActionTest {
 
   @Test
   public void do_not_verify_permissions_if_user_is_root() throws Exception {
-    ComponentDto project = db.components().insertProject(p -> p.setKey("P1").setName("POne"));
+    ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("P1").setName("POne"));
 
     String result = call(null, null, null);
 
@@ -193,9 +193,9 @@ public class IndexActionTest {
   @Test
   public void test_example() {
     insertProjectsAuthorizedForUser(
-      newProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
-      newProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
 
     String result = call(null, null, null);
 
index 21ce68ce276b603f95f7fe553dada8a452a18b47..32b4feee1187ab0ccf74ac029bb8778e3d62d2bc 100644 (file)
@@ -88,7 +88,7 @@ public class ProvisionedActionTest {
   @Test
   public void all_provisioned_projects_without_analyzed_projects() throws Exception {
     OrganizationDto org = db.organizations().insert();
-    ComponentDto analyzedProject = ComponentTesting.newProjectDto(org, "analyzed-uuid-1");
+    ComponentDto analyzedProject = ComponentTesting.newPrivateProjectDto(org, "analyzed-uuid-1");
     db.components().insertComponents(newProvisionedProject(org, "1"), newProvisionedProject(org, "2"), analyzedProject);
     db.components().insertSnapshot(SnapshotTesting.newAnalysis(analyzedProject));
     userSessionRule.logIn().addPermission(PROVISION_PROJECTS, org);
@@ -169,11 +169,11 @@ public class ProvisionedActionTest {
   @Test
   public void provisioned_projects_as_defined_in_the_example() throws Exception {
     OrganizationDto org = db.organizations().insert();
-    ComponentDto hBaseProject = ComponentTesting.newProjectDto(org, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
+    ComponentDto hBaseProject = ComponentTesting.newPrivateProjectDto(org, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
       .setKey("org.apache.hbas:hbase")
       .setName("HBase")
       .setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"));
-    ComponentDto roslynProject = ComponentTesting.newProjectDto(org, "c526ef20-131b-4486-9357-063fa64b5079")
+    ComponentDto roslynProject = ComponentTesting.newPrivateProjectDto(org, "c526ef20-131b-4486-9357-063fa64b5079")
       .setKey("com.microsoft.roslyn:roslyn")
       .setName("Roslyn")
       .setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
@@ -213,7 +213,7 @@ public class ProvisionedActionTest {
 
   private static ComponentDto newProvisionedProject(OrganizationDto organizationDto, String uuid) {
     return ComponentTesting
-      .newProjectDto(organizationDto, "provisioned-uuid-" + uuid)
+      .newPrivateProjectDto(organizationDto, "provisioned-uuid-" + uuid)
       .setName("provisioned-name-" + uuid)
       .setKey("provisioned-key-" + uuid);
   }
index ca81752ed4debf93338468c22d9bc88af9d496c4..7b159ea5114f8503e4a175e25c485e1fc2613208 100644 (file)
@@ -31,6 +31,7 @@ import org.junit.rules.ExpectedException;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -55,7 +56,7 @@ import static org.sonar.core.util.Protobuf.setNullable;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
@@ -85,8 +86,8 @@ public class SearchActionTest {
   public void search_by_key_query() throws IOException {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     db.components().insertComponents(
-      newProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
-      newProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
 
     SearchWsResponse response = call(SearchWsRequest.builder().setQuery("project-_%-key").build());
 
@@ -97,7 +98,7 @@ public class SearchActionTest {
   public void search_projects_when_no_qualifier_set() throws IOException {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     db.components().insertComponents(
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
       newView(db.getDefaultOrganization()));
 
     SearchWsResponse response = call(SearchWsRequest.builder().build());
@@ -108,13 +109,13 @@ public class SearchActionTest {
   @Test
   public void search_projects() throws IOException {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
-    ComponentDto project = newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1);
     ComponentDto module = newModuleDto(project);
     ComponentDto directory = newDirectory(module, "dir");
     ComponentDto file = newFileDto(directory);
     db.components().insertComponents(
       project, module, directory, file,
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
       newView(db.getDefaultOrganization()));
 
     SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(singletonList("TRK")).build());
@@ -126,7 +127,7 @@ public class SearchActionTest {
   public void search_views() throws IOException {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     db.components().insertComponents(
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
       newView(db.getDefaultOrganization()).setKey("view1"));
 
     SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(singletonList("VW")).build());
@@ -138,7 +139,7 @@ public class SearchActionTest {
   public void search_projects_and_views() throws IOException {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     db.components().insertComponents(
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
       newView(db.getDefaultOrganization()).setKey("view1"));
 
     SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(asList("TRK", "VW")).build());
@@ -151,9 +152,9 @@ public class SearchActionTest {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     OrganizationDto otherOrganization = db.organizations().insert();
     db.components().insertComponents(
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
-      newProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
-      newProjectDto(otherOrganization).setKey(PROJECT_KEY_3));
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
+      ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
+      ComponentTesting.newPrivateProjectDto(otherOrganization).setKey(PROJECT_KEY_3));
 
     SearchWsResponse response = call(SearchWsRequest.builder().build());
 
@@ -165,9 +166,9 @@ public class SearchActionTest {
     OrganizationDto organization1 = db.organizations().insert();
     OrganizationDto organization2 = db.organizations().insert();
     userSession.addPermission(ADMINISTER, organization1);
-    ComponentDto project1 = newProjectDto(organization1);
-    ComponentDto project2 = newProjectDto(organization1);
-    ComponentDto project3 = newProjectDto(organization2);
+    ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organization1);
+    ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organization1);
+    ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organization2);
     db.components().insertComponents(project1, project2, project3);
 
     SearchWsResponse response = call(SearchWsRequest.builder().setOrganization(organization1.getKey()).build());
@@ -180,7 +181,7 @@ public class SearchActionTest {
     userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
     List<ComponentDto> componentDtoList = new ArrayList<>();
     for (int i = 1; i <= 9; i++) {
-      componentDtoList.add(newProjectDto(db.getDefaultOrganization(), "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
+      componentDtoList.add(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
     }
     db.components().insertComponents(componentDtoList.toArray(new ComponentDto[] {}));
 
@@ -257,8 +258,8 @@ public class SearchActionTest {
     OrganizationDto organization = db.organizations().insertForKey("my-org-1");
     userSession.addPermission(ADMINISTER, organization);
     db.components().insertComponents(
-      newProjectDto(organization, "project-uuid-1").setName("Project Name 1").setKey("project-key-1"),
-      newProjectDto(organization, "project-uuid-2").setName("Project Name 1").setKey("project-key-2"));
+      newPrivateProjectDto(organization, "project-uuid-1").setName("Project Name 1").setKey("project-key-1"),
+      newPrivateProjectDto(organization, "project-uuid-2").setName("Project Name 1").setKey("project-key-2"));
 
     String response = ws.newRequest()
       .setMediaType(MediaTypes.JSON)
index b40dfdd5048dc31cf36afa372c8cb553e08770e6..2cb6c74d0e57c5c81563d34b674ff94eef5fb8bd 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentLinkDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.organization.OrganizationDto;
@@ -48,7 +49,7 @@ import org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse.Project;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
@@ -124,9 +125,9 @@ public class SearchMyProjectsActionTest {
   @Test
   public void sort_projects_by_name() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto b_project = db.components().insertComponent(newProjectDto(organizationDto).setName("B_project_name"));
-    ComponentDto c_project = db.components().insertComponent(newProjectDto(organizationDto).setName("c_project_name"));
-    ComponentDto a_project = db.components().insertComponent(newProjectDto(organizationDto).setName("A_project_name"));
+    ComponentDto b_project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("B_project_name"));
+    ComponentDto c_project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("c_project_name"));
+    ComponentDto a_project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("A_project_name"));
 
     db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, b_project);
     db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, a_project);
@@ -143,7 +144,7 @@ public class SearchMyProjectsActionTest {
   public void paginate_projects() {
     OrganizationDto organizationDto = db.organizations().insert();
     for (int i = 0; i < 10; i++) {
-      ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto).setName("project-" + i));
+      ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project-" + i));
       db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
     }
 
@@ -209,7 +210,7 @@ public class SearchMyProjectsActionTest {
     OrganizationDto org = db.organizations().insert();
     ComponentDto jdk7 = insertJdk7(org);
     ComponentDto cLang = insertClang(org);
-    ComponentDto sonarqube = db.components().insertProject(org);
+    ComponentDto sonarqube = db.components().insertPrivateProject(org);
 
     GroupDto group = db.users().insertGroup(org);
     db.users().insertMember(group, user);
@@ -241,13 +242,13 @@ public class SearchMyProjectsActionTest {
   }
 
   private ComponentDto insertClang(OrganizationDto organizationDto) {
-    return db.components().insertComponent(newProjectDto(organizationDto, Uuids.UUID_EXAMPLE_01)
+    return db.components().insertComponent(newPrivateProjectDto(organizationDto, Uuids.UUID_EXAMPLE_01)
       .setName("Clang")
       .setKey("clang"));
   }
 
   private ComponentDto insertJdk7(OrganizationDto organizationDto) {
-    return db.components().insertComponent(newProjectDto(organizationDto, Uuids.UUID_EXAMPLE_02)
+    return db.components().insertComponent(newPrivateProjectDto(organizationDto, Uuids.UUID_EXAMPLE_02)
       .setName("JDK 7")
       .setKey("net.java.openjdk:jdk7")
       .setDescription("JDK"));
index 7808a3039c04bca381b2086607bd918151f300e1..67f3007b1de7c67a14df8ada1be44256f02fbbae 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.component.ComponentService;
 import org.sonar.server.exceptions.NotFoundException;
@@ -43,7 +44,6 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM;
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID;
 import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO;
@@ -129,7 +129,7 @@ public class UpdateKeyActionTest {
   }
 
   private ComponentDto insertProject() {
-    return componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    return componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
   }
 
   private String callByUuid(@Nullable String uuid, @Nullable String newKey) {
index e4192a16d39c1c899ddad30b4eb43fb36277f9a3..7b2b504570fdcdc70708000d2494c69b05bca5aa 100644 (file)
@@ -34,6 +34,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.event.EventDto;
@@ -49,7 +50,7 @@ import org.sonarqube.ws.client.projectanalysis.CreateEventRequest;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.component.SnapshotTesting.newSnapshot;
@@ -84,7 +85,7 @@ public class CreateEventActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto analysis = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newAnalysis(project).setUuid("A2"));
     db.commit();
     uuidFactory = mock(UuidFactory.class);
@@ -103,7 +104,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_event_in_db() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -129,7 +130,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_event_as_project_admin() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "P1");
+    ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "P1");
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -144,7 +145,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_version_event() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -160,7 +161,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_other_event_with_ws_response() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -181,7 +182,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_event_without_description() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -198,7 +199,7 @@ public class CreateEventActionTest {
 
   @Test
   public void create_2_version_events_on_same_project() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto firstAnalysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder firstRequest = CreateEventRequest.builder()
       .setAnalysis(firstAnalysis.getUuid())
@@ -221,7 +222,7 @@ public class CreateEventActionTest {
 
   @Test
   public void fail_if_not_blank_name() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder().setAnalysis(analysis.getUuid()).setName("    ");
     logInAsProjectAdministrator(project);
@@ -249,7 +250,7 @@ public class CreateEventActionTest {
 
   @Test
   public void fail_if_2_version_events_on_the_same_analysis() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -266,7 +267,7 @@ public class CreateEventActionTest {
 
   @Test
   public void fail_if_2_other_events_on_same_analysis_with_same_name() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
@@ -283,7 +284,7 @@ public class CreateEventActionTest {
 
   @Test
   public void fail_if_category_other_than_authorized() {
-    ComponentDto project = newProjectDto(db.getDefaultOrganization());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     logInAsProjectAdministrator(project);
 
@@ -330,7 +331,7 @@ public class CreateEventActionTest {
 
   @Test
   public void throw_ForbiddenException_if_not_project_administrator() {
-    SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "P1"));
+    SnapshotDto analysis = db.components().insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), "P1"));
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
       .setCategory(VERSION)
index 01be23ac7e22f61e8c06078db399691eb8bbd6e0..246c794fe27c045da8ca627887b96a0fa39e67c0 100644 (file)
@@ -56,7 +56,7 @@ public class DeleteActionTest {
 
   @Test
   public void project_administrator_deletes_analysis() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setLast(false).setStatus(STATUS_PROCESSED));
     db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setLast(true).setStatus(STATUS_PROCESSED));
     logInAsProjectAdministrator(project);
@@ -80,7 +80,7 @@ public class DeleteActionTest {
 
   @Test
   public void last_analysis_cannot_be_deleted() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setLast(true));
     logInAsProjectAdministrator(project);
 
@@ -102,7 +102,7 @@ public class DeleteActionTest {
 
   @Test
   public void fail_when_analysis_is_unprocessed() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setLast(false).setStatus(STATUS_UNPROCESSED));
     logInAsProjectAdministrator(project);
 
@@ -114,7 +114,7 @@ public class DeleteActionTest {
 
   @Test
   public void fail_when_not_enough_permission() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setLast(false));
     userSession.logIn();
 
index b298e3e799a64db264ee05fcca2afdea579e24a7..4bb5a15b3bccfe855ab90759960d0f06307847ed 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.event.EventDto;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -40,7 +41,7 @@ import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.WsActionTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.event.EventTesting.newEvent;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION;
@@ -60,7 +61,7 @@ public class DeleteEventActionTest {
 
   @Test
   public void delete_event() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     db.events().insertEvent(newEvent(analysis).setUuid("E1"));
     db.events().insertEvent(newEvent(analysis).setUuid("E2"));
@@ -74,7 +75,7 @@ public class DeleteEventActionTest {
 
   @Test
   public void delete_version_event() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setVersion("5.6.3").setLast(false));
     db.events().insertEvent(newEvent(analysis).setUuid("E1").setCategory(VERSION.getLabel()));
     logInAsProjectAdministrator(project);
@@ -87,7 +88,7 @@ public class DeleteEventActionTest {
 
   @Test
   public void fail_if_version_for_last_analysis() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setVersion("5.6.3").setLast(true));
     db.events().insertEvent(newEvent(analysis).setUuid("E1").setCategory(VERSION.getLabel()));
     logInAsProjectAdministrator(project);
@@ -100,7 +101,7 @@ public class DeleteEventActionTest {
 
   @Test
   public void fail_if_category_different_than_other_and_version() {
-    ComponentDto project = newProjectDto(db.organizations().insert(), "P1");
+    ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "P1");
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     db.events().insertEvent(newEvent(analysis).setUuid("E1").setCategory("Profile"));
     logInAsProjectAdministrator(project);
@@ -121,7 +122,7 @@ public class DeleteEventActionTest {
 
   @Test
   public void fail_if_not_enough_permission() {
-    SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto(db.organizations().insert()));
+    SnapshotDto analysis = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     db.events().insertEvent(newEvent(analysis).setUuid("E1"));
     userSession.logIn();
 
index d4ce3ff2a47008d086d221cdc3204b9138c82a2b..43bbcfd2f6c8493725ef6d257f35f9c45cdf35d0 100644 (file)
@@ -22,11 +22,11 @@ package org.sonar.server.projectanalysis.ws;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.event.EventDto;
 import org.sonar.db.event.EventTesting;
 import org.sonar.db.organization.OrganizationTesting;
 
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE;
 
@@ -43,6 +43,6 @@ public class EventValidatorTest {
   }
 
   private EventDto newEvent() {
-    return EventTesting.newEvent(newAnalysis(newProjectDto(OrganizationTesting.newOrganizationDto())));
+    return EventTesting.newEvent(newAnalysis(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto())));
   }
 }
index d9a22a65061ed1d014d852e1068f27769ef65013..2a5567bb8911b7f47f05bab6d21820e8f2241401 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.event.EventDto;
 import org.sonar.db.organization.OrganizationDto;
@@ -52,7 +53,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.core.util.Protobuf.setNullable;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.event.EventTesting.newEvent;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
@@ -79,7 +79,7 @@ public class SearchActionTest {
   @Test
   public void json_example() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto).setKey(KEY_PROJECT_EXAMPLE_001));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(KEY_PROJECT_EXAMPLE_001));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(parseDateTime("2016-12-11T17:12:45+0100").getTime()));
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(parseDateTime("2016-12-12T17:12:45+0100").getTime()));
@@ -104,7 +104,7 @@ public class SearchActionTest {
 
   @Test
   public void return_analyses_ordered_by_analysis_date() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
     db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
@@ -121,7 +121,7 @@ public class SearchActionTest {
 
   @Test
   public void return_only_processed_analyses() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
     db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setStatus(SnapshotDto.STATUS_UNPROCESSED));
@@ -135,10 +135,10 @@ public class SearchActionTest {
   @Test
   public void return_events() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto).setKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
-    SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(newProjectDto(organizationDto)).setUuid("A42"));
+    SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(ComponentTesting.newPrivateProjectDto(organizationDto)).setUuid("A42"));
     EventDto e1 = db.events().insertEvent(newEvent(a1).setUuid("E1").setName("N1").setCategory(EventCategory.QUALITY_GATE.getLabel()).setDescription("D1"));
     EventDto e2 = db.events().insertEvent(newEvent(a1).setUuid("E2").setName("N2").setCategory(VERSION.getLabel()).setDescription("D2"));
     db.events().insertEvent(newEvent(a42));
@@ -155,7 +155,7 @@ public class SearchActionTest {
 
   @Test
   public void paginate_analyses() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     IntStream.rangeClosed(1, 9).forEach(i -> db.components().insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000L * i).setUuid("A" + i)));
 
@@ -171,7 +171,7 @@ public class SearchActionTest {
 
   @Test
   public void filter_by_category() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2"));
@@ -192,7 +192,7 @@ public class SearchActionTest {
 
   @Test
   public void paginate_with_filter_on_category() {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("P1"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
@@ -231,7 +231,7 @@ public class SearchActionTest {
   @Test
   public void fail_if_not_enough_permissions() {
     userSession.anonymous();
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     expectedException.expect(ForbiddenException.class);
 
index 2524d7e2f3673a0081cc272e49015d0514aad45f..bae882ed3c11ba10a9b19c8039aeb9dd2e424361 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.event.EventDto;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -42,7 +43,6 @@ import org.sonarqube.ws.ProjectAnalyses.UpdateEventResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.util.Protobuf.setNullable;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.event.EventTesting.newEvent;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -66,7 +66,7 @@ public class UpdateEventActionTest {
 
   @Test
   public void json_example() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setUuid("A2"));
     db.events().insertEvent(newEvent(analysis)
       .setUuid("E1")
@@ -159,7 +159,7 @@ public class UpdateEventActionTest {
 
   @Test
   public void throw_ForbiddenException_if_not_project_administrator() {
-    ComponentDto project = newProjectDto(db.organizations().insert());
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
     db.events().insertEvent(newEvent(analysis).setUuid("E1"));
     userSession.logIn().addProjectPermission(UserRole.USER, project);
@@ -237,7 +237,7 @@ public class UpdateEventActionTest {
   }
 
   private SnapshotDto createAnalysisAndLogInAsProjectAdministrator(String version) {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setVersion(version));
     logInAsProjectAdministrator(project);
     return analysis;
index 81fc3651c4f20ed261536bd6969f537da73a23b7..6ff4fb3cb616e03283091d5d12c1a102a2d3bdcd 100644 (file)
@@ -202,7 +202,7 @@ public class CreateActionTest {
   private ComponentDto insertProject() {
     OrganizationDto org = db.organizations().insert();
     return db.components().insertComponent(
-      ComponentTesting.newProjectDto(org, PROJECT_UUID).setKey(PROJECT_KEY));
+      ComponentTesting.newPrivateProjectDto(org, PROJECT_UUID).setKey(PROJECT_KEY));
   }
 
   private void createAndTest(ComponentDto project, String name, String url, String type) throws IOException {
index a48d7fa38b956d0e773f829657efac55ea3418a4..f6b7d0cc31b4ba090b2c8d7edc3d8d34c581724c 100644 (file)
@@ -43,7 +43,7 @@ import org.sonarqube.ws.WsProjectLinks.SearchWsResponse;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID;
@@ -145,7 +145,7 @@ public class SearchActionTest {
 
   @Test
   public void request_does_not_fail_when_link_has_no_name() throws IOException {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentLinkDto foo = new ComponentLinkDto().setComponentUuid(project.uuid()).setHref("foo").setType("type");
     insertLink(foo);
     logInAsProjectAdministrator(project);
@@ -155,7 +155,7 @@ public class SearchActionTest {
 
   @Test
   public void request_does_not_fail_when_link_has_no_type() throws IOException {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     ComponentLinkDto foo = new ComponentLinkDto().setComponentUuid(project.uuid()).setHref("foo").setName("name");
     insertLink(foo);
     logInAsProjectAdministrator(project);
@@ -218,7 +218,7 @@ public class SearchActionTest {
   }
 
   private ComponentDto insertProject(String projectKey, String projectUuid) {
-    return componentDb.insertComponent(newProjectDto(db.organizations().insert(), projectUuid).setKey(projectKey));
+    return componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), projectUuid).setKey(projectKey));
   }
 
   private ComponentDto insertProject() {
index 67b2c9a65b11dc23518825f8c6a66442574d8cdf..855f8697f802c519cdd719ae5b71f0665343faca 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.api.config.MapSettings;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.organization.OrganizationTesting;
 import org.sonar.server.es.EsTester;
@@ -47,7 +48,6 @@ import org.sonarqube.ws.WsProjectTags.SearchResponse;
 import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.util.Protobuf.setNullable;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.INDEX_TYPE_PROJECT_MEASURES;
 import static org.sonar.test.JsonAssert.assertJson;
 
@@ -128,7 +128,7 @@ public class SearchActionTest {
   }
 
   private static ProjectMeasuresDoc newDoc() {
-    return newDoc(newProjectDto(ORG));
+    return newDoc(ComponentTesting.newPrivateProjectDto(ORG));
   }
 
   private SearchResponse call(@Nullable String textQuery, @Nullable Integer pageSize) {
index 086f7c18b8466f4d3a5073643ad20b9ba43126c4..00443b49bc9587df4a6dd163ba34003b456bad63 100644 (file)
@@ -67,7 +67,7 @@ public class SetActionTest {
 
   @Before
   public void setUp() {
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
   }
 
   @Test
@@ -81,7 +81,7 @@ public class SetActionTest {
 
   @Test
   public void reset_tags() {
-    project = db.components().insertProject(p -> p.setTagsString("platform,scanner"));
+    project = db.components().insertPrivateProject(p -> p.setTagsString("platform,scanner"));
 
     call(project.key(), "");
 
@@ -90,7 +90,7 @@ public class SetActionTest {
 
   @Test
   public void override_existing_tags() {
-    project = db.components().insertProject(p -> p.setTagsString("marketing,languages"));
+    project = db.components().insertPrivateProject(p -> p.setTagsString("marketing,languages"));
 
     call(project.key(), "finance,offshore,platform");
 
index 8be1173c0a8d138c5e3855436cba11b0e775787b..1c6c5e1e127c1bd4ff26f7c18c41a9f03e7ca004 100644 (file)
@@ -36,6 +36,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.property.PropertyDbTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
@@ -50,7 +51,6 @@ import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -76,7 +76,7 @@ public class IndexActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
   }
 
   @Test
index 3d9ff6a34c66d12a6261c95ad0cc3b4c7a407b78..8f3a44c875b4e9898cfb7d9d3df116818e5e42eb 100644 (file)
@@ -34,6 +34,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.property.PropertyDto;
 import org.sonar.db.qualitygate.ProjectQgateAssociation;
@@ -46,7 +47,6 @@ import org.sonar.server.tester.UserSessionRule;
 
 import static com.google.common.collect.FluentIterable.from;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.qualitygate.ProjectQgateAssociationQuery.IN;
 import static org.sonar.db.qualitygate.ProjectQgateAssociationQuery.OUT;
 import static org.sonar.db.qualitygate.ProjectQgateAssociationQuery.builder;
@@ -89,8 +89,8 @@ public class QgateProjectFinderTest {
   @Test
   public void return_all_projects() throws Exception {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
-    ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
+    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
+    ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
     associateProjectToQualitGate(associatedProject.getId());
 
     Association result = underTest.find(
@@ -108,8 +108,8 @@ public class QgateProjectFinderTest {
   @Test
   public void return_only_associated_project() throws Exception {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
-    insertProjectAuthorizedToAnyone(newProjectDto(org));
+    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
+    insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
     associateProjectToQualitGate(associatedProject.getId());
 
     Association result = underTest.find(
@@ -126,8 +126,8 @@ public class QgateProjectFinderTest {
   @Test
   public void return_only_unassociated_project() throws Exception {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
-    ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
+    ComponentDto associatedProject = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
+    ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org));
     associateProjectToQualitGate(associatedProject.getId());
 
     Association result = underTest.find(
@@ -145,8 +145,8 @@ public class QgateProjectFinderTest {
   public void return_only_authorized_projects() throws Exception {
     UserDto user = dbTester.users().insertUser("a_login");
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project1 = componentDbTester.insertComponent(newProjectDto(organizationDto));
-    componentDbTester.insertComponent(newProjectDto(organizationDto));
+    ComponentDto project1 = componentDbTester.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
+    componentDbTester.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
 
     // User can only see project 1
     dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, project1);
@@ -163,7 +163,7 @@ public class QgateProjectFinderTest {
   @Test
   public void do_not_verify_permissions_if_user_is_root() throws Exception {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project = componentDbTester.insertProject(org);
+    ComponentDto project = componentDbTester.insertPrivateProject(org);
     ProjectQgateAssociationQuery query = builder()
       .gateId(Long.toString(qGate.getId()))
       .build();
@@ -178,9 +178,9 @@ public class QgateProjectFinderTest {
   @Test
   public void test_paging() throws Exception {
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project1 = insertProjectAuthorizedToAnyone(newProjectDto(org).setName("Project 1"));
-    ComponentDto project2 = insertProjectAuthorizedToAnyone(newProjectDto(org).setName("Project 2"));
-    ComponentDto project3 = insertProjectAuthorizedToAnyone(newProjectDto(org).setName("Project 3"));
+    ComponentDto project1 = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org).setName("Project 1"));
+    ComponentDto project2 = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org).setName("Project 2"));
+    ComponentDto project3 = insertProjectAuthorizedToAnyone(ComponentTesting.newPrivateProjectDto(org).setName("Project 3"));
     associateProjectToQualitGate(project1.getId());
 
     // Return partial result on first page
index 3ce145d75ce9a2934313a285e3bb4f1331e81c02..b7754fac0621fb5c253f096d93abd71ef5b8ef8a 100644 (file)
@@ -27,11 +27,11 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.qualitygate.QualityGateDto;
 import org.sonar.server.exceptions.NotFoundException;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 
 public class QualityGateFinderTest {
 
@@ -47,7 +47,7 @@ public class QualityGateFinderTest {
 
   @Test
   public void return_default_quality_gate_for_project() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
     QualityGateDto dbQualityGate = dbTester.qualityGates().createDefaultQualityGate("Sonar way");
 
     Optional<QualityGateFinder.QualityGateData> result = underTest.getQualityGate(dbSession, project.getId());
@@ -59,7 +59,7 @@ public class QualityGateFinderTest {
 
   @Test
   public void return_project_quality_gate_over_default() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     dbTester.qualityGates().createDefaultQualityGate("Sonar way");
     QualityGateDto dbQualityGate = dbTester.qualityGates().insertQualityGate("My team QG");
     dbTester.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
@@ -73,7 +73,7 @@ public class QualityGateFinderTest {
 
   @Test
   public void return_nothing_when_no_default_qgate_and_no_qgate_defined_for_project() {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
 
     Optional<QualityGateFinder.QualityGateData> result = underTest.getQualityGate(dbSession, project.getId());
 
@@ -82,7 +82,7 @@ public class QualityGateFinderTest {
 
   @Test
   public void fail_when_default_qgate_defined_in_properties_does_not_exists() throws Exception {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
     QualityGateDto dbQualityGate = dbTester.qualityGates().createDefaultQualityGate("Sonar way");
     dbTester.getDbClient().qualityGateDao().delete(dbQualityGate, dbSession);
 
@@ -92,7 +92,7 @@ public class QualityGateFinderTest {
 
   @Test
   public void fail_when_project_qgate_defined_in_properties_does_not_exists() throws Exception {
-    ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()));
+    ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()));
     QualityGateDto dbQualityGate = dbTester.qualityGates().insertQualityGate("My team QG");
     dbTester.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
     dbTester.getDbClient().qualityGateDao().delete(dbQualityGate, dbSession);
index 0f9492e650bebb9c29ee2b9d8ca8a382209cf2c8..38753c5f3460f16540f64a20f27d3e4bca1f2704 100644 (file)
@@ -59,7 +59,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 @RunWith(MockitoJUnitRunner.class)
 public class QualityGatesTest {
@@ -91,7 +91,7 @@ public class QualityGatesTest {
     when(dbClient.componentDao()).thenReturn(componentDao);
 
     when(componentDao.selectOrFailById(eq(dbSession), anyLong())).thenReturn(
-      newProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setId(1L).setKey(PROJECT_KEY));
+      newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setId(1L).setKey(PROJECT_KEY));
 
     underTest = new QualityGates(dbClient, metricFinder, userSession);
 
index debfee708d14b97eeef7f1cb92c6950aa0677d73..2bde5265686d9ac78b96a5e5c411f4902e854d0c 100644 (file)
@@ -69,7 +69,7 @@ public class DeselectActionTest {
     underTest = new DeselectAction(qualityGates, dbClient, componentFinder);
     ws = new WsActionTester(underTest);
 
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     gate = insertQualityGate();
   }
 
@@ -77,7 +77,7 @@ public class DeselectActionTest {
   public void deselect_by_id() throws Exception {
     logInAsRoot();
 
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     String gateId = String.valueOf(gate.getId());
     associateProjectToQualityGate(project.getId(), gateId);
     associateProjectToQualityGate(anotherProject.getId(), gateId);
index 522eb69c460800e1335bd50c58961e8d78d2f259..37a429cdd46b0fadbe73e19174b47fb55e230d1d 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.property.PropertyDto;
 import org.sonar.db.qualitygate.QualityGateDto;
@@ -44,7 +45,6 @@ import org.sonarqube.ws.WsQualityGates;
 import org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID;
 import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY;
@@ -66,7 +66,7 @@ public class GetByProjectActionTest {
   @Test
   public void json_example() {
     OrganizationDto organizationDto = db.organizations().insert();
-    ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
     QualityGateDto qualityGate = insertQualityGate("My team QG");
     associateProjectToQualityGate(project.getId(), qualityGate.getId());
     logInAsProjectUser(project);
@@ -80,7 +80,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void empty_response() {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     insertQualityGate("Another QG");
     logInAsProjectUser(project);
 
@@ -91,7 +91,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void default_quality_gate() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
     logInAsProjectUser(project);
@@ -106,7 +106,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void project_quality_gate_over_default() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     QualityGateDto defaultDbQualityGate = insertQualityGate("Sonar way");
     QualityGateDto dbQualityGate = insertQualityGate("My team QG");
     setDefaultQualityGate(defaultDbQualityGate.getId());
@@ -122,7 +122,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void get_by_project_key() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
     QualityGateDto dbQualityGate = insertQualityGate("My team QG");
     associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
     logInAsProjectUser(project);
@@ -134,7 +134,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void get_with_project_admin_permission() {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
@@ -146,7 +146,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void get_with_project_user_permission() {
-    ComponentDto project = componentDb.insertProject();
+    ComponentDto project = componentDb.insertPrivateProject();
     userSession.logIn().addProjectPermission(UserRole.USER, project);
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
@@ -158,7 +158,7 @@ public class GetByProjectActionTest {
 
   @Test
   public void fail_when_insufficient_permission() {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     userSession.logIn();
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
index 85f835eeb660392b4722c882f9568dec76e85340..c38b9cd0a1a0242f32806bcc705c83852e7ab4c2 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.server.component.ComponentFinder;
@@ -44,7 +45,6 @@ import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse;
 import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse.Status;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -77,7 +77,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void json_example() throws IOException {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     userSession.addProjectPermission(UserRole.USER, project);
 
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
@@ -101,7 +101,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void return_status_by_project_id() throws IOException {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
       .setPeriodMode("last_version")
       .setPeriodParam("2015-12-07")
@@ -124,7 +124,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void return_status_by_project_key() throws IOException {
-    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("project-key"));
+    ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("project-key"));
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
       .setPeriodMode("last_version")
       .setPeriodParam("2015-12-07")
@@ -147,7 +147,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void return_undefined_status_if_measure_is_not_found() {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
     dbSession.commit();
     userSession.addProjectPermission(UserRole.USER, project);
@@ -160,7 +160,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void return_undefined_status_if_snapshot_is_not_found() {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     userSession.addProjectPermission(UserRole.USER, project);
 
     ProjectStatusWsResponse result = callByProjectUuid(project.uuid());
@@ -171,7 +171,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void project_administrator_is_allowed_to_get_project_status() {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
     dbSession.commit();
     userSession.addProjectPermission(UserRole.ADMIN, project);
@@ -181,7 +181,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void project_user_is_allowed_to_get_project_status() {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
     dbSession.commit();
     userSession.addProjectPermission(UserRole.USER, project);
@@ -201,7 +201,7 @@ public class ProjectStatusActionTest {
 
   @Test
   public void fail_if_insufficient_privileges() {
-    ComponentDto project = db.components().insertProject(db.organizations().insert());
+    ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
     dbSession.commit();
     userSession.logIn();
index c89cdb21347a3be4bae7fca658d62e54f690c086..dd777aa47c6d41928895e6e1913e2fdb71e1718a 100644 (file)
@@ -63,7 +63,7 @@ public class SelectActionTest {
     ComponentFinder componentFinder = new ComponentFinder(dbClient);
     underTest = new SelectAction(dbClient, userSession, componentFinder);
     ws = new WsActionTester(underTest);
-    project = db.components().insertProject();
+    project = db.components().insertPrivateProject();
     gate = insertQualityGate();
   }
 
index d98e8eb214095685a7542a6e3481460ba8894932..114e2f3baef2b51d21d127e80e06ca6d21cf7729 100644 (file)
@@ -91,7 +91,7 @@ public class QProfileFactoryTest {
 
   private QualityProfileDto createRandomProfile(OrganizationDto org) {
     QualityProfileDto profile = db.qualityProfiles().insert(org);
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.qualityProfiles().associateProjectWithQualityProfile(project, profile);
     ActiveRuleDto activeRuleDto = new ActiveRuleDto()
       .setProfileId(profile.getId())
index d3f59227c0588b26461861e51a8c3fcc93e063d6..50ff1f7738e351c190fcb0cc6009500796e0352c 100644 (file)
@@ -82,7 +82,7 @@ public class AddProjectActionTest {
   @Test
   public void add_project_on_profile_of_default_organization() {
     logInAsProfileAdmin(db.getDefaultOrganization());
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     TestResponse response = call(project, profile);
@@ -95,7 +95,7 @@ public class AddProjectActionTest {
   public void add_project_on_profile_of_specified_organization() {
     OrganizationDto org1 = db.organizations().insert();
     logInAsProfileAdmin(org1);
-    ComponentDto project = db.components().insertProject(org1);
+    ComponentDto project = db.components().insertPrivateProject(org1);
     QualityProfileDto profile = db.qualityProfiles().insert(org1, p -> p.setLanguage(LANGUAGE_1));
 
     TestResponse response = call(org1, project, profile);
@@ -109,7 +109,7 @@ public class AddProjectActionTest {
     OrganizationDto org1 = db.organizations().insert();
     OrganizationDto org2 = db.organizations().insert();
     logInAsProfileAdmin(org1);
-    ComponentDto project = db.components().insertProject(org1);
+    ComponentDto project = db.components().insertPrivateProject(org1);
     QualityProfileDto profileInOrg2 = db.qualityProfiles().insert(org2, p -> p.setLanguage(LANGUAGE_1));
 
     expectedException.expect(IllegalArgumentException.class);
@@ -125,7 +125,7 @@ public class AddProjectActionTest {
     OrganizationDto org1 = db.organizations().insert();
     OrganizationDto org2 = db.organizations().insert();
     logInAsProfileAdmin(org1);
-    ComponentDto project = db.components().insertProject(org1);
+    ComponentDto project = db.components().insertPrivateProject(org1);
     QualityProfileDto profileInOrg2 = db.qualityProfiles().insert(org2, p -> p.setLanguage(LANGUAGE_1));
 
     expectedException.expect(NotFoundException.class);
@@ -141,7 +141,7 @@ public class AddProjectActionTest {
   public void change_association_in_default_organization() throws Exception {
     logInAsProfileAdmin(db.getDefaultOrganization());
 
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     // two profiles on same language
     QualityProfileDto profile1 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_1));
     QualityProfileDto profile2 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_1));
@@ -156,7 +156,7 @@ public class AddProjectActionTest {
   @Test
   public void changing_association_does_not_change_other_language_associations() throws Exception {
     logInAsProfileAdmin(db.getDefaultOrganization());
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile1Language1 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_1));
     QualityProfileDto profile2Language2 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_2));
     QualityProfileDto profile3Language1 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_1));
@@ -170,7 +170,7 @@ public class AddProjectActionTest {
 
   @Test
   public void project_administrator_can_change_profile() throws Exception {
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
 
@@ -182,7 +182,7 @@ public class AddProjectActionTest {
   @Test
   public void throw_ForbiddenException_if_not_project_nor_organization_administrator() {
     userSession.logIn();
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(ForbiddenException.class);
@@ -194,7 +194,7 @@ public class AddProjectActionTest {
   @Test
   public void throw_UnauthorizedException_if_not_logged_in() {
     userSession.anonymous();
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(UnauthorizedException.class);
@@ -220,7 +220,7 @@ public class AddProjectActionTest {
   @Test
   public void throw_NotFoundException_if_profile_does_not_exist() {
     logInAsProfileAdmin(db.getDefaultOrganization());
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
index 582717a209405907282b93fec8054718cb3b8732..f680c9ca8dd19866adee3b20ec930fa7561a6c0a 100644 (file)
@@ -71,7 +71,7 @@ public class DeleteActionTest {
   @Test
   public void delete_profile_by_key() {
     OrganizationDto organization = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
     QualityProfileDto profile1 = createProfile(organization);
     QualityProfileDto profile2 = createProfile(organization);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project, profile1);
@@ -91,7 +91,7 @@ public class DeleteActionTest {
   @Test
   public void delete_profile_by_language_and_name_in_default_organization() throws Exception {
     OrganizationDto organization = dbTester.getDefaultOrganization();
-    ComponentDto project = dbTester.components().insertProject(organization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
     QualityProfileDto profile1 = createProfile(organization);
     QualityProfileDto profile2 = createProfile(organization);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project, profile1);
@@ -113,7 +113,7 @@ public class DeleteActionTest {
   @Test
   public void delete_profile_by_language_and_name_in_specified_organization() {
     OrganizationDto organization = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(organization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
     QualityProfileDto profile1 = createProfile(organization);
     QualityProfileDto profile2 = createProfile(organization);
     dbTester.qualityProfiles().associateProjectWithQualityProfile(project, profile1);
index 09230039dc8b169b96198e7533e3fd7b7a5afee3..d7f8208f0e09273b13051cfd25625098e265b3f3 100644 (file)
@@ -208,7 +208,7 @@ public class ProjectsActionTest {
   }
 
   private ComponentDto newProject(String uuid, String name) {
-    return ComponentTesting.newProjectDto(organizationDto, uuid).setName(name);
+    return ComponentTesting.newPrivateProjectDto(organizationDto, uuid).setName(name);
   }
 
   private void addBrowsePermissionToAnyone(ComponentDto... projects) {
index 3e9ccc3b38938e9b7cac4d19042c8397c4841436..e90381ee12bf81bfcba47b1ef0d9ff3549b532ea 100644 (file)
@@ -81,7 +81,7 @@ public class RemoveProjectActionTest {
   public void remove_profile_from_project_in_default_organization() {
     logInAsProfileAdmin();
 
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profileLang1 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_1));
     QualityProfileDto profileLang2 = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(LANGUAGE_2));
     db.qualityProfiles().associateProjectWithQualityProfile(project, profileLang1);
@@ -98,7 +98,7 @@ public class RemoveProjectActionTest {
   public void removal_does_not_fail_if_profile_is_not_associated_to_project() {
     logInAsProfileAdmin();
 
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     TestResponse response = call(project, profile);
@@ -109,7 +109,7 @@ public class RemoveProjectActionTest {
 
   @Test
   public void project_administrator_can_remove_profile() throws Exception {
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
     db.qualityProfiles().associateProjectWithQualityProfile(project, profile);
     userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
@@ -122,7 +122,7 @@ public class RemoveProjectActionTest {
   @Test
   public void throw_ForbiddenException_if_not_project_nor_organization_administrator() {
     userSession.logIn();
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(ForbiddenException.class);
@@ -134,7 +134,7 @@ public class RemoveProjectActionTest {
   @Test
   public void throw_UnauthorizedException_if_not_logged_in() {
     userSession.anonymous();
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
     QualityProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
 
     expectedException.expect(UnauthorizedException.class);
@@ -160,7 +160,7 @@ public class RemoveProjectActionTest {
   @Test
   public void throw_NotFoundException_if_profile_does_not_exist() {
     logInAsProfileAdmin();
-    ComponentDto project = db.components().insertProject(db.getDefaultOrganization());
+    ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
 
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
index f8ac75c9cdcaf9fba9aedaaac2a3649b5b9c9542..a4852e837f704955e73e44bc9bd7fbd5daa8494e 100644 (file)
@@ -61,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
@@ -135,8 +135,8 @@ public class SearchActionTest {
       .setDefault(true);
     qualityProfileDao.insert(dbSession, defaultProfile, parentProfile, childProfile, profileOnUnknownLang);
 
-    ComponentDto project1 = db.components().insertProject(organization);
-    ComponentDto project2 = db.components().insertProject(organization);
+    ComponentDto project1 = db.components().insertPrivateProject(organization);
+    ComponentDto project2 = db.components().insertPrivateProject(organization);
     db.qualityProfiles().associateProjectWithQualityProfile(project1, parentProfile);
     db.qualityProfiles().associateProjectWithQualityProfile(project2, parentProfile);
 
@@ -260,7 +260,7 @@ public class SearchActionTest {
       .setRulesUpdatedAt("2016-12-21T19:10:03+0100")
       .setLastUsed(time)
       .setName("Another way");
-    ComponentDto project = newProjectDto(org, "project-uuid");
+    ComponentDto project = newPrivateProjectDto(org, "project-uuid");
     qualityProfileDb.insertQualityProfiles(qualityProfileOnXoo1, qualityProfileOnXoo2, anotherQualityProfileOnXoo1);
     qualityProfileDb.insertProjectWithQualityProfileAssociations(project, qualityProfileOnXoo1, qualityProfileOnXoo2);
 
@@ -328,7 +328,7 @@ public class SearchActionTest {
       .setName("Another way")
       .setDefault(true);
     qualityProfileDb.insertQualityProfiles(qualityProfileOnXoo1, qualityProfileOnXoo2, anotherQualityProfileOnXoo1);
-    ComponentDto project = componentDb.insertComponent(newProjectDto(org, "project-uuid"));
+    ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(org, "project-uuid"));
 
     String result = ws.newRequest()
       .setParam(PARAM_ORGANIZATION, org.getKey())
@@ -385,7 +385,7 @@ public class SearchActionTest {
   @Test
   public void name_and_component_query_is_valid() throws Exception {
     minimalValidSetup();
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
 
     SearchWsRequest request = new SearchWsRequest()
       .setProfileName("bla")
index 28339f67460cf5fb7fe8c0ecb7935710dc49d948..614e7284b63309936c798e2600a210f22272fe3b 100644 (file)
@@ -40,7 +40,6 @@ import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.language.LanguageTesting;
 import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.qualityprofile.QProfileLookup;
-import org.sonar.server.qualityprofile.QProfileFactory;
 import org.sonarqube.ws.client.qualityprofile.SearchWsRequest;
 
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
@@ -150,7 +149,7 @@ public class SearchDataLoaderTest {
   }
 
   private ComponentDto insertProject() {
-    ComponentDto project = dbTester.components().insertProject(organization);
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
     doReturn(project).when(componentFinder).getByKey(any(DbSession.class), eq(project.getKey()));
     return project;
   }
index c0b895e0995e7bfa9a899771ec3aee4b1f114dbb..a0f097c08208d55ca8b280d041627360d3fc42c4 100644 (file)
@@ -34,6 +34,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -54,7 +55,6 @@ import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.SCAN;
 import static org.sonarqube.ws.MediaTypes.JSON;
@@ -92,7 +92,7 @@ public class ListDefinitionsActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
   }
 
   @Test
index a8cfe9634caf56eaf9bbbc4f828621b43eb2f9c8..2410d16610db8c9c720b3fcda143fad24e44ca44 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.property.PropertyDbTester;
 import org.sonar.db.property.PropertyQuery;
 import org.sonar.db.user.UserDto;
@@ -53,7 +54,6 @@ import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.resources.Qualifiers.VIEW;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newUserPropertyDto;
@@ -84,7 +84,7 @@ public class ResetActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
   }
 
   @Test
index 06f235568614859938e6a19802197d4661ad0659..44b20cea5dfcd649d67c6061eb0c50299f927987 100644 (file)
@@ -129,7 +129,7 @@ public class SetActionTest {
   @Test
   public void persist_new_project_setting() {
     propertyDb.insertProperty(newGlobalPropertyDto("my.key", "my global value"));
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     logInAsProjectAdministrator(project);
 
     callForProjectSettingByKey("my.key", "my project value", project.key());
@@ -141,7 +141,7 @@ public class SetActionTest {
 
   @Test
   public void persist_project_property_with_project_admin_permission() {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     logInAsProjectAdministrator(project);
 
     callForProjectSettingByKey("my.key", "my value", project.key());
@@ -152,7 +152,7 @@ public class SetActionTest {
   @Test
   public void update_existing_project_setting() {
     propertyDb.insertProperty(newGlobalPropertyDto("my.key", "my global value"));
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     propertyDb.insertProperty(newComponentPropertyDto("my.key", "my project value", project));
     assertComponentSetting("my.key", "my project value", project.getId());
     logInAsProjectAdministrator(project);
@@ -283,7 +283,7 @@ public class SetActionTest {
           .type(PropertyType.STRING)
           .build()))
       .build());
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     propertyDb.insertProperties(
       newGlobalPropertyDto("my.key", "1"),
       newGlobalPropertyDto("my.key.1.firstField", "oldFirstValue"),
@@ -796,7 +796,7 @@ public class SetActionTest {
       .fields(newArrayList(PropertyFieldDefinition.build("firstField").name("First Field").type(PropertyType.STRING).build()))
       .build());
     i18n.put("qualifier." + Qualifiers.PROJECT, "Project");
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     logInAsProjectAdministrator(project);
 
     expectedException.expect(BadRequestException.class);
index d75ba1a1bdd6f1135986299b29d11e11f6cc54e7..5881ecf70b407577a54dd2218c0ce47be1671b7b 100644 (file)
@@ -36,6 +36,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.property.PropertyDto;
 
 import static com.google.common.collect.Sets.newHashSet;
@@ -45,7 +46,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
 import static org.sonar.api.PropertyType.PROPERTY_SET;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
 
@@ -110,7 +110,7 @@ public class SettingsFinderTest {
 
   @Test
   public void return_component_settings() throws Exception {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     addDefinitions(PropertyDefinition.builder("property").defaultValue("default").build());
     insertProperties(newComponentPropertyDto(project).setKey("property").setValue("one"));
 
@@ -125,7 +125,7 @@ public class SettingsFinderTest {
 
   @Test
   public void return_component_setting_even_if_no_definition() throws Exception {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     insertProperties(newComponentPropertyDto(project).setKey("property").setValue("one"));
 
     Multimap<String, Setting> settings = underTest.loadComponentSettings(dbSession, newHashSet("property"), project);
@@ -135,7 +135,7 @@ public class SettingsFinderTest {
 
   @Test
   public void return_component_settings_with_property_set() throws Exception {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     addDefinitions(PropertyDefinition.builder("set1")
       .type(PROPERTY_SET)
       .fields(asList(
@@ -161,10 +161,10 @@ public class SettingsFinderTest {
 
   @Test
   public void return_module_settings() throws Exception {
-    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     ComponentDto module = componentDb.insertComponent(newModuleDto(project));
     ComponentDto subModule = componentDb.insertComponent(newModuleDto(module));
-    ComponentDto anotherProject = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
+    ComponentDto anotherProject = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
 
     insertProperties(
       newComponentPropertyDto(project).setKey("property").setValue("one"),
index 7629c59167c2f51b047d43e2f877c7bd5a677717..6bc1f4690d772f21a87545f0e9762cb5f912b026 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.property.PropertyDbTester;
 import org.sonar.db.property.PropertyQuery;
 import org.sonar.db.user.UserDto;
@@ -40,7 +41,6 @@ import org.sonar.db.user.UserTesting;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newUserPropertyDto;
@@ -66,7 +66,7 @@ public class SettingsUpdaterTest {
 
   @Before
   public void setUp() throws Exception {
-    project = componentDb.insertComponent(newProjectDto(db.organizations().insert()));
+    project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
   }
 
   @Test
index a959bbf645be351ea2a9b740222d94dfce37996d..7f2820b8a1404a7f65bbd8e097ada2640aad3888 100644 (file)
@@ -37,6 +37,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.property.PropertyDbTester;
 import org.sonar.server.component.ComponentFinder;
@@ -61,7 +62,6 @@ import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.SCAN;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
@@ -98,7 +98,7 @@ public class ValuesActionTest {
   @Before
   public void setUp() throws Exception {
     OrganizationDto organizationDto = db.organizations().insert();
-    project = componentDb.insertComponent(newProjectDto(organizationDto));
+    project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
   }
 
   @Test
index 43c58740d31739a4c9be80fd59b852532199c4e9..9c0f2768270b9970de5c88caf90bc893aa7ba6cd 100644 (file)
@@ -58,7 +58,7 @@ public class IndexActionTest {
 
   @Test
   public void get_json() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(CODEVIEWER, project);
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     insertFileWithData(file, newData("public class HelloWorld {", "}"));
@@ -77,7 +77,7 @@ public class IndexActionTest {
 
   @Test
   public void limit_range() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(CODEVIEWER, project);
     ComponentDto file = db.components().insertComponent(newFileDto(project));
     insertFileWithData(file, newData("/**", " */", "public class HelloWorld {", "}", "", "foo"));
@@ -98,7 +98,7 @@ public class IndexActionTest {
 
   @Test
   public void fail_when_missing_code_viewer_permission() throws Exception {
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(USER, project);
     ComponentDto file = db.components().insertComponent(newFileDto(project));
 
index cabdda93a8676d72c693073b5c3a475d9500cb4f..749930e349897edb9ab2d9747a765e63d7a27368 100644 (file)
@@ -84,7 +84,7 @@ public class LinesActionTest {
     componentDao = new ComponentDao();
     wsTester = new WsTester(new SourcesWs(
       new LinesAction(new ComponentFinder(dbTester.getDbClient()), dbTester.getDbClient(), sourceService, htmlSourceDecorator, userSessionRule)));
-    project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
+    project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
     file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
   }
 
index e0e44c65cc6ab6c6e6ec5507e19ab96d6be7ab23..52d764e96698782b6e70bf3d98662aec4289e05d 100644 (file)
@@ -63,7 +63,7 @@ public class RawActionTest {
 
   WsTester tester;
 
-  ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto());
+  ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto());
   ComponentDto file = ComponentTesting.newFileDto(project, null);
 
   @Before
index 6fc112242cf9cea75a130a2c95a9b6e9270eaa77..23cb2b7effe8127d7ded59c63d7f9d28662cea39 100644 (file)
@@ -63,7 +63,7 @@ public class ScmActionTest {
     tester = new WsTester(
       new SourcesWs(new ScmAction(dbClient, new SourceService(dbTester.getDbClient(), new HtmlSourceDecorator()), userSessionRule, new ComponentFinder(dbClient))));
 
-    project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
+    project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
     file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
     dbClient.componentDao().insert(dbTester.getSession(), project, file);
     dbTester.getSession().commit();
index 2d88ec0e59a60c78a7484628c1b79237d31d0f3c..42c34112420996610b87b43e0547a51c510444a9 100644 (file)
@@ -65,7 +65,7 @@ public class ShowActionTest {
   @Mock
   ComponentDao componentDao;
 
-  ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto());
+  ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto());
   ComponentDto file = ComponentTesting.newFileDto(project, null);
 
   @Before
index 3cb5aa0d681e6b02b189ecabd01e3e5b9831d6b2..3a35213c5a410e0da0bdc9a6104ecf4969e68beb 100644 (file)
@@ -50,7 +50,7 @@ public class DisplayLogOnDeprecatedProjectsTest {
   @Test
   public void display_log_on_deprecated_project() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    dbClient.componentDao().insert(dbSession, ComponentTesting.newProjectDto(organizationDto)
+    dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
       .setKey(DEPRECATED_PROJECT_KEY)
       .setDeprecatedKey(null));
     dbSession.commit();
@@ -66,7 +66,7 @@ public class DisplayLogOnDeprecatedProjectsTest {
   @Test
   public void not_display_log_when_task_already_executed() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    dbClient.componentDao().insert(dbSession, ComponentTesting.newProjectDto(organizationDto)
+    dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
       .setKey(DEPRECATED_PROJECT_KEY)
       .setDeprecatedKey(null));
     dbSession.commit();
@@ -82,7 +82,7 @@ public class DisplayLogOnDeprecatedProjectsTest {
   @Test
   public void nothing_do_when_no_deprecated_project() throws Exception {
     OrganizationDto organizationDto = dbTester.organizations().insert();
-    dbClient.componentDao().insert(dbSession, ComponentTesting.newProjectDto(organizationDto)
+    dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
       .setKey(PROJECT_KEY)
       .setDeprecatedKey(PROJECT_KEY));
     dbSession.commit();
index 20dbef657aa9cd6552458fdea160dc52f89c2aaf..72235dcc0d7259a95280f33c44ca4a6b3a26b16a 100644 (file)
@@ -47,7 +47,6 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.server.test.ws.CoveredFilesAction.TEST_ID;
 import static org.sonar.test.JsonAssert.assertJson;
 
@@ -75,7 +74,7 @@ public class CoveredFilesActionTest {
 
   @Test
   public void covered_files() {
-    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "SonarQube");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "SonarQube");
     ComponentDto file = ComponentTesting.newFileDto(project, null, "test-file-uuid");
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
 
@@ -86,8 +85,8 @@ public class CoveredFilesActionTest {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
       Arrays.asList(
-        newFileDto(newProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
-        newFileDto(newProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+        newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+        newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
 
     TestRequest request = ws.newRequest().setParam(TEST_ID, "test-uuid");
 
@@ -96,7 +95,7 @@ public class CoveredFilesActionTest {
 
   @Test
   public void fail_when_test_uuid_is_unknown() {
-    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "SonarQube");
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "SonarQube");
     ComponentDto file = ComponentTesting.newFileDto(project);
     userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
 
@@ -107,8 +106,8 @@ public class CoveredFilesActionTest {
     OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
     when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
       Arrays.asList(
-        newFileDto(newProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
-        newFileDto(newProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+        newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+        newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
 
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Test with id 'test-uuid' is not found");
index 208f02dbd9aba5f88416b2e1f1b35860b62a8bd0..9420aa0dda985605f8a1824567fe5f6970fda9cf 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.api.config.MapSettings;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.protobuf.DbFileSources;
 import org.sonar.db.source.FileSourceDto;
 import org.sonar.server.component.ComponentFinder;
@@ -48,7 +49,6 @@ import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
 import static org.sonar.api.web.UserRole.CODEVIEWER;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.protobuf.DbFileSources.Test.TestStatus.OK;
 import static org.sonar.server.test.db.TestTesting.newTest;
 import static org.sonar.server.test.ws.ListAction.SOURCE_FILE_ID;
@@ -82,7 +82,7 @@ public class ListActionTest {
 
   @Before
   public void setUp() throws Exception {
-    project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization()));
+    project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     mainFile = db.components().insertComponent(newFileDto(project));
     testFile = db.components().insertComponent(newFileDto(project).setQualifier(UNIT_TEST_FILE));
   }
index 06d4d326370b53c3d9804f92bfbd767960b0ef6d..0f261f50ddec141c27bcfa00f5317f6cef91ea4f 100644 (file)
@@ -67,7 +67,7 @@ import static org.sonar.api.web.page.Page.Scope.COMPONENT;
 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.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -94,7 +94,7 @@ public class ComponentActionTest {
   @Before
   public void before() {
     OrganizationDto organization = dbTester.organizations().insertForKey("my-org");
-    project = newProjectDto(organization, "abcd")
+    project = newPrivateProjectDto(organization, "abcd")
       .setKey("polop")
       .setName("Polop")
       .setDescription("test project")
@@ -368,7 +368,7 @@ public class ComponentActionTest {
   public void test_example_response() throws Exception {
     init(createPages());
     OrganizationDto organizationDto = dbTester.organizations().insertForKey("my-org-1");
-    ComponentDto project = newProjectDto(organizationDto, "ABCD")
+    ComponentDto project = newPrivateProjectDto(organizationDto, "ABCD")
       .setKey("org.codehaus.sonar:sonar")
       .setName("Sonarqube")
       .setDescription("Open source platform for continuous inspection of code quality");
@@ -398,7 +398,7 @@ public class ComponentActionTest {
   public void canApplyPermissionTemplate_is_true_if_logged_in_as_organization_administrator() {
     init(createPages());
     OrganizationDto org = dbTester.organizations().insert();
-    ComponentDto project = dbTester.components().insertProject(org);
+    ComponentDto project = dbTester.components().insertPrivateProject(org);
 
     userSession.logIn()
       .addProjectPermission(UserRole.ADMIN, project)
index 1f7666662e275903e41d8877a9cebceb04ff2d02..b8bc5b40540ccc0190b1a1c9e630287dcfa85200 100644 (file)
@@ -81,8 +81,8 @@ public class ServerUserSessionTest {
   @Before
   public void setUp() throws Exception {
     organization = db.organizations().insert();
-    publicProject = db.components().insertProject(organization, PUBLIC_PROJECT_UUID);
-    privateProject = db.components().insertProject(organization, dto -> dto.setUuid(PRIVATE_PROJECT_UUID).setProjectUuid(PRIVATE_PROJECT_UUID).setPrivate(true));
+    publicProject = db.components().insertPublicProject(organization, PUBLIC_PROJECT_UUID);
+    privateProject = db.components().insertPrivateProject(organization, dto -> dto.setUuid(PRIVATE_PROJECT_UUID).setProjectUuid(PRIVATE_PROJECT_UUID).setPrivate(true));
     db.components().insertComponent(ComponentTesting.newFileDto(publicProject, null, FILE_UUID).setKey(FILE_KEY));
     user = db.users().insertUser(LOGIN);
     groupOfUser = db.users().insertGroup(organization);
@@ -193,7 +193,7 @@ public class ServerUserSessionTest {
   @Test
   public void test_hasPermission_on_organization_for_logged_in_user() {
     OrganizationDto org = db.organizations().insert();
-    ComponentDto project = db.components().insertProject(org);
+    ComponentDto project = db.components().insertPrivateProject(org);
     db.users().insertPermissionOnUser(org, user, PROVISION_PROJECTS);
     db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
 
index 22db1956cc96c9c5fa724cdab7137b842d0f9f9b..197ff9c0d5dee307ac7658770e992d6cdd074ee9 100644 (file)
@@ -135,7 +135,7 @@ public class DeactivateActionTest {
   public void deactivate_user_deletes_his_properties() {
     logInAsSystemAdministrator();
     UserDto user = insertUser(newUserDto());
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.properties().insertProperty(newUserPropertyDto(user));
     db.properties().insertProperty(newUserPropertyDto(user));
     db.properties().insertProperty(newUserPropertyDto(user).setResourceId(project.getId()));
@@ -150,7 +150,7 @@ public class DeactivateActionTest {
   public void deactivate_user_deletes_his_permissions() {
     logInAsSystemAdministrator();
     UserDto user = insertUser(newUserDto());
-    ComponentDto project = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
     db.users().insertPermissionOnUser(user, SCAN);
     db.users().insertPermissionOnUser(user, ADMINISTER_QUALITY_PROFILES);
     db.users().insertProjectPermissionOnUser(user, USER, project);
@@ -181,8 +181,8 @@ public class DeactivateActionTest {
   public void deactivate_user_deletes_his_default_assignee_settings() {
     logInAsSystemAdministrator();
     UserDto user = insertUser(newUserDto());
-    ComponentDto project = db.components().insertProject();
-    ComponentDto anotherProject = db.components().insertProject();
+    ComponentDto project = db.components().insertPrivateProject();
+    ComponentDto anotherProject = db.components().insertPrivateProject();
     db.properties().insertProperty(new PropertyDto().setKey("sonar.issues.defaultAssigneeLogin").setValue(user.getLogin()).setResourceId(project.getId()));
     db.properties().insertProperty(new PropertyDto().setKey("sonar.issues.defaultAssigneeLogin").setValue(user.getLogin()).setResourceId(anotherProject.getId()));
     db.properties().insertProperty(new PropertyDto().setKey("other").setValue(user.getLogin()).setResourceId(anotherProject.getId()));
index f47556a80abd4796f45ad0b54a842a05d013c43b..2585a18b9478ddf3f2ca7df28a3e8b26df2a9dcc 100644 (file)
@@ -155,7 +155,7 @@ public class DeleteActionTest {
     addAdminToDefaultOrganization();
     insertDefaultGroupOnDefaultOrganization();
     GroupDto group = db.users().insertGroup();
-    ComponentDto project = componentTester.insertComponent(ComponentTesting.newProjectDto(db.getDefaultOrganization()));
+    ComponentDto project = componentTester.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
     db.users().insertProjectPermissionOnGroup(group, UserRole.ADMIN, project);
     loginAsAdminOnDefaultOrganization();
 
index e48b3fcdd83f77d7e3ec0f22fc35b7e24cd26daa..a26325f0635a3cd0ae1f814eb9b5938b4ac01ab4 100644 (file)
@@ -165,7 +165,7 @@ public class ViewIndexerTest {
   }
 
   private ComponentDto addProjectWithIssue(RuleDto rule, OrganizationDto org) {
-    ComponentDto project = ComponentTesting.newProjectDto(org);
+    ComponentDto project = ComponentTesting.newPrivateProjectDto(org);
     ComponentDto file = ComponentTesting.newFileDto(project, null);
     dbTester.components().insertComponents(project, file);
     dbTester.users().insertProjectPermissionOnAnyone(UserRole.USER, project);
index ba7bd3f157a0dbd37fc88976f3bbcfacf3ec87c9..307993ffb59dc530ae38c7d9c4c2231b1095f182 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.webhook.WebhookDeliveryDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -38,7 +39,6 @@ import org.sonar.server.ws.WsActionTester;
 import org.sonarqube.ws.Webhooks;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.webhook.WebhookDbTesting.newWebhookDeliveryDto;
 import static org.sonar.test.JsonAssert.assertJson;
 
@@ -62,7 +62,7 @@ public class WebhookDeliveriesActionTest {
     ComponentFinder componentFinder = new ComponentFinder(dbClient);
     WebhookDeliveriesAction underTest = new WebhookDeliveriesAction(dbClient, userSession, componentFinder);
     ws = new WsActionTester(underTest);
-    project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("my-project"));
+    project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my-project"));
   }
 
   @Test
index 0c3bf8881fbcebabebb6b14c16347ec9d8e6a3a7..057b3cc094a3da3f7ee7ade54ee49a987b4efe1d 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.webhook.WebhookDeliveryDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -40,7 +41,6 @@ import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.Webhooks;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newProjectDto;
 import static org.sonar.db.webhook.WebhookDbTesting.newWebhookDeliveryDto;
 import static org.sonar.test.JsonAssert.assertJson;
 
@@ -64,7 +64,7 @@ public class WebhookDeliveryActionTest {
     ComponentFinder componentFinder = new ComponentFinder(dbClient);
     WebhookDeliveryAction underTest = new WebhookDeliveryAction(dbClient, userSession, componentFinder);
     ws = new WsActionTester(underTest);
-    project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("my-project"));
+    project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my-project"));
   }
 
   @Test