]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10134 Fix unit tests not having default QG on organization
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 12 Dec 2017 10:42:36 +0000 (11:42 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 14 Dec 2017 16:03:35 +0000 (17:03 +0100)
15 files changed:
server/sonar-db-dao/src/test/java/org/sonar/db/organization/OrganizationDaoTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/DefaultOrganizationProviderImplTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/empty.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/no_previous_version.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_deleted.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_is_last_one.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/shared.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/unprocessed_snapshots.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml

index c6bfeb8e232498dcf1f681544efe373a6e33d693..56becd292b128d473238b1d3eecf029311c8d062 100644 (file)
@@ -55,6 +55,7 @@ import static org.mockito.Mockito.when;
 import static org.sonar.db.Pagination.forPage;
 import static org.sonar.db.organization.OrganizationQuery.newOrganizationQueryBuilder;
 import static org.sonar.db.organization.OrganizationQuery.returnAll;
+import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 
 public class OrganizationDaoTest {
   private static final long SOME_DATE = 1_200_999L;
@@ -729,7 +730,7 @@ public class OrganizationDaoTest {
     insertOrganization(ORGANIZATION_DTO_1);
 
     when(system2.now()).thenReturn(DATE_3);
-    underTest.update(dbSession, new OrganizationDto()
+    underTest.update(dbSession, newOrganizationDto()
       .setUuid(ORGANIZATION_DTO_1.getUuid())
       .setKey("new key")
       .setName("new name")
index 9a1a708bc6e8544fcb2d45da5d63fa9fd17f7dcc..0d2026edc71b5b5ba100caa53e8738c3eb485855 100644 (file)
@@ -32,12 +32,14 @@ import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.SnapshotDto;
+import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.ConfigurationRepository;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
 import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
-import org.sonar.server.computation.task.projectanalysis.component.ViewsComponent;
 import org.sonar.server.computation.task.projectanalysis.period.Period;
 import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderImpl;
 import org.sonar.server.computation.task.step.ComputationStep;
@@ -49,14 +51,14 @@ import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAT
 import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
 import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
 import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
+import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED;
+import static org.sonar.db.event.EventDto.CATEGORY_VERSION;
+import static org.sonar.db.event.EventTesting.newEvent;
 
 @RunWith(DataProviderRunner.class)
 public class LoadPeriodsStepTest extends BaseStepTest {
 
   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
-  private static final String ROOT_KEY = "ROOT_KEY";
-  private static final ReportComponent PROJECT_ROOT = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(ROOT_KEY).setVersion("1.1").build();
-  private static final ViewsComponent VIEW_ROOT = ViewsComponent.builder(Component.Type.VIEW, ROOT_KEY).setUuid("ABCD").build();
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -86,14 +88,9 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     analysisMetadataHolder.setAnalysisDate(DATE_FORMAT.parse("2008-11-30").getTime());
   }
 
-  private void setupRoot(Component root) {
-    treeRootHolder.setRoot(root);
-    when(settingsRepository.getConfiguration()).thenReturn(settings.asConfig());
-  }
-
   @Test
   public void no_period_on_first_analysis() {
-    setupRoot(PROJECT_ROOT);
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setKey("ROOT_KEY").setVersion("1.1").build());
 
     // No project, no snapshot
     underTest.execute();
@@ -103,27 +100,31 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_one_period() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L)); // 2008-11-29
+    setupRoot(project);
     String textDate = "2008-11-22";
-    settings.setProperty("sonar.leak.period", textDate);
 
+    settings.setProperty("sonar.leak.period", textDate);
     underTest.execute();
 
     Period period = periodsHolder.getPeriod();
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
     assertThat(period.getModeParameter()).isEqualTo(textDate);
-    assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis.getUuid());
   }
 
   @Test
   public void no_period_when_settings_match_no_analysis() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "UNKNWOWN VERSION");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L)); // 2008-11-29
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "UNKNWOWN VERSION");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -131,10 +132,12 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void no_period_when_settings_is_empty() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L)); // 2008-11-29
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -142,10 +145,12 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void ignore_unprocessed_snapshots() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "unprocessed_snapshots.xml");
-    settings.setProperty("sonar.leak.period", "100");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    dbTester.components().insertSnapshot(project, snapshot -> snapshot.setStatus(STATUS_UNPROCESSED).setCreatedAt(1226379600000L)); // 2008-11-29
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "100");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -153,11 +158,17 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_period_by_date() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setLast(false)); // 2008-11-20
+    SnapshotDto analysis4 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227358680000L).setLast(false)); // 2008-11-22
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setLast(true)); // 2008-11-29
+    setupRoot(project);
+
     String textDate = "2008-11-22";
     settings.setProperty("sonar.leak.period", textDate);
