]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6014 Remove dependency on project ID.
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 8 Jan 2015 09:05:16 +0000 (10:05 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 8 Jan 2015 09:08:27 +0000 (10:08 +0100)
sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java

index f5045866558dabd27ac59eef79ca1e9c581a14fc..6baa999b22f756673bb64bf08cf118df75e32bea 100644 (file)
@@ -74,7 +74,7 @@ public class TimeMachineConfiguration implements BatchExtension {
   private Snapshot findSnapshot(Snapshot projectSnapshot) {
     String hql = "from " + Snapshot.class.getSimpleName() + " where resourceId=:resourceId and (rootId=:rootSnapshotId or id=:rootSnapshotId)";
     List<Snapshot> snapshots = session.createQuery(hql)
-      .setParameter("resourceId", project.getId())
+      .setParameter("resourceId", projectSnapshot.getResourceId())
       .setParameter("rootSnapshotId", projectSnapshot.getId())
       .setMaxResults(1)
       .getResultList();
index 7e61880fffc89dac6e3fdc1cc26e72802bcfa496..8af5c78517fa5335be1e87b3c26a498189b86023 100644 (file)
@@ -46,11 +46,12 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase {
   public void get_project_past_snapshot() {
     Snapshot projectSnapshot = new Snapshot();
     projectSnapshot.setId(1010);
+    projectSnapshot.setResourceId(1);
     PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);
 
     when(periodsDefinition.getRootProjectPastSnapshots()).thenReturn(newArrayList(projectPastSnapshot));
 
-    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:project").setId(1), periodsDefinition);
+    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:project"), periodsDefinition);
     assertThat(timeMachineConfiguration.periods()).hasSize(1);
     assertThat(timeMachineConfiguration.periods().get(0).getDate()).isNotNull();
     assertThat(timeMachineConfiguration.getProjectPastSnapshots()).hasSize(1);
@@ -61,11 +62,12 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase {
   public void get_module_past_snapshot() {
     Snapshot projectSnapshot = new Snapshot();
     projectSnapshot.setId(1010);
+    projectSnapshot.setResourceId(2);
     PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);
 
     when(periodsDefinition.getRootProjectPastSnapshots()).thenReturn(newArrayList(projectPastSnapshot));
 
-    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:module").setId(2), periodsDefinition);
+    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:module"), periodsDefinition);
     assertThat(timeMachineConfiguration.periods()).hasSize(1);
     assertThat(timeMachineConfiguration.periods().get(0).getDate()).isNotNull();
     assertThat(timeMachineConfiguration.getProjectPastSnapshots()).hasSize(1);