]> source.dussan.org Git - sonarqube.git/commitdiff
ComponentDto.setProject() should only be used by unit tests as this field is retrieve...
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 26 Sep 2014 09:02:29 +0000 (11:02 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 26 Sep 2014 09:02:37 +0000 (11:02 +0200)
18 files changed:
server/sonar-server/src/test/java/org/sonar/server/batch/UploadReportActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentCleanerServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/component/SnapshotTesting.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentAppActionTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/DefaultIssueServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueBackendMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueAuthorizationIndexMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueSearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java
sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java

index 73d2a07459732e36071ed12fc493c733d885969e..ab55d82b6fe9ebf0a0ca5b481769872af174d641 100644 (file)
@@ -94,7 +94,7 @@ public class UploadReportActionMediumTest {
     ComponentDto project = new ComponentDto()
       .setId(1L)
       .setKey("MyProject")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
 
     // project can be seen by anyone
@@ -118,7 +118,7 @@ public class UploadReportActionMediumTest {
     ComponentDto project = new ComponentDto()
       .setId(1L)
       .setKey("MyProject")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
     session.commit();
 
@@ -134,7 +134,7 @@ public class UploadReportActionMediumTest {
     ComponentDto project = new ComponentDto()
       .setId(1L)
       .setKey("MyProject")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
 
     // project can be seen by anyone
@@ -142,7 +142,7 @@ public class UploadReportActionMediumTest {
     db.issueAuthorizationDao().synchronizeAfter(session, new Date(0));
 
     ComponentDto resource = new ComponentDto()
-      .setProjectId(1L)
+      .setProjectId_unit_test_only(1L)
       .setKey("MyComponent")
       .setId(2L);
     db.componentDao().insert(session, resource);
index 0f9ed0d34835f90c628dbe04667123955615c4c0..b42ae6127e58bd2836347cfa939ffca104ce83af 100644 (file)
@@ -70,7 +70,7 @@ public class ComponentCleanerServiceMediumTest {
       .setKey("MyProject")
       .setScope(Scopes.PROJECT)
       .setQualifier(Qualifiers.PROJECT)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
     session.commit();
 
@@ -86,7 +86,7 @@ public class ComponentCleanerServiceMediumTest {
       .setKey("MyProject")
       .setScope(Scopes.PROJECT)
       .setQualifier(Qualifiers.PROJECT)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
 
     // project can be seen by anyone
@@ -109,7 +109,7 @@ public class ComponentCleanerServiceMediumTest {
       .setKey("MyProject")
       .setScope(Scopes.DIRECTORY)
       .setQualifier(Qualifiers.DIRECTORY)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
     session.commit();
 
index 99e644d44a8515b60c7437d69ce6f29f173effd7..1ec6081f08dd6f1e00c0f80519a16fed0f7cd73a 100644 (file)
@@ -28,7 +28,7 @@ public class SnapshotTesting {
   public static SnapshotDto createForComponent(ComponentDto component) {
     return new SnapshotDto()
       .setResourceId(component.getId())
-      .setRootProjectId(component.projectId())
+      .setRootProjectId(component.subProjectId())
       .setLast(true);
   }
 
index 34a0835706e37dd3c7929a6bf03ce1c5262b20a0..fd84c991a5a3eda61a22e3a67061f9df930b2baf 100644 (file)
@@ -147,7 +147,7 @@ public class ComponentAppActionTest {
 
     ComponentDto file = new ComponentDto().setId(10L).setQualifier("FIL").setKey(COMPONENT_KEY).setName("Plugin.java")
       .setLongName("src/main/java/org/sonar/api/Plugin.java")
-      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(5L).setProjectId(1L);
+      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(5L).setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, COMPONENT_KEY)).thenReturn(file);
     when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
     when(componentDao.getById(1L, session)).thenReturn(new ComponentDto().setId(1L).setLongName("SonarQube").setKey("org.codehaus.sonar:sonar"));
@@ -162,7 +162,7 @@ public class ComponentAppActionTest {
     String componentKey = "org.codehaus.sonar:sonar";
     MockUserSession.set().setLogin("john").addComponentPermission(UserRole.USER, componentKey, componentKey);
 
-    ComponentDto file = new ComponentDto().setId(1L).setQualifier("TRK").setKey(componentKey).setName("SonarQube").setProjectId(1L);
+    ComponentDto file = new ComponentDto().setId(1L).setQualifier("TRK").setKey(componentKey).setName("SonarQube").setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, componentKey)).thenReturn(file);
     when(componentDao.getById(1L, session)).thenReturn(new ComponentDto().setId(1L).setLongName("SonarQube").setKey("org.codehaus.sonar:sonar"));
     when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto()));
@@ -176,7 +176,7 @@ public class ComponentAppActionTest {
     MockUserSession.set().setLogin("john").addComponentPermission(UserRole.USER, SUB_PROJECT_KEY, COMPONENT_KEY);
 
     ComponentDto file = new ComponentDto().setId(10L).setQualifier("FIL").setKey(COMPONENT_KEY).setName("Plugin.java")
-      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(1L).setProjectId(1L);
+      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(1L).setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, COMPONENT_KEY)).thenReturn(file);
     when(componentDao.getById(1L, session)).thenReturn(new ComponentDto().setId(1L).setLongName("SonarQube").setKey("org.codehaus.sonar:sonar"));
     when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto()));
@@ -306,7 +306,7 @@ public class ComponentAppActionTest {
     MockUserSession.set().addComponentPermission(UserRole.USER, SUB_PROJECT_KEY, componentKey);
 
     ComponentDto file = new ComponentDto().setId(10L).setQualifier("UTS").setKey(componentKey).setName("PlanActionTest.java")
-      .setPath("src/test/java/org/sonar/server/issue/PlanActionTest.java").setSubProjectId(5L).setProjectId(1L);
+      .setPath("src/test/java/org/sonar/server/issue/PlanActionTest.java").setSubProjectId(5L).setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, componentKey)).thenReturn(file);
     when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
     when(componentDao.getById(1L, session)).thenReturn(new ComponentDto().setId(1L).setLongName("SonarQube").setKey("org.codehaus.sonar:sonar"));
@@ -478,7 +478,7 @@ public class ComponentAppActionTest {
   private void addComponent() {
     ComponentDto file = new ComponentDto().setId(10L).setQualifier("FIL").setKey(COMPONENT_KEY).setName("Plugin.java")
       .setLongName("src/main/java/org/sonar/api/Plugin.java")
-      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(5L).setProjectId(1L);
+      .setPath("src/main/java/org/sonar/api/Plugin.java").setSubProjectId(5L).setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, COMPONENT_KEY)).thenReturn(file);
     when(componentDao.getById(5L, session)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY));
     when(componentDao.getById(1L, session)).thenReturn(new ComponentDto().setId(1L).setLongName("SonarQube").setKey("org.codehaus.sonar:sonar"));