-
     underTest.execute();
 
     // Return analysis from given date 2008-11-22
@@ -165,8 +176,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
     assertThat(period.getModeParameter()).isEqualTo(textDate);
-    assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis4.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis4.getUuid());
 
     assertThat(logTester.logs()).hasSize(1);
     assertThat(logTester.logs().get(0)).startsWith("Compare to date 2008-11-22 (analysis of ");
@@ -174,29 +185,37 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void search_by_date_return_nearest_later_analysis() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    String date = "2008-11-24";
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setLast(false)); // 2008-11-20
+    SnapshotDto analysis4 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227358680000L).setLast(false)); // 2008-11-22
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setLast(true)); // 2008-11-29
+    setupRoot(project);
+
+    String date = "2008-11-13";
     settings.setProperty("sonar.leak.period", date);
-
     underTest.execute();
 
-    // Analysis form 2008-11-29
+    // Analysis form 2008-11-20
     Period period = periodsHolder.getPeriod();
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
     assertThat(period.getModeParameter()).isEqualTo(date);
-    assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1004");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis3.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis3.getUuid());
   }
 
   @Test
   public void no_period_by_date() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L)); // 2008-11-29
+    setupRoot(project);
+
     // No analysis at and after this date
     settings.setProperty("sonar.leak.period", "2008-11-30");
-
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -204,10 +223,16 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_period_by_days() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "10");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setLast(false)); // 2008-11-20
+    SnapshotDto analysis4 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227358680000L).setLast(false)); // 2008-11-22
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setLast(true)); // 2008-11-29
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "10");
     underTest.execute();
 
     // return analysis from 2008-11-20
@@ -215,8 +240,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DAYS);
     assertThat(period.getModeParameter()).isEqualTo("10");
-    assertThat(period.getSnapshotDate()).isEqualTo(1227157200000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1002");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis3.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis3.getUuid());
 
     assertThat(logTester.logs()).hasSize(1);
     assertThat(logTester.logs().get(0)).startsWith("Compare over 10 days (2008-11-20, analysis of ");
@@ -224,10 +249,11 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void no_period_by_days() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "empty.xml");
-    settings.setProperty("sonar.leak.period", "0");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "0");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -235,10 +261,19 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_period_by_previous_version() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setVersion("0.9").setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setVersion("1.0").setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setVersion("1.1").setLast(false)); // 2008-11-20
+    SnapshotDto analysis4 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227358680000L).setVersion("1.1").setLast(false)); // 2008-11-22
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setVersion("1.1").setLast(true)); // 2008-11-29
+    dbTester.events().insertEvent(newEvent(analysis1).setName("0.9").setCategory(CATEGORY_VERSION).setDate(analysis1.getCreatedAt()));
+    dbTester.events().insertEvent(newEvent(analysis2).setName("1.0").setCategory(CATEGORY_VERSION).setDate(analysis2.getCreatedAt()));
+    dbTester.events().insertEvent(newEvent(analysis5).setName("1.1").setCategory(CATEGORY_VERSION).setDate(analysis4.getCreatedAt()));
+    setupRoot(project, "1.1");
 
