aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-08-09 17:19:35 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-08-10 18:17:07 +0200
commit97f71ab006003c2e627c23032f3b29276909e7d9 (patch)
treeb39977239c3a05b945455300ebc99103d3ba7fb3
parent6322127612a3430304f6073a8d430d2bcbea0e66 (diff)
downloadsonarqube-97f71ab006003c2e627c23032f3b29276909e7d9.tar.gz
sonarqube-97f71ab006003c2e627c23032f3b29276909e7d9.zip
SONAR-7958 fix UUID_PATH of file created by ComponentTesting
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/BulkUpdateKeyActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java23
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java36
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java142
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java58
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java38
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java66
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java22
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java28
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java29
-rw-r--r--sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java4
49 files changed, 310 insertions, 307 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
index 66f2191f6c3..d22516d361e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
@@ -99,7 +99,7 @@ public class IssuesActionTest {
public void return_minimal_fields() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID).setKey(FILE_KEY).setPath(null);
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath(null);
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
@@ -137,7 +137,7 @@ public class IssuesActionTest {
public void issues_from_project() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
@@ -175,7 +175,7 @@ public class IssuesActionTest {
public void issues_from_module() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
@@ -213,7 +213,7 @@ public class IssuesActionTest {
public void issues_from_file() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
@@ -289,7 +289,7 @@ public class IssuesActionTest {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
// File and module are removed
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY).setEnabled(false);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java").setEnabled(false);
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java").setEnabled(false);
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java
index f3424182762..59c2f1c992d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java
@@ -495,7 +495,7 @@ public class ProjectDataLoaderMediumTest {
tester.get(DbClient.class).componentDao().insert(dbSession, project);
addDefaultProfile();
- ComponentDto file = ComponentTesting.newFileDto(project, "file");
+ ComponentDto file = ComponentTesting.newFileDto(project, null, "file");
tester.get(DbClient.class).componentDao().insert(dbSession, file);
tester.get(FileSourceDao.class).insert(newFileSourceDto(file).setSrcHash("123456"));
@@ -515,7 +515,7 @@ public class ProjectDataLoaderMediumTest {
addDefaultProfile();
// File on project
- ComponentDto projectFile = ComponentTesting.newFileDto(project, "projectFile");
+ ComponentDto projectFile = ComponentTesting.newFileDto(project, null, "projectFile");
tester.get(DbClient.class).componentDao().insert(dbSession, projectFile);
tester.get(FileSourceDao.class).insert(newFileSourceDto(projectFile).setSrcHash("123456"));
@@ -523,7 +523,7 @@ public class ProjectDataLoaderMediumTest {
tester.get(DbClient.class).componentDao().insert(dbSession, module);
// File on module
- ComponentDto moduleFile = ComponentTesting.newFileDto(module, "moduleFile");
+ ComponentDto moduleFile = ComponentTesting.newFileDto(module, null, "moduleFile");
tester.get(DbClient.class).componentDao().insert(dbSession, moduleFile);
tester.get(FileSourceDao.class).insert(newFileSourceDto(moduleFile).setSrcHash("789456"));
@@ -541,7 +541,7 @@ public class ProjectDataLoaderMediumTest {
addDefaultProfile();
// File on project
- ComponentDto projectFile = ComponentTesting.newFileDto(project, "projectFile");
+ ComponentDto projectFile = ComponentTesting.newFileDto(project, null, "projectFile");
tester.get(DbClient.class).componentDao().insert(dbSession, projectFile);
tester.get(FileSourceDao.class).insert(newFileSourceDto(projectFile).setSrcHash("123456").setRevision("987654321"));
@@ -550,7 +550,7 @@ public class ProjectDataLoaderMediumTest {
tester.get(DbClient.class).componentDao().insert(dbSession, module);
// File on module
- ComponentDto moduleFile = ComponentTesting.newFileDto(module, "moduleFile");
+ ComponentDto moduleFile = ComponentTesting.newFileDto(module, null, "moduleFile");
tester.get(DbClient.class).componentDao().insert(dbSession, moduleFile);
tester.get(FileSourceDao.class).insert(newFileSourceDto(moduleFile).setSrcHash("789456").setRevision("123456789"));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java
index 5c3f5ee58f0..6e56f4981ce 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java
@@ -114,7 +114,7 @@ public class ComponentServiceTest {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
dbClient.componentDao().insert(dbSession, module);
- ComponentDto file = newFileDto(module).setKey("sample:root:module:src/File.xoo");
+ ComponentDto file = newFileDto(module, null).setKey("sample:root:module:src/File.xoo");
dbClient.componentDao().insert(dbSession, file);
dbSession.commit();
@@ -301,7 +301,7 @@ public class ComponentServiceTest {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey(moduleKey);
dbClient.componentDao().insert(dbSession, module);
String fileKey = "sample:root:module:Foo.xoo";
- ComponentDto file = newFileDto(module).setKey(fileKey);
+ ComponentDto file = newFileDto(module, null).setKey(fileKey);
dbClient.componentDao().insert(dbSession, file);
dbSession.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
index 8c48413bffb..c4b35a88ec0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
@@ -70,7 +70,7 @@ public class ComponentServiceUpdateKeyTest {
@Test
public void update_project_key() {
ComponentDto project = insertSampleRootProject();
- ComponentDto file = ComponentTesting.newFileDto(project).setKey("sample:root:src/File.xoo");
+ ComponentDto file = ComponentTesting.newFileDto(project, null).setKey("sample:root:src/File.xoo");
dbClient.componentDao().insert(dbSession, file);
dbSession.commit();
@@ -94,7 +94,7 @@ public class ComponentServiceUpdateKeyTest {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
dbClient.componentDao().insert(dbSession, module);
- ComponentDto file = ComponentTesting.newFileDto(module).setKey("sample:root:module:src/File.xoo");
+ ComponentDto file = ComponentTesting.newFileDto(module, null).setKey("sample:root:module:src/File.xoo");
dbClient.componentDao().insert(dbSession, file);
dbSession.commit();
@@ -171,7 +171,7 @@ public class ComponentServiceUpdateKeyTest {
public void fail_if_update_is_not_on_module_or_project() {
setGlobalAdminPermission();
ComponentDto project = insertSampleRootProject();
- ComponentDto file = componentDb.insertComponent(newFileDto(project));
+ ComponentDto file = componentDb.insertComponent(newFileDto(project, null));
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Component updated must be a module or a key");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
index 8c7f3cbba6e..0d7ab34f99e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java
@@ -154,7 +154,7 @@ public class AppActionTest {
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project)
.setLongName("SonarQube :: Plugin API")
.setKey(MODULE_KEY);
- ComponentDto file = ComponentTesting.newFileDto(module, FILE_UUID)
+ ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID)
.setKey(FILE_KEY)
.setName("Plugin.java")
.setLongName("src/main/java/org/sonar/api/Plugin.java")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/BulkUpdateKeyActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/BulkUpdateKeyActionTest.java
index f01f11d6f51..722e8cc6fb2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/BulkUpdateKeyActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/BulkUpdateKeyActionTest.java
@@ -91,7 +91,7 @@ public class BulkUpdateKeyActionTest {
ComponentDto anotherProject = componentDb.insertComponent(newProjectDto().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));
+ componentDb.insertComponent(newFileDto(module2, null));
String result = ws.newRequest()
.setParam(PARAM_KEY, "my_project")
@@ -117,7 +117,7 @@ public class BulkUpdateKeyActionTest {
public void bulk_update_project_key() {
ComponentDto project = insertMyProject();
ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
- ComponentDto file = componentDb.insertComponent(newFileDto(module).setKey("my_project:root:module:src/File.xoo"));
+ ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
BulkUpdateKeyWsResponse result = callByUuid(project.uuid(), FROM, TO);
@@ -167,7 +167,7 @@ public class BulkUpdateKeyActionTest {
@Test
public void fail_to_bulk_update_if_not_project_or_module() {
ComponentDto project = insertMyProject();
- ComponentDto file = componentDb.insertComponent(newFileDto(project));
+ ComponentDto file = componentDb.insertComponent(newFileDto(project, null));
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Component updated must be a module or a key");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
index 7c44116a5ab..67e14ebef3c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
@@ -92,13 +92,13 @@ public class SearchActionTest {
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");
+ componentDb.insertComponent(directory);
componentDb.insertComponent(
- newDirectory(module, "path/to/directoy")
- .setUuid("directory-uuid")
- .setKey("directory-key")
- .setName("Directory Name"));
- componentDb.insertComponent(
- newFileDto(module, "file-uuid")
+ newFileDto(module, directory, "file-uuid")
.setKey("file-key")
.setLanguage("java")
.setName("File Name"));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
index ea19c676e14..963954ea7e2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
@@ -153,7 +153,7 @@ public class ShowActionTest {
.setQualifier(Qualifiers.DIRECTORY);
componentDb.insertComponent(directory);
componentDb.insertComponent(
- newFileDto(directory, "AVIF-FffA3Ax6PH2efPD")
+ newFileDto(directory, directory, "AVIF-FffA3Ax6PH2efPD")
.setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java")
.setName("Rule.java")
.setPath("src/main/java/com/sonarsource/markdown/impl/Rule.java")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
index 7d9be1c9744..4c26595a6be 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
@@ -28,6 +28,7 @@ import com.google.gson.JsonParser;
import java.io.IOException;
import java.util.Date;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Rule;
@@ -117,7 +118,7 @@ public class TreeActionTest {
}
ComponentDto directory = newDirectory(module, "directory-path-1");
componentDb.insertComponent(directory);
- componentDb.insertComponent(newFileDto(directory, 10));
+ componentDb.insertComponent(newFileDto(module, directory, 10));
db.commit();
componentDb.indexAllComponents();
@@ -147,7 +148,7 @@ public class TreeActionTest {
}
ComponentDto directory = newDirectory(module, "directory-path-1");
componentDb.insertComponent(directory);
- componentDb.insertComponent(newFileDto(directory, 1));
+ componentDb.insertComponent(newFileDto(module, directory, 1));
db.commit();
componentDb.indexAllComponents();
@@ -193,7 +194,7 @@ public class TreeActionTest {
componentDb.insertComponent(newFileDto(module, 2));
ComponentDto directory = newDirectory(project, "directory-path-1");
componentDb.insertComponent(directory);
- componentDb.insertComponent(newFileDto(directory, 3));
+ componentDb.insertComponent(newFileDto(module, directory, 3));
db.commit();
componentDb.indexAllComponents();
@@ -385,11 +386,15 @@ public class TreeActionTest {
}
}
- private static ComponentDto newFileDto(ComponentDto parentComponent, int i) {
- return ComponentTesting.newFileDto(parentComponent, "file-uuid-" + i)
- .setName("file-name-" + i)
- .setKey("file-key-" + i)
- .setPath("file-path-" + i);
+ private static ComponentDto newFileDto(ComponentDto moduleOrProject, @Nullable ComponentDto directory, int i) {
+ return ComponentTesting.newFileDto(moduleOrProject, directory, "file-uuid-" + i)
+ .setName("file-name-" + i)
+ .setKey("file-key-" + i)
+ .setPath("file-path-" + i);
+ }
+
+ private static ComponentDto newFileDto(ComponentDto moduleOrProject, int i) {
+ return newFileDto(moduleOrProject, null, i);
}
private ComponentDto initJsonExampleComponents() throws IOException {
@@ -404,7 +409,7 @@ public class TreeActionTest {
for (JsonElement componentAsJsonElement : components) {
JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject();
String uuid = getJsonField(componentAsJsonObject, "id");
- componentDb.insertComponent(ComponentTesting.newChildComponent(uuid, project)
+ componentDb.insertComponent(ComponentTesting.newChildComponent(uuid, project, project)
.setKey(getJsonField(componentAsJsonObject, "key"))
.setName(getJsonField(componentAsJsonObject, "name"))
.setLanguage(getJsonField(componentAsJsonObject, "language"))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
index 9e0522264dd..80ab1300887 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
@@ -277,7 +277,7 @@ public class IntegrateIssuesVisitorTest {
private void addBaseIssue(RuleKey ruleKey) {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
- ComponentDto file = ComponentTesting.newFileDto(project, FILE_UUID).setKey(FILE_KEY);
+ ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, file);
RuleDto ruleDto = RuleTesting.newDto(ruleKey);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java
index 43d7e2b3ecf..4f67ac3b60c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/BuildComponentTreeStepTest.java
@@ -174,8 +174,9 @@ public class BuildComponentTreeStepTest {
public void return_existing_uuids() {
ComponentDto project = insertComponent(newProjectDto("ABCD").setKey(REPORT_PROJECT_KEY));
ComponentDto module = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY));
- insertComponent(newDirectory(module, "CDEF", REPORT_DIR_KEY_1).setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
- insertComponent(newFileDto(module, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1));
+ ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_KEY_1);
+ insertComponent(directory.setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
+ insertComponent(newFileDto(module, directory, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
@@ -253,7 +254,7 @@ public class BuildComponentTreeStepTest {
ComponentDto project = insertComponent(newProjectDto("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(removedDirectory, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
+ insertComponent(newFileDto(removedModule, removedModule, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
index 8e1857ac490..93b7612efa4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
@@ -340,7 +340,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
}
private ComponentDto createFile(String fileKey, ComponentDto project) {
- ComponentDto file = ComponentTesting.newFileDto(project)
+ ComponentDto file = ComponentTesting.newFileDto(project, null)
.setKey(fileKey)
.setLanguage(XOO_LANGUAGE);
dbClient.componentDao().insert(dbSession, file);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java
index 73a08c15231..711baf4f7e8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java
@@ -100,7 +100,7 @@ public class PersistIssuesStepTest extends BaseStepTest {
dbClient.ruleDao().insert(session, rule);
ComponentDto project = ComponentTesting.newProjectDto();
dbClient.componentDao().insert(session, project);
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
dbClient.componentDao().insert(session, file);
session.commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
index 2ebd03163c3..6a7a5ff102c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
@@ -104,7 +104,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
dbClient.componentDao().insert(dbTester.getSession(), moduleDto);
ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
dbClient.componentDao().insert(dbTester.getSession(), directoryDto);
- ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), fileDto);
dbTester.getSession().commit();
@@ -173,7 +173,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
dbClient.componentDao().insert(dbTester.getSession(), directoryDto);
- ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), fileDto);
dbTester.getSession().commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
index 32074d055ce..ac5af070aa4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
@@ -31,11 +31,11 @@ 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.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
import org.sonar.server.computation.task.projectanalysis.component.MutableDbIdsRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.component.MutableDisabledComponentsHolder;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.step.ComputationStep;
import static org.assertj.core.api.Assertions.assertThat;
@@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
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.ComponentDto.formatUuidPathFromParent;
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;
@@ -383,7 +382,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), module);
ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir");
- ComponentDto file = ComponentTesting.newFileDto(module, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ ComponentDto file = ComponentTesting.newFileDto(module, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), directory, file);
dbTester.getSession().commit();
@@ -528,7 +527,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
.setName("Module B");
dbClient.componentDao().insert(dbTester.getSession(), moduleA, moduleB);
ComponentDto directory = ComponentTesting.newDirectory(moduleB, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_B:src/main/java/dir");
- ComponentDto file = ComponentTesting.newFileDto(moduleB, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_B:src/main/java/dir/Foo.java");
+ ComponentDto file = ComponentTesting.newFileDto(moduleB, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_B:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), directory, file);
dbTester.getSession().commit();
@@ -623,10 +622,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
.setUuid("CDEF")
.setKey("MODULE_KEY:src/main/java/dir")
.setEnabled(false);
- ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, "DEFG")
- // method ComponentTesting.newFileDto is buggy because it only takes the module/project and assumes it is the parent of the file,
- // which is wrong here (and most of the time), it is the directory
- .setUuidPath(formatUuidPathFromParent(removedDirectory))
+ ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, removedDirectory, "DEFG")
.setPath("src/main/java/dir/Foo.java")
.setName("Foo.java")
.setKey("MODULE_KEY:src/main/java/dir/Foo.java")
@@ -724,7 +720,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
dbClient.componentDao().insert(dbTester.getSession(), module, removedModule);
ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir");
// The file was attached to another module
- ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
+ ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
.setKey("MODULE_KEY:src/main/java/dir/Foo.java").setEnabled(false);
dbClient.componentDao().insert(dbTester.getSession(), directory, removedFile);
dbTester.getSession().commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java
index 5bfda9d6d01..d49e12a01e8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java
@@ -70,9 +70,9 @@ public class DuplicationsJsonWriterTest {
@Test
public void write_duplications() {
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
- ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setRootUuid("uuid_5");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setRootUuid("uuid_5");
String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
- ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5");
when(componentDao.selectByKey(session, key1)).thenReturn(Optional.of(file1));
when(componentDao.selectByKey(session, key2)).thenReturn(Optional.of(file2));
@@ -129,9 +129,9 @@ public class DuplicationsJsonWriterTest {
@Test
public void write_duplications_without_sub_project() {
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
- ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
- ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setKey(key2).setLongName("PropertyUpdateQuery");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setId(11L).setKey(key2).setLongName("PropertyUpdateQuery");
when(componentDao.selectByKey(session, key1)).thenReturn(Optional.of(file1));
when(componentDao.selectByKey(session, key2)).thenReturn(Optional.of(file2));
@@ -178,7 +178,7 @@ public class DuplicationsJsonWriterTest {
@Test
public void write_duplications_with_a_removed_component() {
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
- ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
when(componentDao.selectByKey(session, key1)).thenReturn(Optional.of(file1));
when(componentDao.selectByUuid(session, project.uuid())).thenReturn(Optional.of(project));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
index c1addc7c9bc..f33035ca6e6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
@@ -71,15 +71,15 @@ public class DuplicationsParserTest {
// Current file
String key1 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java";
- currentFile = newFileDto(project1).setKey(key1).setLongName("CommandExecutor");
+ currentFile = newFileDto(project1, null).setKey(key1).setLongName("CommandExecutor");
// File on same project
String key2 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
- fileOnSameProject = newFileDto(project1).setKey(key2).setLongName("CommandExecutor");
+ fileOnSameProject = newFileDto(project1, null).setKey(key2).setLongName("CommandExecutor");
// File on different project
String key3 = "com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
- fileOnDifferentProject = newFileDto(project2).setKey(key3).setLongName("CommandExecutor");
+ fileOnDifferentProject = newFileDto(project2, null).setKey(key3).setLongName("CommandExecutor");
componentDao.insert(dbSession, currentFile, fileOnSameProject, fileOnDifferentProject);
dbSession.commit();
@@ -194,9 +194,9 @@ public class DuplicationsParserTest {
@Test
public void compare_duplications() {
- ComponentDto currentFile = newFileDto(project1).setId(11L);
- ComponentDto fileOnSameProject = newFileDto(project1).setId(12L);
- ComponentDto fileOnDifferentProject = newFileDto(project2).setId(13L);
+ ComponentDto currentFile = newFileDto(project1, null).setId(11L);
+ ComponentDto fileOnSameProject = newFileDto(project1, null).setId(12L);
+ ComponentDto fileOnDifferentProject = newFileDto(project2, null).setId(13L);
DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile.uuid(), currentFile.projectUuid());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java
index 9d8ce2a9480..cd042c45c3d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java
@@ -65,7 +65,7 @@ public class ActionServiceTest {
when(dbClient.openSession(false)).thenReturn(session);
project = newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
- issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project), project).setKee(ISSUE_KEY);
+ issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY);
underTest = new ActionService(dbClient, userSession, issueService);
}
@@ -90,13 +90,13 @@ public class ActionServiceTest {
@Test
public void doest_not_return_assign_to_me_action_when_issue_already_assigned_to_user() {
userSession.login("julien");
- IssueDto issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project), project).setKee(ISSUE_KEY).setAssignee("julien");
+ IssueDto issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY).setAssignee("julien");
assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).doesNotContain("assign_to_me");
}
@Test
public void return_only_comment_action_when_issue_has_a_resolution() {
- IssueDto issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project), project).setKee(ISSUE_KEY).setResolution(RESOLUTION_FIXED);
+ IssueDto issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY).setResolution(RESOLUTION_FIXED);
assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
index 2ddc44798c4..2f8bd826394 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
@@ -90,7 +90,7 @@ public class IssueBulkChangeServiceMediumTest {
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
tester.get(SnapshotDao.class).insert(session, projectSnapshot);
- file = ComponentTesting.newFileDto(project).setKey("MyComponent");
+ file = ComponentTesting.newFileDto(project, null).setKey("MyComponent");
tester.get(ComponentDao.class).insert(session, file);
// project can be seen by anyone
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
index f98aed6c7a6..20647c01b3d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
@@ -84,7 +84,7 @@ public class IssueCommentServiceMediumTest {
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
tester.get(SnapshotDao.class).insert(session, projectSnapshot);
- file = ComponentTesting.newFileDto(project);
+ file = ComponentTesting.newFileDto(project, null);
tester.get(ComponentDao.class).insert(session, file);
// project can be seen by anyone
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceTest.java
index c02a79c08ea..60707a7b75a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceTest.java
@@ -103,7 +103,7 @@ public class IssueCommentServiceTest {
@Test
public void should_add_comment() {
- IssueDto issueDto = IssueTesting.newDto(RuleTesting.newXooX1().setId(500), ComponentTesting.newFileDto(ComponentTesting.newProjectDto()), ComponentTesting.newProjectDto());
+ IssueDto issueDto = IssueTesting.newDto(RuleTesting.newXooX1().setId(500), ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), null), ComponentTesting.newProjectDto());
when(issueService.getByKeyForUpdate(session, "ABCD")).thenReturn(issueDto);
when(issueCommentService.findComments(session, "ABCD")).thenReturn(newArrayList(new DefaultIssueComment()));
@@ -146,7 +146,7 @@ public class IssueCommentServiceTest {
@Test
public void fail_if_comment_not_inserted_in_db() {
- IssueDto issueDto = IssueTesting.newDto(RuleTesting.newXooX1().setId(500), ComponentTesting.newFileDto(ComponentTesting.newProjectDto()), ComponentTesting.newProjectDto());
+ IssueDto issueDto = IssueTesting.newDto(RuleTesting.newXooX1().setId(500), ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), null), ComponentTesting.newProjectDto());
when(issueService.getByKeyForUpdate(session, "ABCD")).thenReturn(issueDto);
// Comment has not be inserted in db
when(issueCommentService.findComments(session, "ABCD")).thenReturn(Collections.<DefaultIssueComment>emptyList());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
index 5a6d8846cda..37153200261 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
@@ -344,7 +344,7 @@ public class IssueServiceMediumTest {
}
private ComponentDto newFile(ComponentDto project) {
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
tester.get(ComponentDao.class).insert(session, file);
session.commit();
return file;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
index 72e023b37ec..a10ad421290 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
@@ -84,9 +84,9 @@ public class IssueIndexDebtTest {
ComponentDto project2 = ComponentTesting.newProjectDto("EFGH");
indexIssues(
- IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)).setEffort(10L),
- IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)).setEffort(10L),
- IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)).setEffort(10L));
+ IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L),
+ IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)).setEffort(10L),
+ IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(),
new SearchOptions().addFacets(newArrayList("projectUuids")));
@@ -98,9 +98,9 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_components() {
ComponentDto project = ComponentTesting.newProjectDto("A");
- ComponentDto file1 = ComponentTesting.newFileDto(project, "ABCD");
- ComponentDto file2 = ComponentTesting.newFileDto(project, "BCDE");
- ComponentDto file3 = ComponentTesting.newFileDto(project, "CDEF");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE");
+ ComponentDto file3 = ComponentTesting.newFileDto(project, null, "CDEF");
indexIssues(
IssueTesting.newDoc("ISSUE1", project),
@@ -119,8 +119,8 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_directories() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file1 = ComponentTesting.newFileDto(project).setPath("src/main/xoo/F1.xoo");
- ComponentDto file2 = ComponentTesting.newFileDto(project).setPath("F2.xoo");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo");
indexIssues(
IssueTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"),
@@ -135,7 +135,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_severities() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setSeverity(Severity.INFO),
@@ -151,7 +151,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_statuses() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED),
@@ -167,7 +167,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_resolutions() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE),
@@ -183,7 +183,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_languages() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo").setEffort(10L));
@@ -197,7 +197,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_assignees() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("steph"),
@@ -214,7 +214,7 @@ public class IssueIndexDebtTest {
@Test
public void facets_on_authors() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAuthorLogin("steph"),
@@ -249,9 +249,9 @@ public class IssueIndexDebtTest {
ComponentDto project2 = ComponentTesting.newProjectDto("EFGH");
indexIssues(
- IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)).setEffort(10L),
- IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)).setEffort(10L),
- IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)).setEffort(10L));
+ IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L),
+ IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)).setEffort(10L),
+ IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).facetMode(DEPRECATED_FACET_MODE_DEBT).build(),
new SearchOptions().addFacets(newArrayList("projectUuids")));
@@ -262,7 +262,7 @@ public class IssueIndexDebtTest {
protected SearchOptions fixtureForCreatedAtFacet() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue0 = IssueTesting.newDoc("ISSUE0", file).setFuncCreationDate(DateUtils.parseDateTime("2011-04-25T01:05:13+0100"));
IssueDoc issue1 = IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(DateUtils.parseDateTime("2014-09-01T12:34:56+0100"));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
index 987fb1dcde6..3bca5f4b800 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
@@ -95,7 +95,7 @@ public class IssueIndexTest {
@Test
public void get_by_key() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file)
.setEffort(100L);
indexIssues(issue);
@@ -110,7 +110,7 @@ public class IssueIndexTest {
@Test
public void get_by_key_with_attributes() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file).setAttributes((KeyValueFormat.format(ImmutableMap.of("jira-issue-key", "SONAR-1234"))));
indexIssues(issue);
@@ -121,7 +121,7 @@ public class IssueIndexTest {
@Test(expected = IllegalStateException.class)
public void comments_field_is_not_available() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file);
indexIssues(issue);
@@ -132,7 +132,7 @@ public class IssueIndexTest {
@Test(expected = IllegalStateException.class)
public void is_new_field_is_not_available() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file);
indexIssues(issue);
@@ -150,8 +150,8 @@ public class IssueIndexTest {
ComponentDto project = ComponentTesting.newProjectDto();
indexIssues(
- IssueTesting.newDoc("1", ComponentTesting.newFileDto(project)),
- IssueTesting.newDoc("2", ComponentTesting.newFileDto(project)));
+ IssueTesting.newDoc("1", ComponentTesting.newFileDto(project, null)),
+ IssueTesting.newDoc("2", ComponentTesting.newFileDto(project, null)));
assertThat(underTest.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1", "2")).build(), new SearchOptions()).getDocs()).hasSize(2);
assertThat(underTest.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1")).build(), new SearchOptions()).getDocs()).hasSize(1);
@@ -166,11 +166,11 @@ public class IssueIndexTest {
indexIssues(
IssueTesting.newDoc("ISSUE1", project),
- IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)),
+ IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)),
IssueTesting.newDoc("ISSUE3", module),
- IssueTesting.newDoc("ISSUE4", ComponentTesting.newFileDto(module)),
+ IssueTesting.newDoc("ISSUE4", ComponentTesting.newFileDto(module, null)),
IssueTesting.newDoc("ISSUE5", subModule),
- IssueTesting.newDoc("ISSUE6", ComponentTesting.newFileDto(subModule)));
+ IssueTesting.newDoc("ISSUE6", ComponentTesting.newFileDto(subModule, null)));
assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
@@ -182,9 +182,9 @@ public class IssueIndexTest {
ComponentDto project2 = ComponentTesting.newProjectDto("EFGH");
indexIssues(
- IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project)),
- IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)),
- IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)));
+ IssueTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)),
+ IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)),
+ IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2, null)));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
assertThat(result.getFacets().getNames()).containsOnly("projectUuids");
@@ -196,7 +196,7 @@ public class IssueIndexTest {
ComponentDto project = ComponentTesting.newProjectDto();
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
- ComponentDto file = ComponentTesting.newFileDto(subModule);
+ ComponentDto file = ComponentTesting.newFileDto(subModule, null);
indexIssues(
IssueTesting.newDoc("ISSUE3", module),
@@ -229,9 +229,9 @@ public class IssueIndexTest {
ComponentDto project = ComponentTesting.newProjectDto();
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
- ComponentDto file1 = ComponentTesting.newFileDto(project);
- ComponentDto file2 = ComponentTesting.newFileDto(module);
- ComponentDto file3 = ComponentTesting.newFileDto(subModule);
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null);
+ ComponentDto file2 = ComponentTesting.newFileDto(module, null);
+ ComponentDto file3 = ComponentTesting.newFileDto(subModule, null);
String view = "ABCD";
indexView(view, newArrayList(project.uuid()));
@@ -262,11 +262,11 @@ public class IssueIndexTest {
@Test
public void filter_by_components_on_non_contextualized_search() {
ComponentDto project = ComponentTesting.newProjectDto("project");
- ComponentDto file1 = ComponentTesting.newFileDto(project, "file1");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null, "file1");
ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("module");
- ComponentDto file2 = ComponentTesting.newFileDto(module, "file2");
+ ComponentDto file2 = ComponentTesting.newFileDto(module, null, "file2");
ComponentDto subModule = ComponentTesting.newModuleDto(module).setUuid("subModule");
- ComponentDto file3 = ComponentTesting.newFileDto(subModule, "file3");
+ ComponentDto file3 = ComponentTesting.newFileDto(subModule, null, "file3");
String view = "ABCD";
indexView(view, newArrayList(project.uuid()));
@@ -293,9 +293,9 @@ public class IssueIndexTest {
@Test
public void facets_on_components() {
ComponentDto project = ComponentTesting.newProjectDto("A");
- ComponentDto file1 = ComponentTesting.newFileDto(project, "ABCD");
- ComponentDto file2 = ComponentTesting.newFileDto(project, "BCDE");
- ComponentDto file3 = ComponentTesting.newFileDto(project, "CDEF");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE");
+ ComponentDto file3 = ComponentTesting.newFileDto(project, null, "CDEF");
indexIssues(
IssueTesting.newDoc("ISSUE1", project),
@@ -313,8 +313,8 @@ public class IssueIndexTest {
@Test
public void filter_by_directories() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file1 = ComponentTesting.newFileDto(project).setPath("src/main/xoo/F1.xoo");
- ComponentDto file2 = ComponentTesting.newFileDto(project).setPath("F2.xoo");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo");
indexIssues(
IssueTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"),
@@ -328,8 +328,8 @@ public class IssueIndexTest {
@Test
public void facets_on_directories() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file1 = ComponentTesting.newFileDto(project).setPath("src/main/xoo/F1.xoo");
- ComponentDto file2 = ComponentTesting.newFileDto(project).setPath("F2.xoo");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo");
indexIssues(
IssueTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"),
@@ -343,7 +343,7 @@ public class IssueIndexTest {
@Test
public void filter_by_views() {
ComponentDto project1 = ComponentTesting.newProjectDto();
- ComponentDto file1 = ComponentTesting.newFileDto(project1);
+ ComponentDto file1 = ComponentTesting.newFileDto(project1, null);
ComponentDto project2 = ComponentTesting.newProjectDto();
indexIssues(
// Project1 has 2 issues (one on a file and one on the project itself)
@@ -369,7 +369,7 @@ public class IssueIndexTest {
@Test
public void filter_by_severities() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setSeverity(Severity.INFO),
@@ -383,7 +383,7 @@ public class IssueIndexTest {
@Test
public void facets_on_severities() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setSeverity(Severity.INFO),
@@ -398,7 +398,7 @@ public class IssueIndexTest {
@Test
public void filter_by_statuses() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED),
@@ -413,7 +413,7 @@ public class IssueIndexTest {
@Test
public void facets_on_statuses() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED),
@@ -428,7 +428,7 @@ public class IssueIndexTest {
@Test
public void filter_by_resolutions() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE),
@@ -445,7 +445,7 @@ public class IssueIndexTest {
@Test
public void facets_on_resolutions() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE),
@@ -460,7 +460,7 @@ public class IssueIndexTest {
@Test
public void filter_by_resolved() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED),
@@ -475,7 +475,7 @@ public class IssueIndexTest {
@Test
public void filter_by_rules() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()));
@@ -487,7 +487,7 @@ public class IssueIndexTest {
@Test
public void filter_by_languages() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
@@ -500,7 +500,7 @@ public class IssueIndexTest {
@Test
public void facets_on_languages() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
@@ -513,7 +513,7 @@ public class IssueIndexTest {
@Test
public void filter_by_assignees() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("steph"),
@@ -528,7 +528,7 @@ public class IssueIndexTest {
@Test
public void facets_on_assignees() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("steph"),
@@ -544,7 +544,7 @@ public class IssueIndexTest {
@Test
public void facets_on_assignees_supports_dashes() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("j-b"),
@@ -561,7 +561,7 @@ public class IssueIndexTest {
@Test
public void filter_by_assigned() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("steph"),
@@ -576,7 +576,7 @@ public class IssueIndexTest {
@Test
public void filter_by_authors() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAuthorLogin("steph"),
@@ -591,7 +591,7 @@ public class IssueIndexTest {
@Test
public void facets_on_authors() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAuthorLogin("steph"),
@@ -607,7 +607,7 @@ public class IssueIndexTest {
@Test
public void filter_by_created_after() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")),
@@ -623,7 +623,7 @@ public class IssueIndexTest {
@Test
public void filter_by_created_before() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")),
@@ -639,7 +639,7 @@ public class IssueIndexTest {
@Test
public void filter_by_created_after_and_before() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")),
@@ -685,7 +685,7 @@ public class IssueIndexTest {
@Test
public void filter_by_create_after_and_before_take_into_account_timezone() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDateTime("2014-09-20T00:00:00+0100")),
@@ -732,7 +732,7 @@ public class IssueIndexTest {
@Test
public void filter_by_created_at() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")));
@@ -872,7 +872,7 @@ public class IssueIndexTest {
private SearchOptions fixtureForCreatedAtFacet() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
IssueDoc issue0 = IssueTesting.newDoc("ISSUE0", file).setFuncCreationDate(parseDateTime("2011-04-25T00:05:13+0000"));
IssueDoc issue1 = IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDateTime("2014-09-01T12:34:56+0100"));
@@ -890,7 +890,7 @@ public class IssueIndexTest {
@Test
public void paging() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
for (int i = 0; i < 12; i++) {
indexIssues(IssueTesting.newDoc("ISSUE" + i, file));
}
@@ -913,7 +913,7 @@ public class IssueIndexTest {
@Test
public void search_with_max_limit() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
List<IssueDoc> issues = newArrayList();
for (int i = 0; i < 500; i++) {
String key = "ISSUE" + i;
@@ -929,7 +929,7 @@ public class IssueIndexTest {
@Test
public void sort_by_status() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_OPEN),
@@ -952,7 +952,7 @@ public class IssueIndexTest {
@Test
public void sort_by_severity() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setSeverity(Severity.BLOCKER),
@@ -981,7 +981,7 @@ public class IssueIndexTest {
@Test
public void sort_by_assignee() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setAssignee("steph"),
@@ -1003,7 +1003,7 @@ public class IssueIndexTest {
@Test
public void sort_by_creation_date() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDateTime("2014-09-23T00:00:00+0100")),
@@ -1025,7 +1025,7 @@ public class IssueIndexTest {
@Test
public void sort_by_update_date() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncUpdateDate(parseDateTime("2014-09-23T00:00:00+0100")),
@@ -1047,7 +1047,7 @@ public class IssueIndexTest {
@Test
public void sort_by_close_date() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(
IssueTesting.newDoc("ISSUE1", file).setFuncCloseDate(parseDateTime("2014-09-23T00:00:00+0100")),
@@ -1072,8 +1072,8 @@ public class IssueIndexTest {
@Test
public void sort_by_file_and_line() {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file1 = ComponentTesting.newFileDto(project, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo");
- ComponentDto file2 = ComponentTesting.newFileDto(project, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo");
indexIssues(
// file F1
@@ -1116,9 +1116,9 @@ public class IssueIndexTest {
ComponentDto project2 = ComponentTesting.newProjectDto().setKey("project2");
ComponentDto project3 = ComponentTesting.newProjectDto().setKey("project3");
- ComponentDto file1 = ComponentTesting.newFileDto(project1).setKey("file1");
- ComponentDto file2 = ComponentTesting.newFileDto(project2).setKey("file2");
- ComponentDto file3 = ComponentTesting.newFileDto(project3).setKey("file3");
+ ComponentDto file1 = ComponentTesting.newFileDto(project1, null).setKey("file1");
+ ComponentDto file2 = ComponentTesting.newFileDto(project2, null).setKey("file2");
+ ComponentDto file3 = ComponentTesting.newFileDto(project3, null).setKey("file3");
// project1 can be seen by sonar-users
indexIssue(IssueTesting.newDoc("ISSUE1", file1), "sonar-users", null);
@@ -1149,9 +1149,9 @@ public class IssueIndexTest {
ComponentDto project2 = ComponentTesting.newProjectDto().setKey("project2");
ComponentDto project3 = ComponentTesting.newProjectDto().setKey("project3");
- ComponentDto file1 = ComponentTesting.newFileDto(project1).setKey("file1");
- ComponentDto file2 = ComponentTesting.newFileDto(project2).setKey("file2");
- ComponentDto file3 = ComponentTesting.newFileDto(project3).setKey("file3");
+ ComponentDto file1 = ComponentTesting.newFileDto(project1, null).setKey("file1");
+ ComponentDto file2 = ComponentTesting.newFileDto(project2, null).setKey("file2");
+ ComponentDto file3 = ComponentTesting.newFileDto(project3, null).setKey("file3");
// project1 can be seen by john, project2 by max, project3 cannot be seen by anyone
indexIssue(IssueTesting.newDoc("ISSUE1", file1), null, "john");
@@ -1177,8 +1177,8 @@ public class IssueIndexTest {
ComponentDto project1 = ComponentTesting.newProjectDto().setKey("project1");
ComponentDto project2 = ComponentTesting.newProjectDto().setKey("project2");
- ComponentDto file1 = ComponentTesting.newFileDto(project1).setKey("file1");
- ComponentDto file2 = ComponentTesting.newFileDto(project2).setKey("file2");
+ ComponentDto file1 = ComponentTesting.newFileDto(project1, null).setKey("file1");
+ ComponentDto file2 = ComponentTesting.newFileDto(project2, null).setKey("file2");
// project1 can be seen by john and by sonar-users
indexIssue(IssueTesting.newDoc("ISSUE1", file1), "sonar-users", "john");
@@ -1191,7 +1191,7 @@ public class IssueIndexTest {
@Test
public void search_issues_for_batch_return_needed_fields() {
ComponentDto project = ComponentTesting.newProjectDto("PROJECT");
- ComponentDto file = ComponentTesting.newFileDto(project).setPath("src/File.xoo");
+ ComponentDto file = ComponentTesting.newFileDto(project, null).setPath("src/File.xoo");
IssueDoc issue = IssueTesting.newDoc("ISSUE", file)
.setRuleKey("squid:S001")
@@ -1229,7 +1229,7 @@ public class IssueIndexTest {
ComponentDto project = ComponentTesting.newProjectDto();
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
- ComponentDto file = ComponentTesting.newFileDto(subModule);
+ ComponentDto file = ComponentTesting.newFileDto(subModule, null);
indexIssues(
IssueTesting.newDoc("ISSUE3", module),
@@ -1260,8 +1260,8 @@ public class IssueIndexTest {
ComponentDto project1 = ComponentTesting.newProjectDto().setKey("project1");
ComponentDto project2 = ComponentTesting.newProjectDto().setKey("project2");
- ComponentDto file1 = ComponentTesting.newFileDto(project1).setKey("file1");
- ComponentDto file2 = ComponentTesting.newFileDto(project2).setKey("file2");
+ ComponentDto file1 = ComponentTesting.newFileDto(project1, null).setKey("file1");
+ ComponentDto file2 = ComponentTesting.newFileDto(project2, null).setKey("file2");
// project1 can be seen by sonar-users
indexIssue(IssueTesting.newDoc("ISSUE1", file1), "sonar-users", null);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
index 5d92cce89c5..23fde1c21a6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
@@ -97,7 +97,7 @@ public class SearchActionComponentsMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
IssueDto issue = IssueTesting.newDto(rule, file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setStatus("OPEN").setResolution("OPEN")
@@ -108,7 +108,7 @@ public class SearchActionComponentsMediumTest {
ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto("P2").setKey("PK2"));
setDefaultProjectPermission(project2);
- ComponentDto file2 = insertComponent(newFileDto(project2, "F2").setKey("FK2"));
+ ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2)
.setKee("92fd47d4-b650-4037-80bc-7b112bd4eac2")
.setStatus("OPEN").setResolution("OPEN")
@@ -128,7 +128,7 @@ public class SearchActionComponentsMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
- ComponentDto file = insertComponent(newFileDto(module, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
RuleDto newRule = newRule();
IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
@@ -157,7 +157,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_project_uuid() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@@ -188,7 +188,7 @@ public class SearchActionComponentsMediumTest {
public void search_since_leak_period_on_project() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
db.snapshotDao().insert(session,
newAnalysis(project)
.setPeriodDate(1, parseDateTime("2015-09-03T00:00:00+0100").getTime()));
@@ -217,7 +217,7 @@ public class SearchActionComponentsMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(newModuleDto(project));
- ComponentDto file = insertComponent(newFileDto(module, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
db.snapshotDao().insert(session,
newAnalysis(project).setPeriodDate(1, parseDateTime("2015-09-03T00:00:00+0100").getTime()));
RuleDto rule = newRule();
@@ -249,9 +249,9 @@ public class SearchActionComponentsMediumTest {
setDefaultProjectPermission(project1);
setDefaultProjectPermission(project2);
setDefaultProjectPermission(project3);
- ComponentDto file1 = insertComponent(newFileDto(project1, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(project2, "F2").setKey("FK2"));
- ComponentDto file3 = insertComponent(newFileDto(project3, "F3").setKey("FK3"));
+ ComponentDto file1 = insertComponent(newFileDto(project1, null, "F1").setKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
+ ComponentDto file3 = insertComponent(newFileDto(project3, null, "F3").setKey("FK3"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file1, project1).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@@ -271,7 +271,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_file_uuid() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@@ -302,8 +302,8 @@ public class SearchActionComponentsMediumTest {
public void search_by_file_key() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
- ComponentDto unitTest = insertComponent(newFileDto(project, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto unitTest = insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2"));
RuleDto rule = newRule();
IssueDto issueOnFile = IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issueOnTest = IssueTesting.newDto(rule, unitTest, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@@ -326,9 +326,9 @@ public class SearchActionComponentsMediumTest {
public void display_file_facet() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file1 = insertComponent(newFileDto(project, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(project, "F2").setKey("FK2"));
- ComponentDto file3 = insertComponent(newFileDto(project, "F3").setKey("FK3"));
+ ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setKey("FK2"));
+ ComponentDto file3 = insertComponent(newFileDto(project, null, "F3").setKey("FK3"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file2, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@@ -349,7 +349,7 @@ public class SearchActionComponentsMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@@ -384,8 +384,8 @@ public class SearchActionComponentsMediumTest {
ComponentDto module2 = insertComponent(newModuleDto("M2", project).setKey("MK2"));
ComponentDto directory1 = insertComponent(ComponentTesting.newDirectory(module1, "D1", "src/main/java/dir"));
ComponentDto directory2 = insertComponent(ComponentTesting.newDirectory(module2, "D2", "src/main/java/dir"));
- ComponentDto file1 = insertComponent(newFileDto(module1, "F1").setKey("FK1").setPath(directory1.path() + "/MyComponent.java"));
- insertComponent(newFileDto(module2, "F2").setKey("FK2").setPath(directory2.path() + "/MyComponent.java"));
+ ComponentDto file1 = insertComponent(newFileDto(module1, directory1, "F1").setKey("FK1").setPath(directory1.path() + "/MyComponent.java"));
+ insertComponent(newFileDto(module2, directory2, "F2").setKey("FK2").setPath(directory2.path() + "/MyComponent.java"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue1);
@@ -434,8 +434,8 @@ public class SearchActionComponentsMediumTest {
ComponentDto subModule1 = insertComponent(newModuleDto("SUBM1", module).setKey("SUBMK1"));
ComponentDto subModule2 = insertComponent(newModuleDto("SUBM2", module).setKey("SUBMK2"));
ComponentDto subModule3 = insertComponent(newModuleDto("SUBM3", module).setKey("SUBMK3"));
- ComponentDto file1 = insertComponent(newFileDto(subModule1, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(subModule2, "F2").setKey("FK2"));
+ ComponentDto file1 = insertComponent(newFileDto(subModule1, null, "F1").setKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(subModule2, null, "F2").setKey("FK2"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file2, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@@ -456,7 +456,7 @@ public class SearchActionComponentsMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
+ ComponentDto file = insertComponent(newFileDto(project, directory, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@@ -474,7 +474,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_view_uuid() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ 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("V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
@@ -493,7 +493,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_view_uuid_return_only_authorized_view() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ 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("V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
@@ -513,7 +513,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_sub_view_uuid() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ 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("V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
@@ -534,7 +534,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_sub_view_uuid_return_only_authorized_view() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ 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("V1").setQualifier(Qualifiers.VIEW).setKey("MyView"));
@@ -556,7 +556,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_author() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("leia").setKee("2bd4eac2-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("luke@skywalker.name").setKee("82fd47d4-b650-4037-80bc-7b1182fd47d4");
@@ -582,7 +582,7 @@ public class SearchActionComponentsMediumTest {
public void search_by_developer() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
ComponentDto developer = insertComponent(ComponentTesting.newDeveloper("Anakin Skywalker"));
db.authorDao().insertAuthor(session, "vader", developer.getId());
db.authorDao().insertAuthor(session, "anakin@skywalker.name", developer.getId());
@@ -604,11 +604,11 @@ public class SearchActionComponentsMediumTest {
public void search_by_developer_technical_project() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("P1").setKey("PK1"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(newFileDto(project, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
ComponentDto otherProject = insertComponent(ComponentTesting.newProjectDto("P2").setKey("PK2"));
setDefaultProjectPermission(otherProject);
- ComponentDto otherFile = insertComponent(newFileDto(otherProject, "F2").setKey("FK2"));
+ ComponentDto otherFile = insertComponent(newFileDto(otherProject, null, "F2").setKey("FK2"));
ComponentDto developer = insertComponent(ComponentTesting.newDeveloper("Anakin Skywalker"));
ComponentDto technicalProject = insertComponent(ComponentTesting.newDevProjectCopy("COPY_P1", project, developer));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
index aa04415b7d4..ee0a2966afb 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
@@ -118,7 +118,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setEffort(10L)
@@ -146,7 +146,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
@@ -182,7 +182,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
@@ -216,7 +216,7 @@ public class SearchActionMediumTest {
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
@@ -237,7 +237,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project).setUuid("REMOVED_FILE_ID")
+ ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project, null).setUuid("REMOVED_FILE_ID")
.setKey("REMOVED_FILE_KEY")
.setEnabled(false));
@@ -261,7 +261,7 @@ public class SearchActionMediumTest {
public void issue_contains_component_id_for_eclipse() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project);
db.issueDao().insert(session, issue);
session.commit();
@@ -276,7 +276,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
for (int i = 0; i < QueryContext.MAX_LIMIT + 1; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@@ -293,7 +293,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("ProjectHavingModule"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile"));
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, "BCDE").setKey("FileLinkedToModule"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setKey("FileLinkedToModule"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project);
db.issueDao().insert(session, issue);
session.commit();
@@ -307,7 +307,7 @@ public class SearchActionMediumTest {
public void display_facets() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
@@ -331,7 +331,7 @@ public class SearchActionMediumTest {
public void display_facets_in_effort_mode() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
@@ -356,7 +356,7 @@ public class SearchActionMediumTest {
public void display_zero_valued_facets_for_selected_items() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
@@ -384,7 +384,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
@@ -428,7 +428,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setStatus("OPEN")
@@ -458,7 +458,7 @@ public class SearchActionMediumTest {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
@@ -501,7 +501,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
db.issueDao().insert(session, IssueTesting.newDto(rule, file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac1")
.setIssueUpdateDate(DateUtils.parseDateTime("2014-11-02T00:00:00+0100")));
@@ -526,7 +526,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@@ -547,7 +547,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@@ -568,7 +568,7 @@ public class SearchActionMediumTest {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@@ -596,7 +596,7 @@ public class SearchActionMediumTest {
public void display_deprecated_debt_fields() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto("PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
index 0e2cc1dfa81..b4b7e986623 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
@@ -149,7 +149,7 @@ public class ComponentActionTest {
componentDb.insertDeveloperAndSnapshot(developer);
ComponentDto project = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file = newFileDto(project, "file-uuid");
+ ComponentDto file = newFileDto(project, null, "file-uuid");
componentDb.insertComponent(file);
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
@@ -172,7 +172,7 @@ public class ComponentActionTest {
componentDb.insertDeveloperAndSnapshot(developer);
ComponentDto project = newProjectDto(PROJECT_UUID);
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file = newFileDto(project, "file-uuid");
+ ComponentDto file = newFileDto(project, null, "file-uuid");
componentDb.insertComponent(file);
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
@@ -321,7 +321,7 @@ public class ComponentActionTest {
.setPeriodDate(3, parseDateTime("2016-01-11T10:38:45+0100").getTime())
.setPeriodMode(3, "days")
.setPeriodParam(3, "30");
- ComponentDto file = newFileDto(project)
+ ComponentDto file = newFileDto(project, null)
.setUuid("AVIwDXE-bJbJqrw6wFv5")
.setKey("MY_PROJECT:ElementImpl.java")
.setName("ElementImpl.java")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
index 158449e9487..ebf301dfc8a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
@@ -151,7 +151,7 @@ public class ComponentTreeActionTest {
userSession.anonymous().addProjectUuidPermissions(UserRole.ADMIN, "project-uuid");
ComponentDto directoryDto = newDirectory(projectDto, "directory-uuid", "path/to/directory").setName("directory-1");
componentDb.insertComponent(directoryDto);
- ComponentDto file = newFileDto(directoryDto, "file-uuid").setName("file-1");
+ ComponentDto file = newFileDto(directoryDto, null, "file-uuid").setName("file-1");
componentDb.insertComponent(file);
MetricDto ncloc = insertNclocMetric();
MetricDto coverage = insertCoverageMetric();
@@ -181,7 +181,7 @@ public class ComponentTreeActionTest {
userSession.anonymous().addProjectUuidPermissions(UserRole.ADMIN, "project-uuid");
ComponentDto directoryDto = newDirectory(projectDto, "directory-uuid", "path/to/directory").setName("directory-1");
componentDb.insertComponent(directoryDto);
- ComponentDto file = newFileDto(directoryDto, "file-uuid").setName("file-1");
+ ComponentDto file = newFileDto(directoryDto, null, "file-uuid").setName("file-1");
componentDb.insertComponent(file);
MetricDto coverage = insertCoverageMetric();
dbClient.metricDao().insert(dbSession, newMetricDto()
@@ -221,15 +221,15 @@ public class ComponentTreeActionTest {
public void load_measures_multi_sort_with_metric_key_and_paginated() {
ComponentDto projectDto = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
- ComponentDto file9 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-9").setName("file-1"));
- ComponentDto file8 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-8").setName("file-1"));
- ComponentDto file7 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-7").setName("file-1"));
- ComponentDto file6 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-6").setName("file-1"));
- ComponentDto file5 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-5").setName("file-1"));
- ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-4").setName("file-1"));
- ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-3").setName("file-1"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-2").setName("file-1"));
- ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-1").setName("file-1"));
+ 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"));
+ ComponentDto file7 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-7").setName("file-1"));
+ ComponentDto file6 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-6").setName("file-1"));
+ ComponentDto file5 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-5").setName("file-1"));
+ ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4").setName("file-1"));
+ ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3").setName("file-1"));
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-2").setName("file-1"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1").setName("file-1"));
MetricDto coverage = insertCoverageMetric();
dbClient.measureDao().insert(dbSession,
newMeasureDto(coverage, file1, projectSnapshot).setValue(1.0d),
@@ -260,10 +260,10 @@ public class ComponentTreeActionTest {
public void sort_by_metric_value() {
ComponentDto projectDto = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
- ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-4"));
- ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-3"));
- ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-1"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-2"));
+ ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4"));
+ ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1"));
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-2"));
MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1);
dbClient.metricDao().insert(dbSession, ncloc);
dbClient.measureDao().insert(dbSession,
@@ -286,10 +286,10 @@ public class ComponentTreeActionTest {
public void remove_components_without_measure_on_the_metric_sort() {
ComponentDto project = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file1 = newFileDto(project, "file-uuid-1");
- ComponentDto file2 = newFileDto(project, "file-uuid-2");
- ComponentDto file3 = newFileDto(project, "file-uuid-3");
- ComponentDto file4 = newFileDto(project, "file-uuid-4");
+ ComponentDto file1 = newFileDto(project, null, "file-uuid-1");
+ ComponentDto file2 = newFileDto(project, null, "file-uuid-2");
+ ComponentDto file3 = newFileDto(project, null, "file-uuid-3");
+ ComponentDto file4 = newFileDto(project, null, "file-uuid-4");
componentDb.insertComponent(file1);
componentDb.insertComponent(file2);
componentDb.insertComponent(file3);
@@ -321,9 +321,9 @@ public class ComponentTreeActionTest {
public void sort_by_metric_period() {
ComponentDto projectDto = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
- ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-3"));
- ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-1"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-2"));
+ ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1"));
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-2"));
MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1);
dbClient.metricDao().insert(dbSession, ncloc);
dbClient.measureDao().insert(dbSession,
@@ -346,10 +346,10 @@ public class ComponentTreeActionTest {
public void remove_components_without_measure_on_the_metric_period_sort() {
ComponentDto projectDto = newProjectDto("project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto);
- ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-4"));
- ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-3"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-2"));
- ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, "file-uuid-1"));
+ ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4"));
+ ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3"));
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-2"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1"));
MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("new_ncloc").setValueType(ValueType.INT.name()).setDirection(1);
dbClient.metricDao().insert(dbSession, ncloc);
dbClient.measureDao().insert(dbSession,
@@ -402,8 +402,8 @@ public class ComponentTreeActionTest {
ComponentDto project = newProjectDto("project-uuid").setKey("project-key");
componentDb.insertDeveloperAndSnapshot(developer);
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file1 = componentDb.insertComponent(newFileDto(project, "file1-uuid"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(project, "file2-uuid"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(project, null, "file1-uuid"));
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(project, null, "file2-uuid"));
componentDb.insertComponent(newDevProjectCopy("project-uuid-copy", project, developer));
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
@@ -435,7 +435,7 @@ public class ComponentTreeActionTest {
ComponentDto project = newProjectDto("project-uuid").setKey("project-key");
componentDb.insertDeveloperAndSnapshot(developer);
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file1 = componentDb.insertComponent(newFileDto(project, "file1-uuid"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(project, null, "file1-uuid"));
componentDb.insertComponent(newDevProjectCopy("project-uuid-copy", project, developer));
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
@@ -462,7 +462,7 @@ public class ComponentTreeActionTest {
String projectUuid = "project-uuid";
ComponentDto project = newProjectDto(projectUuid);
componentDb.insertProjectAndSnapshot(project);
- componentDb.insertComponent(newFileDto(project));
+ componentDb.insertComponent(newFileDto(project, null));
insertNclocMetric();
ComponentTreeWsResponse result = call(ws.newRequest()
@@ -482,7 +482,7 @@ public class ComponentTreeActionTest {
ComponentDto project = newProjectDto("project-uuid").setKey("project-key");
componentDb.insertDeveloperAndSnapshot(developer);
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
- ComponentDto file1 = componentDb.insertComponent(newFileDto(project, "file1-uuid"));
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(project, null, "file1-uuid"));
componentDb.insertComponent(newDevProjectCopy("project-uuid-copy", project, developer));
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
@@ -652,14 +652,14 @@ public class ComponentTreeActionTest {
.setPeriodMode(3, "days")
.setPeriodParam(3, "30"));
- ComponentDto file1 = componentDb.insertComponent(newFileDto(project)
+ ComponentDto file1 = componentDb.insertComponent(newFileDto(project, null)
.setUuid("AVIwDXE-bJbJqrw6wFv5")
.setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/ElementImpl.java")
.setName("ElementImpl.java")
.setLanguage("java")
.setQualifier(Qualifiers.FILE)
.setPath("src/main/java/com/sonarsource/markdown/impl/ElementImpl.java"));
- ComponentDto file2 = componentDb.insertComponent(newFileDto(project)
+ ComponentDto file2 = componentDb.insertComponent(newFileDto(project, null)
.setUuid("AVIwDXE_bJbJqrw6wFwJ")
.setKey("com.sonarsource:java-markdown:src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java")
.setName("ElementImplTest.java")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
index 6c01be3d067..75469c254e9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
@@ -206,7 +206,7 @@ public class AddGroupActionTest {
insertGroup("sonar-administrators");
ComponentDto project = newProjectDto("project-uuid").setKey("project-key");
insertComponent(project);
- insertComponent(ComponentTesting.newFileDto(project, "file-uuid"));
+ insertComponent(ComponentTesting.newFileDto(project, null, "file-uuid"));
commit();
newRequest()
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
index 26e0c56e1e4..623a56097cc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
@@ -169,7 +169,7 @@ public class AddUserActionTest {
@Test
public void fail_when_component_is_not_a_project() throws Exception {
expectedException.expect(BadRequestException.class);
- insertComponent(newFileDto(newProjectDto("project-uuid"), "file-uuid"));
+ insertComponent(newFileDto(newProjectDto("project-uuid"), null, "file-uuid"));
commit();
ws.newPostRequest(CONTROLLER, ACTION)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
index 3df7726edc8..222a657629b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
@@ -187,7 +187,7 @@ public class RemoveGroupActionTest {
@Test
public void fail_when_component_is_not_a_project() throws Exception {
expectedException.expect(BadRequestException.class);
- insertComponent(newFileDto(newProjectDto("project-uuid"), "file-uuid"));
+ insertComponent(newFileDto(newProjectDto("project-uuid"), null, "file-uuid"));
insertGroup("sonar-administrators");
commit();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
index 1b6ceb69fec..bffdd63221e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
@@ -163,7 +163,7 @@ public class RemoveUserActionTest {
@Test
public void fail_when_component_is_not_a_project() throws Exception {
expectedException.expect(BadRequestException.class);
- insertComponent(newFileDto(newProjectDto(), "file-uuid"));
+ insertComponent(newFileDto(newProjectDto(), null, "file-uuid"));
ws.newPostRequest(CONTROLLER, ACTION)
.setParam(PARAM_USER_LOGIN, "ray.bradbury")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
index 9be6fa38854..3e92da3db20 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
@@ -181,7 +181,7 @@ public class BulkDeleteActionTest {
@Test
public void fail_if_scope_is_not_project() throws Exception {
expectedException.expect(IllegalArgumentException.class);
- dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), "file-uuid"));
+ dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), null, "file-uuid"));
dbSession.commit();
ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "file-uuid").execute();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
index 5f2485f3b2a..4adf0859344 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
@@ -200,7 +200,7 @@ public class DeleteActionTest {
@Test
public void fail_if_scope_is_not_project() throws Exception {
expectedException.expect(IllegalArgumentException.class);
- dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), "file-uuid"));
+ dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), null, "file-uuid"));
dbSession.commit();
newRequest().setParam(PARAM_ID, "file-uuid").execute();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java
index e1bf541b488..9ba327212b4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/IndexActionTest.java
@@ -64,7 +64,7 @@ public class IndexActionTest {
WsTester tester;
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
@Before
public void setUp() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java
index cd5b0f96d05..d0e7fc2e4f3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java
@@ -174,7 +174,7 @@ public class LinesActionTest {
private void newFile() {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID);
- ComponentDto file = ComponentTesting.newFileDto(project, FILE_UUID).setKey(FILE_KEY);
+ ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
componentDao.insert(dbTester.getSession(), project, file);
dbTester.getSession().commit();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java
index 07712bf75d9..a8b7c0cbde4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/RawActionTest.java
@@ -63,7 +63,7 @@ public class RawActionTest {
WsTester tester;
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
@Before
public void setUp() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java
index a1fbb0f3b0b..9d90512e3d8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmActionTest.java
@@ -182,7 +182,7 @@ public class ScmActionTest {
private void initFile() {
ComponentDto project = ComponentTesting.newProjectDto(PROJECT_UUID);
- dbClient.componentDao().insert(dbTester.getSession(), project, ComponentTesting.newFileDto(project, FILE_UUID).setKey(FILE_KEY));
+ dbClient.componentDao().insert(dbTester.getSession(), project, ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY));
dbTester.getSession().commit();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java
index 09664fd6f65..45482df88d4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ShowActionTest.java
@@ -65,7 +65,7 @@ public class ShowActionTest {
ComponentDao componentDao;
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
@Before
public void setUp() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
index e422141a965..5f560053f1b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
@@ -79,8 +79,8 @@ public class CoveredFilesActionTest {
new CoveredFileDoc().setFileUuid(FILE_2_ID).setCoveredLines(Arrays.asList(1, 2, 3))));
when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
Arrays.asList(
- newFileDto(newProjectDto(), FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
- newFileDto(newProjectDto(), FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+ newFileDto(newProjectDto(), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+ newFileDto(newProjectDto(), 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");
@@ -97,8 +97,8 @@ public class CoveredFilesActionTest {
new CoveredFileDoc().setFileUuid(FILE_2_ID).setCoveredLines(Arrays.asList(1, 2, 3))));
when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
Arrays.asList(
- newFileDto(newProjectDto(), FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
- newFileDto(newProjectDto(), FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+ newFileDto(newProjectDto(), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+ newFileDto(newProjectDto(), 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");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
index ad7cb0c8ee8..d9e0d745f66 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java
@@ -319,7 +319,7 @@ public class ComponentNavigationActionTest {
ComponentDto module = ComponentTesting.newModuleDto("bcde", project)
.setKey("palap").setName("Palap");
ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/xoo");
- ComponentDto file = ComponentTesting.newFileDto(directory, "cdef").setName("Source.xoo")
+ ComponentDto file = ComponentTesting.newFileDto(directory, directory, "cdef").setName("Source.xoo")
.setKey("palap:src/main/xoo/Source.xoo")
.setPath(directory.path());
dbClient.componentDao().insert(dbTester.getSession(), project, module, directory, file);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java
index 59428c8fb8a..2c99713694f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java
@@ -19,14 +19,6 @@
*/
package org.sonar.server.user;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.core.permission.GlobalPermissions.DASHBOARD_SHARING;
-import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN;
-import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
-import static org.sonar.db.user.UserTesting.newUserDto;
-import static org.sonar.server.user.ServerUserSession.createForAnonymous;
-import static org.sonar.server.user.ServerUserSession.createForUser;
-
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Rule;
@@ -46,6 +38,14 @@ import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserPermissionDto;
import org.sonar.server.exceptions.ForbiddenException;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.permission.GlobalPermissions.DASHBOARD_SHARING;
+import static org.sonar.core.permission.GlobalPermissions.QUALITY_PROFILE_ADMIN;
+import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
+import static org.sonar.db.user.UserTesting.newUserDto;
+import static org.sonar.server.user.ServerUserSession.createForAnonymous;
+import static org.sonar.server.user.ServerUserSession.createForUser;
+
public class ServerUserSessionTest {
static final String LOGIN = "marius";
@@ -71,7 +71,7 @@ public class ServerUserSessionTest {
@Before
public void setUp() throws Exception {
project = componentDbTester.insertComponent(ComponentTesting.newProjectDto(PROJECT_UUID));
- file = componentDbTester.insertComponent(ComponentTesting.newFileDto(project, FILE_UUID).setKey(FILE_KEY));
+ file = componentDbTester.insertComponent(ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY));
dbClient.userDao().insert(dbSession, userDto);
dbSession.commit();
}
@@ -162,7 +162,7 @@ public class ServerUserSessionTest {
@Test
public void check_component_key_permission_ko() {
ComponentDto project2 = componentDbTester.insertComponent(ComponentTesting.newProjectDto());
- ComponentDto file2 = componentDbTester.insertComponent(ComponentTesting.newFileDto(project2));
+ ComponentDto file2 = componentDbTester.insertComponent(ComponentTesting.newFileDto(project2, null));
addProjectPermissions(project, UserRole.USER);
UserSession session = newUserSession(userDto);
@@ -190,7 +190,7 @@ public class ServerUserSessionTest {
@Test
public void check_component_key_permission_when_project_not_found() {
ComponentDto project2 = componentDbTester.insertComponent(ComponentTesting.newProjectDto());
- ComponentDto file2 = componentDbTester.insertComponent(ComponentTesting.newFileDto(project2)
+ ComponentDto file2 = componentDbTester.insertComponent(ComponentTesting.newFileDto(project2, null)
// Simulate file is linked to an invalid project
.setProjectUuid("INVALID"));
addProjectPermissions(project, UserRole.USER);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
index 9a0adb7f839..11e30bec476 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
@@ -185,7 +185,7 @@ public class ViewIndexerTest {
private ComponentDto addProjectWithIssue(RuleDto rule) {
ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
+ ComponentDto file = ComponentTesting.newFileDto(project, null);
dbClient.componentDao().insert(dbSession, project, file);
dbClient.roleDao().insertGroupRole(dbSession, new GroupRoleDto().setRole(UserRole.USER).setGroupId(null).setResourceId(project.getId()));
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java
index b52484c6682..42354cd46ac 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDto.java
@@ -64,7 +64,7 @@ public class ComponentDto implements Component {
* - on root module: UUID="1" UUID_PATH="."
* - on module: UUID="2" UUID_PATH=".1."
* - on directory: UUID="3" UUID_PATH=".1.2."
- * - on file: UUID="4" UUID_PATH="1.2.3."
+ * - on file: UUID="4" UUID_PATH=".1.2.3."
* - on view: UUID="5" UUID_PATH="."
* - on sub-view: UUID="6" UUID_PATH=".5."
*
@@ -88,8 +88,8 @@ public class ComponentDto implements Component {
* Badly named, it is not the root !
* - on root module: UUID="1" ROOT_UUID="1"
* - on modules, whatever depth, value is the root module: UUID="2" ROOT_UUID="1"
- * - on directory, value is the closed module: UUID="3" ROOT_UUID="2"
- * - on file, value is the closed module: UUID="4" ROOT_UUID="2"
+ * - on directory, value is the closest module: UUID="3" ROOT_UUID="2"
+ * - on file, value is the closest module: UUID="4" ROOT_UUID="2"
* - on view: UUID="5" ROOT_UUID="5"
* - on sub-view: UUID="6" ROOT_UUID="5"
* @since 6.0
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index 70a3f9f2ddf..394d2a241e9 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -846,11 +846,11 @@ public class ComponentDaoTest {
componentDb.insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
componentDb.insertComponent(module);
- ComponentDto file1 = newFileDto(project, FILE_1_UUID).setKey("file-key-1").setName("File One");
+ ComponentDto file1 = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
componentDb.insertComponent(file1);
- ComponentDto file2 = newFileDto(module, FILE_2_UUID).setKey("file-key-2").setName("File Two");
+ ComponentDto file2 = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
componentDb.insertComponent(file2);
- ComponentDto file3 = newFileDto(module, FILE_3_UUID).setKey("file-key-3").setName("File Three");
+ ComponentDto file3 = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
componentDb.insertComponent(file3);
db.commit();
componentDb.indexAllComponents();
@@ -923,7 +923,7 @@ public class ComponentDaoTest {
ComponentDto project = newProjectDto(PROJECT_UUID);
componentDb.insertProjectAndSnapshot(project);
for (int i = 1; i <= 9; i++) {
- componentDb.insertComponent(newFileDto(project, "file-uuid-" + i));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-" + i));
}
db.commit();
@@ -941,9 +941,9 @@ public class ComponentDaoTest {
public void selectChildren_ordered_by_file_path() {
ComponentDto project = newProjectDto(PROJECT_UUID);
componentDb.insertProjectAndSnapshot(project);
- componentDb.insertComponent(newFileDto(project, "file-uuid-1").setName("file-name-1").setPath("3"));
- componentDb.insertComponent(newFileDto(project, "file-uuid-2").setName("file-name-2").setPath("2"));
- componentDb.insertComponent(newFileDto(project, "file-uuid-3").setName("file-name-3").setPath("1"));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-name-1").setPath("3"));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-2").setName("file-name-2").setPath("2"));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-3").setName("file-name-3").setPath("1"));
db.commit();
componentDb.indexAllComponents();
@@ -1007,7 +1007,7 @@ public class ComponentDaoTest {
componentDb.insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
componentDb.insertComponent(module);
- ComponentDto file = newFileDto(module, FILE_1_UUID);
+ ComponentDto file = newFileDto(module, null, FILE_1_UUID);
componentDb.insertComponent(file);
db.commit();
@@ -1023,7 +1023,7 @@ public class ComponentDaoTest {
componentDb.insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
componentDb.insertComponent(module);
- ComponentDto file = newFileDto(module, FILE_1_UUID);
+ ComponentDto file = newFileDto(module, null, FILE_1_UUID);
componentDb.insertComponent(file);
db.commit();
@@ -1045,8 +1045,8 @@ public class ComponentDaoTest {
ComponentDto project = newProjectDto(PROJECT_UUID);
componentDb.insertProjectAndSnapshot(project);
componentDb.insertComponent(newModuleDto("module-1-uuid", project));
- componentDb.insertComponent(newFileDto(project, "file-1-uuid"));
- componentDb.insertComponent(newFileDto(project, "file-2-uuid"));
+ componentDb.insertComponent(newFileDto(project, null, "file-1-uuid"));
+ componentDb.insertComponent(newFileDto(project, null, "file-2-uuid"));
db.commit();
componentDb.indexAllComponents();
@@ -1071,10 +1071,10 @@ public class ComponentDaoTest {
ComponentDto project = newProjectDto(PROJECT_UUID).setKey("project-key");
componentDb.insertProjectAndSnapshot(project);
componentDb.insertComponent(newModuleDto("module-1-uuid", project));
- componentDb.insertComponent(newFileDto(project, "file-uuid-1").setName("file-name-1"));
- componentDb.insertComponent(newFileDto(project, "another-uuid"));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-name-1"));
+ componentDb.insertComponent(newFileDto(project, null, "another-uuid"));
for (int i = 2; i <= 9; i++) {
- componentDb.insertComponent(newFileDto(project, "file-uuid-" + i).setName("file-name-" + i));
+ componentDb.insertComponent(newFileDto(project, null, "file-uuid-" + i).setName("file-name-" + i));
}
db.commit();
componentDb.indexAllComponents();
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
index 518871a4d35..ede24716973 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
@@ -110,7 +110,7 @@ public class ComponentKeyUpdaterDaoTest {
public void fail_with_functional_exception_when_sub_component_key_is_longer_than_authorized() {
ComponentDto project = newProjectDto("project-uuid").setKey("old-project-key");
componentDb.insertComponent(project);
- componentDb.insertComponent(newFileDto(project).setKey("old-project-key:file"));
+ componentDb.insertComponent(newFileDto(project, null).setKey("old-project-key:file"));
String newLongProjectKey = Strings.repeat("a", 400);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component key length (405) is longer than the maximum authorized (400). '" + newLongProjectKey + ":file' was provided.");
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java
index 3d80147a92b..2116b81f5d2 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java
@@ -20,6 +20,7 @@
package org.sonar.db.component;
import java.util.Date;
+import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.core.util.Uuids;
@@ -29,13 +30,13 @@ import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
public class ComponentTesting {
- public static ComponentDto newFileDto(ComponentDto subProjectOrProject) {
- return newFileDto(subProjectOrProject, Uuids.create());
+ public static ComponentDto newFileDto(ComponentDto subProjectOrProject, @Nullable ComponentDto directory) {
+ return newFileDto(subProjectOrProject, directory, Uuids.create());
}
- public static ComponentDto newFileDto(ComponentDto module, String fileUuid) {
+ public static ComponentDto newFileDto(ComponentDto module, @Nullable ComponentDto directory, String fileUuid) {
String path = "src/main/xoo/org/sonar/samples/File.xoo";
- return newChildComponent(fileUuid, module)
+ return newChildComponent(fileUuid, module, directory == null ? module : directory)
.setKey("KEY_" + fileUuid)
.setName("NAME_" + fileUuid)
.setLongName(path)
@@ -51,7 +52,7 @@ public class ComponentTesting {
}
public static ComponentDto newDirectory(ComponentDto module, String uuid, String path) {
- return newChildComponent(uuid, module)
+ return newChildComponent(uuid, module, module)
.setKey(!path.equals("/") ? module.getKey() + ":" + path : module.getKey() + ":/")
.setName(path)
.setLongName(path)
@@ -61,7 +62,7 @@ public class ComponentTesting {
}
public static ComponentDto newSubView(ComponentDto viewOrSubView, String uuid, String key) {
- return newChildComponent(uuid, viewOrSubView)
+ return newChildComponent(uuid, viewOrSubView, viewOrSubView)
.setKey(key)
.setName(key)
.setLongName(key)
@@ -70,7 +71,7 @@ public class ComponentTesting {
}
public static ComponentDto newModuleDto(String uuid, ComponentDto parentModuleOrProject) {
- return newChildComponent(uuid, parentModuleOrProject)
+ return newChildComponent(uuid, parentModuleOrProject, parentModuleOrProject)
.setModuleUuidPath(parentModuleOrProject.moduleUuidPath() + uuid + UUID_PATH_SEPARATOR)
.setKey("KEY_" + uuid)
.setName("NAME_" + uuid)
@@ -156,7 +157,7 @@ public class ComponentTesting {
public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) {
checkNotNull(project.getId(), "The project need to be persisted before creating this technical project.");
- return newChildComponent(uuid, view)
+ return newChildComponent(uuid, view, view)
.setUuid(uuid)
.setKey(view.key() + project.key())
.setName(project.name())
@@ -170,7 +171,7 @@ public class ComponentTesting {
public static ComponentDto newDevProjectCopy(String uuid, ComponentDto project, ComponentDto developer) {
checkNotNull(project.getId(), "The project need to be persisted before creating this technical project.");
- return newChildComponent(uuid, developer)
+ return newChildComponent(uuid, developer, developer)
.setUuid(uuid)
.setKey(developer.key() + ":" + project.key())
.setName(project.name())
@@ -182,14 +183,14 @@ public class ComponentTesting {
.setLanguage(null);
}
- public static ComponentDto newChildComponent(String uuid, ComponentDto parent) {
+ public static ComponentDto newChildComponent(String uuid, ComponentDto moduleOrProject, ComponentDto parent) {
return new ComponentDto()
.setUuid(uuid)
.setUuidPath(ComponentDto.formatUuidPathFromParent(parent))
- .setProjectUuid(parent.projectUuid())
- .setRootUuid(parent.uuid())
- .setModuleUuid(parent.uuid())
- .setModuleUuidPath(parent.moduleUuidPath())
+ .setProjectUuid(moduleOrProject.projectUuid())
+ .setRootUuid(moduleOrProject.uuid())
+ .setModuleUuid(moduleOrProject.uuid())
+ .setModuleUuidPath(moduleOrProject.moduleUuidPath())
.setCreatedAt(new Date())
.setEnabled(true);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
index 9fe992fd17e..82baa486078 100644
--- a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
@@ -39,7 +39,7 @@ public class IssueDaoTest {
public static final RuleDto RULE = RuleTesting.newXooX1();
public static final ComponentDto PROJECT = ComponentTesting.newProjectDto();
- public static final ComponentDto FILE = ComponentTesting.newFileDto(PROJECT);
+ public static final ComponentDto FILE = ComponentTesting.newFileDto(PROJECT, null);
public static final String ISSUE_KEY1 = "I1";
public static final String ISSUE_KEY2 = "I2";
diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java
index 20aec627ab3..3b3e7b13766 100644
--- a/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java
@@ -48,9 +48,9 @@ public class IssueMapperTest {
public void setUp() throws Exception {
project = ComponentTesting.newProjectDto();
dbTester.getDbClient().componentDao().insert(dbSession, project);
- file = ComponentTesting.newFileDto(project);
+ file = ComponentTesting.newFileDto(project, null);
dbTester.getDbClient().componentDao().insert(dbSession, file);
- file2 = ComponentTesting.newFileDto(project).setUuid("file2 uuid");
+ file2 = ComponentTesting.newFileDto(project, null).setUuid("file2 uuid");
dbTester.getDbClient().componentDao().insert(dbSession, file2);
rule = RuleTesting.newXooX1();
dbTester.getDbClient().ruleDao().insert(dbSession, rule);