index 287a40b24723022125b59ee2c5363f04409cbf93..7d42df08e51655555c7f06e1306d3b0f067e3450 100644 (file)
@@ -60,9 +60,9 @@ public class DuplicationsJsonWriterTest {
   @Test
   public void write_duplications() throws Exception {
     String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
-    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId(1L).setSubProjectId(5L);
+    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId_unit_test_only(1L).setSubProjectId(5L);
     String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
-    ComponentDto file2 = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setProjectId(1L).setSubProjectId(5L);
+    ComponentDto file2 = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setProjectId_unit_test_only(1L).setSubProjectId(5L);
 
     when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
     when(componentDao.getNullableByKey(session, key2)).thenReturn(file2);
@@ -119,9 +119,9 @@ public class DuplicationsJsonWriterTest {
   @Test
   public void write_duplications_without_sub_project() throws Exception {
     String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
-    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId(1L);
+    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId_unit_test_only(1L);
     String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
-    ComponentDto file2 = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setProjectId(1L);
+    ComponentDto file2 = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setProjectId_unit_test_only(1L);
 
     when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
     when(componentDao.getNullableByKey(session, key2)).thenReturn(file2);
@@ -168,7 +168,7 @@ public class DuplicationsJsonWriterTest {
   @Test
   public void write_duplications_with_a_removed_component() throws Exception {
     String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
-    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId(1L);
+    ComponentDto file1 = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("PropertyDeleteQuery").setProjectId_unit_test_only(1L);
 
     when(componentDao.getNullableByKey(session, key1)).thenReturn(file1);
     when(componentDao.getNullableById(1L, session)).thenReturn(new ComponentDto().setId(1L).setKey("org.codehaus.sonar:sonar").setLongName("SonarQube"));
index aa31f8dec1203c1d4420969089e9fa4322709643..3035478ad517a54069f907aa3148b5f304d9f5e3 100644 (file)
@@ -62,17 +62,17 @@ public class DuplicationsParserTest {
   public void setUp() throws Exception {
     // Current file
     String key1 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java";
-    currentFile = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("CommandExecutor").setProjectId(1L);
+    currentFile = new ComponentDto().setId(10L).setQualifier("FIL").setKey(key1).setLongName("CommandExecutor").setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, key1)).thenReturn(currentFile);
 
     // File on same project
     String key2 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
-    fileOnSameProject = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("CommandExecutor").setProjectId(1L);
+    fileOnSameProject = new ComponentDto().setId(11L).setQualifier("FIL").setKey(key2).setLongName("CommandExecutor").setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, key2)).thenReturn(fileOnSameProject);
 
     // File on different project
     String key3 = "com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
-    fileOnDifferentProject = new ComponentDto().setId(12L).setQualifier("FIL").setKey(key3).setLongName("CommandExecutor").setProjectId(2L);
+    fileOnDifferentProject = new ComponentDto().setId(12L).setQualifier("FIL").setKey(key3).setLongName("CommandExecutor").setProjectId_unit_test_only(2L);
     when(componentDao.getNullableByKey(session, key3)).thenReturn(fileOnDifferentProject);
 
     parser = new DuplicationsParser(componentDao);
@@ -187,9 +187,9 @@ public class DuplicationsParserTest {
 
   @Test
   public void compare_duplications() throws Exception {
-    ComponentDto currentFile = new ComponentDto().setId(11L).setProjectId(1L);
-    ComponentDto fileOnSameProject = new ComponentDto().setId(12L).setProjectId(1L);
-    ComponentDto fileOnDifferentProject = new ComponentDto().setId(13L).setProjectId(2L);
+    ComponentDto currentFile = new ComponentDto().setId(11L).setProjectId_unit_test_only(1L);
+    ComponentDto fileOnSameProject = new ComponentDto().setId(12L).setProjectId_unit_test_only(1L);
+    ComponentDto fileOnDifferentProject = new ComponentDto().setId(13L).setProjectId_unit_test_only(2L);
 
     DuplicationsParser.DuplicationComparator comparator = new DuplicationsParser.DuplicationComparator(currentFile);
 
@@ -203,7 +203,7 @@ public class DuplicationsParserTest {
     assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(1);
     // Files on 2 different projects
     assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2),
-      new DuplicationsParser.Duplication(new ComponentDto().setId(30L).setProjectId(3L), 2, 2))).isEqualTo(1);
+      new DuplicationsParser.Duplication(new ComponentDto().setId(30L).setProjectId_unit_test_only(3L), 2, 2))).isEqualTo(1);
 
     // With null duplications
     assertThat(comparator.compare(null, new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(-1);
index 61b368122734a7aa659844969eb12d6c900354ce..9e0320fbdf588bc025e6ee5ef5403276dd82b1e5 100644 (file)
@@ -101,7 +101,6 @@ public class DefaultIssueServiceMediumTest {
     tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(project));
 
     file = new ComponentDto()
-      .setProjectId(project.getId())
       .setSubProjectId(project.getId())
       .setKey("MyComponent")
       .setLongName("My Component");
index 214a811d881d59e8ad15358a61f7379641a71302..a20de2e44eb6f39470bb34bfadd9fd40dc5b3214 100644 (file)
@@ -95,7 +95,6 @@ public class IssueBulkChangeServiceMediumTest {
     tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(project));
 
     file = new ComponentDto()
-      .setProjectId(project.getId())
       .setSubProjectId(project.getId())
       .setKey("MyComponent")
       .setLongName("My Component");
index 5e91277fd420ea34e62c637c7147bb9e466f06a4..afc86cc1724883b2eb614db6d809200367fea6df 100644 (file)
@@ -96,7 +96,7 @@ public class IssueBulkChangeServiceTest {
 
     file = new ComponentDto()
       .setId(2L)
-      .setProjectId(project.getId())
+      .setProjectId_unit_test_only(project.getId())
       .setSubProjectId(project.getId())
       .setKey("MyComponent")
       .setLongName("My Component");
index 0f01ef1b934b006488a398b1932443d31ac0bc5a..5305b0f128c8a8b6c1541b612f0633fd2c6a7757 100644 (file)
@@ -81,8 +81,7 @@ public class IssueBackendMediumTest {
 
     ComponentDto project = new ComponentDto()
       .setId(1L)
-      .setKey("MyProject")
-      .setProjectId(1L);
+      .setKey("MyProject");
     tester.get(ComponentDao.class).insert(dbSession, project);
 
     // project can be seen by anyone
@@ -90,7 +89,6 @@ public class IssueBackendMediumTest {
     dbClient.issueAuthorizationDao().synchronizeAfter(dbSession, new Date(0));
 
     ComponentDto resource = new ComponentDto()
-      .setProjectId(1L)
       .setKey("MyComponent")
       .setId(2L);
     tester.get(ComponentDao.class).insert(dbSession, resource);
@@ -145,13 +143,13 @@ public class IssueBackendMediumTest {
     ComponentDto project = new ComponentDto()
       .setId(1L)
       .setKey("MyProject")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     tester.get(ComponentDao.class).insert(dbSession, project);
 
     ComponentDto resource = new ComponentDto()
       .setId(2L)
       .setKey("MyComponent")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     tester.get(ComponentDao.class).insert(dbSession, resource);
 
     IssueDto issue = new IssueDto().setId(1L)
index 6d9942bbbc71eb6952e868ad0c19dd5a7b30dc46..6e7d90830e106c9cc4908fbaf823c330ae1be542 100644 (file)
@@ -68,7 +68,6 @@ public class IssueAuthorizationIndexMediumTest {
   public void synchronize() throws Exception {
     project = new ComponentDto()
       .setKey("Sample")
-      .setProjectId(1L)
       .setAuthorizationUpdatedAt(DateUtils.parseDate("2014-09-11"));
     db.componentDao().insert(session, project);
 
@@ -104,7 +103,6 @@ public class IssueAuthorizationIndexMediumTest {
   public void delete_index() throws Exception {
     project = new ComponentDto()
       .setKey("Sample")
-      .setProjectId(1L)
       .setAuthorizationUpdatedAt(DateUtils.parseDate("2014-09-11"));
     db.componentDao().insert(session, project);
 
index 8b5e6ed768e8d914949641aee7b4df7c69c80c8c..736b863c02b8d17146644849fe1759f0deee0a0c 100644 (file)
@@ -85,11 +85,11 @@ public class IssueIndexMediumTest {
     project = new ComponentDto()
       .setId(1L)
       .setKey("MyProject")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     tester.get(ComponentDao.class).insert(session, project);
 
     resource = new ComponentDto()
-      .setProjectId(1L)
+      .setProjectId_unit_test_only(1L)
       .setKey("MyComponent")
       .setId(2L);
     tester.get(ComponentDao.class).insert(session, resource);
index 9325f7745c350eac3b7a6c330a2879cde470d2eb..31903c546da22f0d5d6b14c81d38429c11790976 100644 (file)
@@ -267,7 +267,7 @@ public class IssueSearchActionTest {
       .setQualifier("FIL")
       .setPath("src/main/xoo/sample/Sample.xoo")
       .setSubProjectId(7L)
-      .setProjectId(7L);
+      .setProjectId_unit_test_only(7L);
 
     ComponentDto project = new ComponentDto()
       .setId(7L)
@@ -275,7 +275,7 @@ public class IssueSearchActionTest {
       .setLongName("Sample")
       .setName("Sample")
       .setQualifier("TRK")
-      .setProjectId(7L);
+      .setProjectId_unit_test_only(7L);
 
     result.addComponents(Lists.<Component>newArrayList(component, project));
     result.addProjects(Lists.<Component>newArrayList(project));
@@ -298,7 +298,7 @@ public class IssueSearchActionTest {
       .setQualifier("FIL")
       .setPath("src/main/xoo/sample/Sample.xoo")
       .setSubProjectId(8L)
-      .setProjectId(7L);
+      .setProjectId_unit_test_only(7L);
 
     // Sub project
     ComponentDto subProject = new ComponentDto()
@@ -308,7 +308,7 @@ public class IssueSearchActionTest {
       .setName("Sample Project :: Sample Module")
       .setQualifier("BRC")
       .setSubProjectId(7L)
-      .setProjectId(7L);
+      .setProjectId_unit_test_only(7L);
 
     // Project
     ComponentDto project = new ComponentDto()
@@ -317,7 +317,7 @@ public class IssueSearchActionTest {
       .setLongName("Sample Project")
       .setName("Sample Project")
       .setQualifier("TRK")
-      .setProjectId(7L);
+      .setProjectId_unit_test_only(7L);
 
     result.addComponents(Lists.<Component>newArrayList(component, subProject, project));
     result.addProjects(Lists.<Component>newArrayList(project));
index 3379d6eaaf7e7816b0254896885c22009f5528d8..f28328410ee3e5f859ac6b13ac4acecae377b089 100644 (file)
@@ -161,7 +161,7 @@ public class IssueShowActionTest {
       .setName("SonarQube :: Issue Client")
       .setQualifier("FIL")
       .setSubProjectId(1L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, file.key())).thenReturn(file);
 
     ComponentDto project = new ComponentDto()
@@ -169,7 +169,7 @@ public class IssueShowActionTest {
       .setKey("org.sonar.Sonar")
       .setLongName("SonarQube")
       .setName("SonarQube")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableById(file.projectId(), session)).thenReturn(project);
 
     MockUserSession.set();
@@ -200,7 +200,7 @@ public class IssueShowActionTest {
       .setLongName("SonarQube :: Issue Client")
       .setQualifier("FIL")
       .setSubProjectId(2L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, file.key())).thenReturn(file);
 
     // Module
@@ -210,7 +210,7 @@ public class IssueShowActionTest {
       .setLongName("SonarQube :: Server")
       .setQualifier("BRC")
       .setSubProjectId(1L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableById(file.subProjectId(), session)).thenReturn(module);
 
     // Project
@@ -249,7 +249,7 @@ public class IssueShowActionTest {
       .setLongName("SonarQube :: Issue Client")
       .setQualifier("FIL")
       .setSubProjectId(2L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, file.key())).thenReturn(file);
 
     // Module
@@ -259,7 +259,7 @@ public class IssueShowActionTest {
       .setName("SonarQube :: Server")
       .setQualifier("BRC")
       .setSubProjectId(1L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableById(file.subProjectId(), session)).thenReturn(module);
 
     // Project
@@ -506,7 +506,7 @@ public class IssueShowActionTest {
       .setName("SonarQube :: Issue Client")
       .setQualifier("FIL")
       .setSubProjectId(1L)
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableByKey(session, file.key())).thenReturn(file);
 
     ComponentDto project = new ComponentDto()
@@ -514,7 +514,7 @@ public class IssueShowActionTest {
       .setKey("org.sonar.Sonar")
       .setLongName("SonarQube")
       .setName("SonarQube")
-      .setProjectId(1L);
+      .setProjectId_unit_test_only(1L);
     when(componentDao.getNullableById(file.projectId(), session)).thenReturn(project);
   }
 
index 0ac268f91e892e2241cf73b508a596fd1a781460..4a6a88f975eeaf77bac1d420caecedfc2419e5ae 100644 (file)
@@ -68,7 +68,7 @@ public class InternalPermissionServiceMediumTest {
     user = new UserDto().setLogin("john").setName("John");
     db.userDao().insert(session, user);
 
-    project = new ComponentDto().setKey("Sample").setProjectId(1L);
+    project = new ComponentDto().setKey("Sample").setProjectId_unit_test_only(1L);
     db.componentDao().insert(session, project);
 
     session.commit();
index c2033a56c79b9ad597fc7dadf10257141225d43e..f13242558376874ba885e9335e7b19fac8c7c916 100644 (file)
@@ -81,7 +81,7 @@ public class BackendCleanupMediumTest {
     db.snapshotDao().insert(session, SnapshotTesting.createForComponent(project));
 
     file = new ComponentDto()
-      .setProjectId(project.getId())
+      .setProjectId_unit_test_only(project.getId())
       .setKey("MyComponent");
     tester.get(ComponentDao.class).insert(session, file);
     db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file));
index fb22bf18d913cecd5b1b01e981c4441cf6e8b7c1..756824740a1d1f692449ff225a9043244d990fab 100644 (file)
@@ -104,7 +104,10 @@ public class ComponentDto extends AuthorizedComponentDto implements Component {
     return projectId;
   }
 
-  public ComponentDto setProjectId(Long projectId) {
+  /**
+   * Only for unit tests
+   */
+  public ComponentDto setProjectId_unit_test_only(Long projectId) {
     this.projectId = projectId;
     return this;
   }
index 7341139e2e186f3e67e1bf70e998d9aa99bde649..d3bce1f946f7ac6e156b2146ee05827fd707412e 100644 (file)
@@ -38,7 +38,7 @@ public class ComponentDtoTest {
       .setScope("FIL")
       .setLanguage("java")
       .setPath("src/org/struts/RequestContext.java")
-      .setProjectId(2L)
+      .setProjectId_unit_test_only(2L)
       .setSubProjectId(3L)
       .setAuthorizationUpdatedAt(DateUtils.parseDate("2014-09-11"));