+    settings.setProperty("sonar.leak.period", "previous_version");
     underTest.execute();
 
     // Analysis form 2008-11-12
@@ -246,8 +281,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
     assertThat(period.getModeParameter()).isEqualTo("1.0");
-    assertThat(period.getSnapshotDate()).isEqualTo(1226494680000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1001");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis2.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis2.getUuid());
 
     assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1);
     assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).startsWith("Compare to previous version (");
@@ -255,10 +290,17 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_period_by_previous_version_with_previous_version_deleted() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "previous_version_deleted.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setVersion("0.9").setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setVersion("1.0").setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setVersion("1.1").setLast(false)); // 2008-11-20
+    dbTester.events().insertEvent(newEvent(analysis1).setName("0.9").setCategory(CATEGORY_VERSION));
+    // The "1.0" version was deleted from the history
+    dbTester.events().insertEvent(newEvent(analysis3).setName("1.1").setCategory(CATEGORY_VERSION));
+    setupRoot(project, "1.1");
 
+    settings.setProperty("sonar.leak.period", "previous_version");
     underTest.execute();
 
     // Analysis form 2008-11-11
@@ -266,16 +308,17 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
     assertThat(period.getModeParameter()).isEqualTo("0.9");
-    assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis1.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis1.getUuid());
   }
 
   @Test
   public void no_period_by_previous_version() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "empty.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "previous_version");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
@@ -283,65 +326,90 @@ public class LoadPeriodsStepTest extends BaseStepTest {
 
   @Test
   public void feed_period_by_previous_version_with_first_analysis_when_no_previous_version_found() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "no_previous_version.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setVersion("0.9").setLast(false)); // 2008-11-11
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setVersion("1.1").setLast(true)); // 2008-11-29
+    dbTester.events().insertEvent(newEvent(analysis5).setName("1.1").setCategory(CATEGORY_VERSION));
+    setupRoot(project, "1.1");
 
+    settings.setProperty("sonar.leak.period", "previous_version");
     underTest.execute();
 
     Period period = periodsHolder.getPeriod();
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
     assertThat(period.getModeParameter()).isNull();
-    assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis1.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis1.getUuid());
   }
 
   @Test
   public void feed_period_by_previous_version_with_first_analysis_when_previous_snapshot_is_the_last_one() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "previous_version_is_last_one.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setVersion("0.9").setLast(true)); // 2008-11-11
+    setupRoot(project, "1.1");
 
+    settings.setProperty("sonar.leak.period", "previous_version");
     underTest.execute();
 
     Period period = periodsHolder.getPeriod();
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
     assertThat(period.getModeParameter()).isNull();
-    assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis.getUuid());
   }
 
   @Test
   public void feed_period_by_version() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "0.9");
-
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setVersion("0.9").setLast(false)); // 2008-11-11
+    SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setVersion("1.0").setLast(false)); // 2008-11-12
+    SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setVersion("1.1").setLast(false)); // 2008-11-20
+    SnapshotDto analysis4 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227358680000L).setVersion("1.1").setLast(false)); // 2008-11-22
+    SnapshotDto analysis5 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227934800000L).setVersion("1.1").setLast(true)); // 2008-11-29
+    dbTester.events().insertEvent(newEvent(analysis1).setName("0.9").setCategory(CATEGORY_VERSION));
+    dbTester.events().insertEvent(newEvent(analysis2).setName("1.0").setCategory(CATEGORY_VERSION));
+    dbTester.events().insertEvent(newEvent(analysis5).setName("1.1").setCategory(CATEGORY_VERSION));
+    setupRoot(project, "1.1");
+
+    settings.setProperty("sonar.leak.period", "1.0");
     underTest.execute();
 
     // Analysis form 2008-11-11
     Period period = periodsHolder.getPeriod();
     assertThat(period).isNotNull();
     assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_VERSION);
-    assertThat(period.getModeParameter()).isEqualTo("0.9");
-    assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
-    assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
+    assertThat(period.getModeParameter()).isEqualTo("1.0");
+    assertThat(period.getSnapshotDate()).isEqualTo(analysis2.getCreatedAt());
+    assertThat(period.getAnalysisUuid()).isEqualTo(analysis2.getUuid());
 
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs().get(0)).startsWith("Compare to version (0.9) (");
+    assertThat(logTester.logs().get(0)).startsWith("Compare to version (1.0) (");
   }
 
   @Test
   public void no_period_by_version() {
-    setupRoot(PROJECT_ROOT);
-    dbTester.prepareDbUnit(getClass(), "empty.xml");
-    settings.setProperty("sonar.leak.period", "0.8");
+    OrganizationDto organization = dbTester.organizations().insert();
+    ComponentDto project = dbTester.components().insertPrivateProject(organization);
+    setupRoot(project);
 
+    settings.setProperty("sonar.leak.period", "0.8");
     underTest.execute();
 
     assertThat(periodsHolder.getPeriod()).isNull();
   }
 
+  private void setupRoot(ComponentDto project) {
+    setupRoot(project, "1.1");
+  }
+
+  private void setupRoot(ComponentDto project, String version) {
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(project.uuid()).setKey(project.getKey()).setVersion(version).build());
+    when(settingsRepository.getConfiguration()).thenReturn(settings.asConfig());
+  }
+
 }
index 09a22653625c6082cf0f292b88f9fa8fb8fe7110..ed00038c2aa17bb78cc9b9da040c1d93b538f826 100644 (file)
@@ -32,10 +32,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 import static org.sonar.server.property.InternalProperties.DEFAULT_ORGANIZATION;
 
 public class DefaultOrganizationProviderImplTest {
-  private static final OrganizationDto ORGANIZATION_DTO_1 = new OrganizationDto()
+  private static final OrganizationDto ORGANIZATION_DTO_1 = newOrganizationDto()
     .setUuid("uuid1")
     .setName("the name of 1")
     .setKey("the key 1");
index bc64b63b1e92d5f7fd6bc3ecb4b0347e2d9c95ab..66b766cad919f82151986497e816162496029447 100644 (file)
@@ -352,7 +352,7 @@ public class CreateActionTest {
   @Test
   public void request_fails_if_key_is_specified_and_already_exists_in_DB() {
     logInAsSystemAdministrator();
-    OrganizationDto org = insertOrganization("the-key");
+    OrganizationDto org = dbTester.organizations().insert(o -> o.setKey("the-key"));
 
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("Key '" + org.getKey() + "' is already used. Specify another one.");
@@ -364,7 +364,7 @@ public class CreateActionTest {
   public void request_fails_if_key_computed_from_name_already_exists_in_DB() {
     logInAsSystemAdministrator();
     String key = STRING_65_CHARS_LONG.substring(0, 32);
-    insertOrganization(key);
+    dbTester.organizations().insert(o -> o.setKey(key));
 
     String name = STRING_65_CHARS_LONG.substring(0, 64);
 
@@ -662,18 +662,6 @@ public class CreateActionTest {
     assertThat(dto.getUpdatedAt()).isEqualTo(createdAt);
   }
 
-  private OrganizationDto insertOrganization(String key) {
-    OrganizationDto dto = new OrganizationDto()
-      .setUuid(key + "_uuid")
-      .setKey(key)
-      .setName(key + "_name")
-      .setCreatedAt((long) key.hashCode())
-      .setUpdatedAt((long) key.hashCode());
-    dbClient.organizationDao().insert(dbTester.getSession(), dto, false);
-    dbTester.commit();
-    return dto;
-  }
-
   private void logInAsSystemAdministrator() {
     userSession.logIn(user).setSystemAdministrator();
   }
index 8eedbae42ecab9e46f9dc88af10057e0cf072f8c..587b43afec69761fb276f8525a181e7fc017170e 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.server.organization.ws;
 
 import com.google.common.base.Joiner;
-import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
@@ -55,15 +53,7 @@ import static org.sonar.server.organization.ws.SearchAction.PARAM_MEMBER;
 import static org.sonar.test.JsonAssert.assertJson;
 
 public class SearchActionTest {
-  private static final OrganizationDto ORGANIZATION_DTO = new OrganizationDto()
-    .setUuid("a uuid")
-    .setKey("the_key")
-    .setName("the name")
-    .setDescription("the description")
-    .setUrl("the url")
-    .setAvatarUrl("the avatar url")
-    .setCreatedAt(1_999_000L)
-    .setUpdatedAt(1_888_000L);
+
   private static final long SOME_DATE = 1_999_999L;
 
   private System2 system2 = mock(System2.class);
@@ -116,9 +106,9 @@ public class SearchActionTest {
   }
 
   @Test
-  public void json_example() throws URISyntaxException, IOException {
+  public void json_example() {
     when(system2.now()).thenReturn(SOME_DATE, SOME_DATE + 1000);
-    OrganizationDto barOrganization = db.organizations().insert(new OrganizationDto()
+    OrganizationDto barOrganization = db.organizations().insert(organization -> organization
       .setUuid(Uuids.UUID_EXAMPLE_02)
       .setKey("bar-company")
       .setName("Bar Company")
@@ -126,10 +116,13 @@ public class SearchActionTest {
       .setUrl("https://www.bar.com")
       .setAvatarUrl("https://www.bar.com/logo.png")
       .setGuarded(false));
-    OrganizationDto fooOrganization = db.organizations().insert(new OrganizationDto()
+    OrganizationDto fooOrganization = db.organizations().insert(organization -> organization
       .setUuid(Uuids.UUID_EXAMPLE_01)
       .setKey("foo-company")
       .setName("Foo Company")
+      .setDescription(null)
+      .setUrl(null)
+      .setAvatarUrl(null)
       .setGuarded(true));
     UserDto user = db.users().insertUser();
     db.organizations().addMember(barOrganization, user);
@@ -179,7 +172,7 @@ public class SearchActionTest {
   @Test
   public void request_returns_empty_on_table_with_single_row_when_not_requesting_the_first_page() {
     when(system2.now()).thenReturn(SOME_DATE);
-    db.organizations().insert(ORGANIZATION_DTO);
+    db.organizations().insert();
 
     assertThat(executeRequestAndReturnList(2, null)).isEmpty();
     assertThat(executeRequestAndReturnList(2, 1)).isEmpty();
@@ -191,11 +184,11 @@ public class SearchActionTest {
   @Test
   public void request_returns_rows_ordered_by_createdAt_descending_applying_requested_paging() {
     when(system2.now()).thenReturn(SOME_DATE, SOME_DATE + 1_000, SOME_DATE + 2_000, SOME_DATE + 3_000, SOME_DATE + 5_000);
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid3").setKey("key-3"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid1").setKey("key-1"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid2").setKey("key-2"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid5").setKey("key-5"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid4").setKey("key-4"));
+    db.organizations().insert(organization -> organization.setKey("key-3"));
+    db.organizations().insert(organization -> organization.setKey("key-1"));
+    db.organizations().insert(organization -> organization.setKey("key-2"));
+    db.organizations().insert(organization -> organization.setKey("key-5"));
+    db.organizations().insert(organization -> organization.setKey("key-4"));
 
     assertThat(executeRequestAndReturnList(1, 1))
       .extracting(Organization::getKey)
@@ -231,11 +224,11 @@ public class SearchActionTest {
   @Test
   public void request_returns_only_specified_keys_ordered_by_createdAt_when_filtering_keys() {
     when(system2.now()).thenReturn(SOME_DATE, SOME_DATE + 1_000, SOME_DATE + 2_000, SOME_DATE + 3_000, SOME_DATE + 5_000);
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid3").setKey("key-3"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid1").setKey("key-1"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid2").setKey("key-2"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid5").setKey("key-5"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid4").setKey("key-4"));
+    db.organizations().insert(organization -> organization.setKey("key-3"));
+    db.organizations().insert(organization -> organization.setKey("key-1"));
+    db.organizations().insert(organization -> organization.setKey("key-2"));
+    db.organizations().insert(organization -> organization.setKey("key-5"));
+    db.organizations().insert(organization -> organization.setKey("key-4"));
 
     assertThat(executeRequestAndReturnList(1, 10, "key-3", "key-1", "key-5"))
       .extracting(Organization::getKey)
@@ -249,11 +242,11 @@ public class SearchActionTest {
   @Test
   public void result_is_paginated() {
     when(system2.now()).thenReturn(SOME_DATE, SOME_DATE + 1_000, SOME_DATE + 2_000, SOME_DATE + 3_000, SOME_DATE + 5_000);
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid3").setKey("key-3"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid1").setKey("key-1"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid2").setKey("key-2"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid5").setKey("key-5"));
-    db.organizations().insert(ORGANIZATION_DTO.setUuid("uuid4").setKey("key-4"));
+    db.organizations().insert(organization -> organization.setKey("key-3"));
+    db.organizations().insert(organization -> organization.setKey("key-1"));
+    db.organizations().insert(organization -> organization.setKey("key-2"));
+    db.organizations().insert(organization -> organization.setKey("key-5"));
+    db.organizations().insert(organizationo -> organizationo.setKey("key-4"));
 
     SearchWsResponse response = call(1, 1, "key-1", "key-3", "key-5");
     assertThat(response.getOrganizationsList()).extracting(Organization::getKey).containsOnly("key-5");
@@ -275,11 +268,11 @@ public class SearchActionTest {
   @Test
   public void request_returns_empty_when_filtering_on_non_existing_key() {
     when(system2.now()).thenReturn(SOME_DATE);
-    db.organizations().insert(ORGANIZATION_DTO);
+    OrganizationDto organization = db.organizations().insert();
 
-    assertThat(executeRequestAndReturnList(1, 10, ORGANIZATION_DTO.getKey()))
+    assertThat(executeRequestAndReturnList(1, 10, organization.getKey()))
       .extracting(Organization::getKey)
-      .containsExactly(ORGANIZATION_DTO.getKey());
+      .containsExactly(organization.getKey());
   }
 
   @Test
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/empty.xml
deleted file mode 100644 (file)
index 98fb91c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <projects organization_uuid="org1"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            id="1"
-            root_uuid="ABCD"
-            project_uuid="ABCD"
-            kee="ROOT_KEY"
-            private="[false]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/no_previous_version.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/no_previous_version.xml
deleted file mode 100644 (file)
index eb9da82..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-<dataset>
-
-  <organizations uuid="org1"
-                 kee="org1_key"
-                 name="org1_name"
-                 guarded="[false]"
-                 new_project_private="[false]"
-                 created_at="1000"
-                 updated_at="2000"/>
-
-  <projects organization_uuid="org1"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            root_uuid="ABCD"
-            project_uuid="ABCD"
-            id="1"
-            kee="ROOT_KEY"
-            name="project"
-            private="[false]"/>
-
-  <!-- 2008-11-11 -->
-  <!-- Version 0.9 -->
-  <snapshots id="1000"
-             uuid="u1000"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226379600000"
-             build_date="1226379600000"
-             version="0.9"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-12 -->
-  <!-- Version 1.0 -->
-  <snapshots id="1001"
-             uuid="u1001"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226494680000"
-             build_date="1226494680000"
-             version="1.0"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-20 -->
-  <!-- First version 1.1 -->
-  <snapshots id="1002"
-             uuid="u1002"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227157200000"
-             build_date="1227157200000"
-             version="1.1"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-22 -->
-  <snapshots id="1003"
-             uuid="u1003"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227358680000"
-             build_date="1227358680000"
-             version="1.1"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-29 -->
-  <!-- Last version 1.1 -->
-  <snapshots id="1004"
-             uuid="u1004"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227934800000"
-             build_date="1227934800000"
-             version="1.1"
-             status="P"
-             islast="[true]"
-  />
-
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_deleted.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_deleted.xml
deleted file mode 100644 (file)
index d235e0a..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-<dataset>
-
-  <organizations uuid="org1"
-                 kee="org1_key"
-                 name="org1_name"
-                 guarded="[false]"
-                 new_project_private="[false]"
-                 created_at="1000"
-                 updated_at="2000"/>
-
-  <projects organization_uuid="org1"
-            id="1"
-            kee="ROOT_KEY"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            root_uuid="ABCD"
-            project_uuid="ABCD"
-            private="[false]"/>
-
-  <!-- 2008-11-11 -->
-  <!-- Version 0.9 -->
-  <snapshots id="1000"
-             uuid="u1000"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226379600000"
-             build_date="1226379600000"
-             version="0.9"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-12 -->
-  <!-- Version 1.0 -->
-  <snapshots id="1001"
-             uuid="u1001"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226494680000"
-             build_date="1226494680000"
-             version="1.0"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-20 -->
-  <!-- version 1.1 -->
-  <snapshots id="1002"
-             uuid="u1002"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227157200000"
-             build_date="1227157200000"
-             version="1.1"
-             status="P"
-             islast="[false]"
-  />
-
-
-  <events id="1"
-          uuid="P2"
-          analysis_uuid="u1000"
-          component_uuid="ABCD"
-          name="0.9"
-          category="Version"
-          event_date="1226379600000"
-          created_at="1226379600000"
-          description=""
-          event_data="[null]"/>
-  <!-- The "1.0" version was deleted from the history :  -->
-  <!--<events id="2" name="1.0" component_uuid="ABCD" snapshot_id="1001" category="Version" event_date="1226494680000" created_at="1226494680000" description="" event_data="[null]"/>-->
-  <events id="3"
-          uuid="P3"
-          analysis_uuid="u1004"
-          component_uuid="ABCD"
-          name="1.1"
-          category="Version"
-          event_date="1227934800000"
-          created_at="1227934800000"
-          description=""
-          event_data="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_is_last_one.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/previous_version_is_last_one.xml
deleted file mode 100644 (file)
index 010f700..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<dataset>
-
-  <organizations uuid="org1"
-                 kee="org1_key"
-                 name="org1_name"
-                 guarded="[false]"
-                 new_project_private="[false]"
-                 created_at="1000"
-                 updated_at="2000"/>
-
-  <projects organization_uuid="org1"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            root_uuid="ABCD"
-            project_uuid="ABCD"
-            id="1"
-            kee="ROOT_KEY"
-            name="project"
-            private="[false]"/>
-
-  <!-- 2008-11-11 -->
-  <!-- Version 0.9 -->
-  <snapshots id="1000"
-             uuid="u1000"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226379600000"
-             build_date="1226379600000"
-             version="0.9"
-             status="P"
-             islast="[true]"
-  />
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/shared.xml
deleted file mode 100644 (file)
index bbd500b..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-<dataset>
-
-  <organizations uuid="org1"
-                 kee="org1_key"
-                 name="org1_name"
-                 guarded="[false]"
-                 new_project_private="[false]"
-                 created_at="1000"
-                 updated_at="2000"/>
-
-  <projects organization_uuid="org1"
-            id="1"
-            kee="ROOT_KEY"
-            name="project"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            root_uuid="ABCD"
-            project_uuid="ABCD"
-            private="[false]"/>
-
-  <!-- 2008-11-11 -->
-  <!-- Version 0.9 -->
-  <snapshots id="1000"
-             uuid="u1000"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226379600000"
-             build_date="1226379600000"
-             version="0.9"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-12 -->
-  <!-- Version 1.0 -->
-  <snapshots id="1001"
-             uuid="u1001"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226494680000"
-             build_date="1226494680000"
-             version="1.0"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-20 -->
-  <!-- First version 1.1 -->
-  <snapshots id="1002"
-             uuid="u1002"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227157200000"
-             build_date="1227157200000"
-             version="1.1"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-22 -->
-  <snapshots id="1003"
-             uuid="u1003"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227358680000"
-             build_date="1227358680000"
-             version="1.1"
-             status="P"
-             islast="[false]"
-  />
-
-  <!-- 2008-11-29 -->
-  <!-- Last version 1.1 -->
-  <snapshots id="1004"
-             uuid="u1004"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1227934800000"
-             build_date="1227934800000"
-             version="1.1"
-             status="P"
-             islast="[true]"
-  />
-
-
-  <events id="1"
-          uuid="P1"
-          analysis_uuid="u1000"
-          component_uuid="ABCD"
-          name="0.9"
-          category="Version"
-          event_date="1226379600000"
-          created_at="1226379600000"
-          description=""
-          event_data="[null]"/>
-  <events id="2"
-          uuid="P2"
-          analysis_uuid="u1001"
-          component_uuid="ABCD"
-          name="1.0"
-          category="Version"
-          event_date="1226494680000"
-          created_at="1226494680000"
-          description=""
-          event_data="[null]"/>
-  <events id="3"
-          uuid="P3"
-          analysis_uuid="u1004"
-          component_uuid="ABCD"
-          name="1.1"
-          category="Version"
-          event_date="1227934800000"
-          created_at="1227934800000"
-          description=""
-          event_data="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/unprocessed_snapshots.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest/unprocessed_snapshots.xml
deleted file mode 100644 (file)
index fd783cd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<dataset>
-
-  <projects organization_uuid="org1"
-            uuid="ABCD"
-            uuid_path="NOT_USED"
-            project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path=".ABCD."
-            enabled="[true]"
-            language="java"
-            id="1"
-            root_uuid="ABCD"
-            scope="PRJ"
-            qualifier="TRK"
-            kee="PROJECT_KEY"
-            name="project"
-            long_name="[null]"
-            description="[null]"
-            private="[false]"/>
-
-  <!-- Unprocessed snapshot -->
-  <snapshots id="1000"
-             uuid="u1000"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             component_uuid="ABCD"
-             created_at="1226379600000"
-             build_date="1226379600000"
-             version="0.9"
-             status="U"
-             islast="[false]"
-  />
-
-</dataset>
index c235e1fc744c694a306e1300dc2837c314d734fe..222670b1485b142ceab674520363aa7da8b9be84 100644 (file)
@@ -5,6 +5,7 @@
                  name="org1_name"
                  guarded="[false]"
                  new_project_private="[false]"
+                 default_quality_gate_uuid="DEFAULT_QG"
                  created_at="1000"
                  updated_at="2000"/>
 
index 72c6e708229b2b1eeb3314111453d5102371615d..f3cfd334264ef9762940c7a5f3ac1c04f1a7254c 100644 (file)
@@ -5,6 +5,7 @@
                  name="org1_name"
                  guarded="[false]"
                  new_project_private="[false]"
+                 default_quality_gate_uuid="DEFAULT_QG"
                  created_at="1000"
                  updated_at="2000"/>
 
index c235e1fc744c694a306e1300dc2837c314d734fe..222670b1485b142ceab674520363aa7da8b9be84 100644 (file)
@@ -5,6 +5,7 @@
                  name="org1_name"
                  guarded="[false]"
                  new_project_private="[false]"
+                 default_quality_gate_uuid="DEFAULT_QG"
                  created_at="1000"
                  updated_at="2000"/>
 
index 0b8edb614d0a6d13bcafc180a50a1846663c9ecd..879f7973eb96206da9978e5c25ec64121773f5fc 100644 (file)
@@ -5,6 +5,7 @@
                  name="org1_name"
                  guarded="[false]"
                  new_project_private="[false]"
+                 default_quality_gate_uuid="DEFAULT_QG"
                  created_at="1000"
                  updated_at="2000"/>